[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH] libxl: add libxl__is_driver_domain function
From: Oleksandr Grytsov <oleksandr_grytsov@xxxxxxxx> libxl__is_driver_domain determines the driver domain by presence of libxl entry in the domain xen store. Use this function on device destroy to properly manage cleanup in case backends are located on domain with non zero id. Signed-off-by: Oleksandr Grytsov <oleksandr_grytsov@xxxxxxxx> --- tools/libxl/libxl_device.c | 17 ++++++++++------- tools/libxl/libxl_internal.c | 16 ++++++++++++++++ tools/libxl/libxl_internal.h | 4 ++++ 3 files changed, 30 insertions(+), 7 deletions(-) diff --git a/tools/libxl/libxl_device.c b/tools/libxl/libxl_device.c index f84422e..08a33e2 100644 --- a/tools/libxl/libxl_device.c +++ b/tools/libxl/libxl_device.c @@ -732,7 +732,7 @@ int libxl__device_destroy(libxl__gc *gc, libxl__device *dev) libxl__xs_path_cleanup(gc, t, fe_path); libxl__xs_path_cleanup(gc, t, libxl_path); } - if (dev->backend_domid == domid && !libxl_only) { + if (!libxl__is_driver_domain(gc, dev->backend_domid) && !libxl_only) { /* * The driver domain is in charge of removing what it can * from the backend path. @@ -1110,16 +1110,19 @@ static void device_hotplug(libxl__egc *egc, libxl__ao_device *aodev) LOGD(ERROR, aodev->dev->domid, "Failed to get domid"); goto out; } - if (aodev->dev->backend_domid != domid) { + + if (aodev->dev->backend_domid != domid && + aodev->action != LIBXL__DEVICE_ACTION_REMOVE) { + LOG(DEBUG, "Not a remove, not executing hotplug scripts"); + goto out; + } + + if (libxl__is_driver_domain(gc, aodev->dev->backend_domid) && + aodev->action == LIBXL__DEVICE_ACTION_REMOVE) { LOGD(DEBUG, aodev->dev->domid, "Backend domid %d, domid %d, assuming driver domains", aodev->dev->backend_domid, domid); - if (aodev->action != LIBXL__DEVICE_ACTION_REMOVE) { - LOG(DEBUG, "Not a remove, not executing hotplug scripts"); - goto out; - } - aodev->xswait.ao = ao; aodev->xswait.what = "removal of backend path"; aodev->xswait.path = be_path; diff --git a/tools/libxl/libxl_internal.c b/tools/libxl/libxl_internal.c index f492dae..a65bc58 100644 --- a/tools/libxl/libxl_internal.c +++ b/tools/libxl/libxl_internal.c @@ -575,6 +575,22 @@ void libxl__update_domain_configuration(libxl__gc *gc, dst->b_info.video_memkb = src->b_info.video_memkb; } +bool libxl__is_driver_domain(libxl__gc *gc, uint32_t domid) +{ + const char *val; + int rc; + + char *dom_path = libxl__xs_get_dompath(gc, domid); + + if (!dom_path) return false; + + rc = libxl__xs_read_checked(gc, XBT_NULL, + GCSPRINTF("%s/libxl", dom_path), &val); + if (rc) return false; + + return val != NULL; +} + /* * Local variables: * mode: C diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index 7fab561..f566d81 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -4414,6 +4414,10 @@ void* libxl__device_list(libxl__gc *gc, const struct libxl_device_type *dt, uint32_t domid, int *num); void libxl__device_list_free(const struct libxl_device_type *dt, void *list, int num); + +/* Check if domain is driver domain */ +_hidden bool libxl__is_driver_domain(libxl__gc *gc, uint32_t domid); + #endif /* -- 2.7.4 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |