[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH 6/6] libxl: Add more logging to hotplug script path



This was useful in tracking down bugs.

Signed-off-by: George Dunlap <george.dunlap@xxxxxxxxxxxxx>
---
CC: Ian Campbell <ian.campbell@xxxxxxxxxx>
CC: Ian Jackson <ian.jackson@xxxxxxxxxx>
CC: Wei Liu <wei.liu2@xxxxxxxxxx>
---
 tools/libxl/libxl_device.c | 20 +++++++++++++++++---
 tools/libxl/libxl_linux.c  |  5 +++++
 2 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/tools/libxl/libxl_device.c b/tools/libxl/libxl_device.c
index c1ca07b..d2ae42f 100644
--- a/tools/libxl/libxl_device.c
+++ b/tools/libxl/libxl_device.c
@@ -920,11 +920,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;
@@ -967,10 +969,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";
@@ -978,8 +988,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;
     }
 
@@ -991,6 +1004,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 512d2c9..4fbcba1 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;
     }
-- 
1.9.1


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.