From: George Dunlap Date: Mon, 6 Jul 2015 10:51:43 +0000 (+0100) Subject: libxl: Add more logging to hotplug script path X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~2905 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=eff228d947a645a1427fe3acbae589d44d0eaa10;p=xen.git libxl: Add more logging to hotplug script path This was useful in tracking down bugs. Signed-off-by: George Dunlap Acked-by: Wei Liu --- diff --git a/tools/libxl/libxl_device.c b/tools/libxl/libxl_device.c index 82096294be..2493972424 100644 --- a/tools/libxl/libxl_device.c +++ b/tools/libxl/libxl_device.c @@ -934,11 +934,13 @@ static void device_backend_callback(libxl__egc *egc, libxl__ev_devstate *ds, libxl__ao_device *aodev = CONTAINER_OF(ds, *aodev, backend_ds); STATE_AO_GC(aodev->ao); + LOG(DEBUG, "calling device_backend_cleanup"); device_backend_cleanup(gc, aodev); if (rc == ERROR_TIMEDOUT && aodev->action == LIBXL__DEVICE_ACTION_REMOVE && !aodev->force) { + LOG(DEBUG, "Timeout reached, initiating forced remove"); aodev->force = 1; libxl__initiate_device_remove(egc, aodev); return; @@ -981,10 +983,18 @@ static void device_hotplug(libxl__egc *egc, libxl__ao_device *aodev) * hotplug scripts */ rc = libxl__get_domid(gc, &domid); - if (rc) goto out; + if (rc) { + LOG(ERROR, "Failed to get domid"); + goto out; + } if (aodev->dev->backend_domid != domid) { - if (aodev->action != LIBXL__DEVICE_ACTION_REMOVE) + LOG(DEBUG, "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"; @@ -992,8 +1002,11 @@ static void device_hotplug(libxl__egc *egc, libxl__ao_device *aodev) aodev->xswait.timeout_ms = LIBXL_DESTROY_TIMEOUT * 1000; aodev->xswait.callback = device_destroy_be_watch_cb; rc = libxl__xswait_start(gc, &aodev->xswait); - if (rc) + if (rc) { + LOG(ERROR, "Setup of backend removal watch failed (path %s)", be_path); goto out; + } + return; } @@ -1005,6 +1018,7 @@ static void device_hotplug(libxl__egc *egc, libxl__ao_device *aodev) switch (hotplug) { case 0: /* no hotplug script to execute */ + LOG(DEBUG, "No hotplug script to execute"); goto out; case 1: /* execute hotplug script */ diff --git a/tools/libxl/libxl_linux.c b/tools/libxl/libxl_linux.c index 512d2c9ddc..4fbcba1061 100644 --- a/tools/libxl/libxl_linux.c +++ b/tools/libxl/libxl_linux.c @@ -214,6 +214,7 @@ static int libxl__hotplug_disk(libxl__gc *gc, libxl__device *dev, *env = get_hotplug_env(gc, script, dev); if (!*env) { + LOG(ERROR, "Failed to get hotplug environment"); rc = ERROR_FAIL; goto error; } @@ -225,6 +226,7 @@ static int libxl__hotplug_disk(libxl__gc *gc, libxl__device *dev, (*args)[nr++] = NULL; assert(nr == arraysize); + LOG(DEBUG, "Args and environment ready"); rc = 1; error: @@ -241,6 +243,7 @@ int libxl__get_hotplug_script_info(libxl__gc *gc, libxl__device *dev, switch (dev->backend_kind) { case LIBXL__DEVICE_KIND_VBD: if (num_exec != 0) { + LOG(DEBUG, "num_exec %d, not running hotplug scripts\n", num_exec); rc = 0; goto out; } @@ -253,6 +256,7 @@ int libxl__get_hotplug_script_info(libxl__gc *gc, libxl__device *dev, */ if ((num_exec > 1) || (libxl_get_stubdom_id(CTX, dev->domid) && num_exec)) { + LOG(DEBUG, "num_exec %d, not running hotplug scripts\n", num_exec); rc = 0; goto out; } @@ -260,6 +264,7 @@ int libxl__get_hotplug_script_info(libxl__gc *gc, libxl__device *dev, break; default: /* No need to execute any hotplug scripts */ + LOG(DEBUG, "backend_kind %d, no need to execute scripts", dev->backend_kind); rc = 0; break; }