xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: George Dunlap <george.dunlap@eu.citrix.com>
To: xen-devel@lists.xen.org
Cc: George Dunlap <george.dunlap@eu.citrix.com>,
	Ian Jackson <ian.jackson@citrix.com>,
	Wei Liu <wei.liu2@citrix.com>,
	Ian Campbell <ian.campbell@citrix.com>
Subject: [PATCH 6/6] libxl: Add more logging to hotplug script path
Date: Mon, 6 Jul 2015 11:51:43 +0100	[thread overview]
Message-ID: <1436179903-449-7-git-send-email-george.dunlap@eu.citrix.com> (raw)
In-Reply-To: <1436179903-449-1-git-send-email-george.dunlap@eu.citrix.com>

This was useful in tracking down bugs.

Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com>
---
CC: Ian Campbell <ian.campbell@citrix.com>
CC: Ian Jackson <ian.jackson@citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
---
 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

  parent reply	other threads:[~2015-07-06 10:51 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-06 10:51 [PATCH 0/6] Use system blktap George Dunlap
2015-07-06 10:51 ` [PATCH 1/6] libxl: Make local_initiate_attach more rational George Dunlap
2015-07-06 10:51 ` [PATCH 2/6] libxl: Remove linux udev rules George Dunlap
2015-07-07 11:39   ` Wei Liu
2015-07-14 16:13     ` Konrad Rzeszutek Wilk
2015-07-14 16:21       ` Ian Campbell
2015-07-14 16:35         ` George Dunlap
2015-07-14 16:40           ` Wei Liu
2015-07-14 16:48             ` Ian Campbell
2015-07-23 11:55               ` Roger Pau Monné
2015-07-23 12:30                 ` Ian Campbell
2015-07-15 11:07         ` [PATCH for-4.6] tools/hotplug: Add an initscript to start "xl devd" in a driver domain Ian Campbell
2015-07-15 13:26           ` Wei Liu
2015-07-15 13:40             ` Ian Campbell
2015-07-15 15:25           ` George Dunlap
2015-07-15 15:32           ` Ian Jackson
2015-07-15 15:35             ` George Dunlap
2015-07-15 15:37               ` Ian Campbell
2015-07-16 16:58         ` [PATCH for-4.6 v2] " Ian Campbell
2015-07-16 17:09           ` Ian Jackson
2015-07-16 17:48           ` Wei Liu
2015-07-17  9:05           ` Wei Liu
2015-07-17 11:36             ` Ian Campbell
2015-07-20 14:16           ` Roger Pau Monné
2015-07-20 14:28             ` Ian Campbell
2015-07-06 10:51 ` [PATCH 3/6] tools: Add a block-tap script for setting up tapdisks via tap-ctl George Dunlap
2015-07-07 12:03   ` Wei Liu
2015-07-07 12:35     ` Wei Liu
2015-07-06 10:51 ` [PATCH 4/6] libxl: Use the block-tap script for LIBXL_DISK_BACKEND_TAP George Dunlap
2015-07-06 11:01   ` Andrew Cooper
2015-07-06 12:39     ` George Dunlap
2015-07-07 12:29   ` Wei Liu
2015-07-07 13:41     ` George Dunlap
2015-07-07 14:20       ` Ian Campbell
2015-07-07 14:27         ` George Dunlap
2015-07-06 10:51 ` [PATCH 5/6] tools: Remove in-tree blktap2 George Dunlap
2015-07-07 11:55   ` Wei Liu
2015-07-06 10:51 ` George Dunlap [this message]
2015-07-07 11:55   ` [PATCH 6/6] libxl: Add more logging to hotplug script path Wei Liu
2015-07-07 14:21 ` [PATCH 0/6] Use system blktap Ian Campbell
2015-07-07 14:24   ` George Dunlap
2015-07-07 14:52     ` Ian Campbell
2015-07-07 14:59       ` George Dunlap
2015-07-07 15:04         ` Ian Campbell
2015-07-07 15:20 ` Ian Campbell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1436179903-449-7-git-send-email-george.dunlap@eu.citrix.com \
    --to=george.dunlap@eu.citrix.com \
    --cc=ian.campbell@citrix.com \
    --cc=ian.jackson@citrix.com \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).