Skip to contentSkip to conversation

libxl: call hotplug scripts from libxl

PATCH Superseded Roger Pau Monne 2 participants 18 messages Apr 16, 2012 – Apr 17, 2012 Arm/actions semi architecture

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

cover libxl: call hotplug scripts from libxl

This series removes the use of udev rules to call hotplug scripts when using libxl. Scripts are directly called from the toolstack at the necessary points, making use of the new event library and it's fork support.

[PATCH 1/5] libxl: allow libxl__exec to take a parameter containing

Small change to libxl__exec, so we can pass an array of env variables.

[PATCH 2/5] libxl: call hotplug scripts from libxl for vbd

Much of the meat is in this patch and the following one. Most significant changes in this patch, (apart from the introduction of the hotplug functions), is the addition of a new xenstore entry in each backend directory, that tells the hotplug script wheter it should be executed from udev or form the toolstack.

[PATCH 3/5] libxl: call hotplug scripts from libxl for vif

Another xenstore backend entry is added on this patch for each nic device, called "type", it stores the type of the interface (currently only VIF or IOEMU), so that the plug and unplug operations know with what they are dealing.

[PATCH 4/5] libxl: add "downscript=no" to Qemu call [PATCH 5/5] libxl: clean xenstore console directories recursively on

Two minor bugfixes that I've found while working on this hotplug series.

#1 lore raw

PATCH 1/5 libxl: allow libxl__exec to take a parameter containing the env variables

Add another parameter to libxl__exec call that contains the environment variables to use when performing the execvp call.

---
 tools/libxl/libxl.c            |    2 +-
 tools/libxl/libxl_bootloader.c |    4 ++--
 tools/libxl/libxl_dm.c         |    2 +-
 tools/libxl/libxl_exec.c       |    7 ++++++-
 tools/libxl/libxl_internal.h   |   13 ++++++++++++-
 5 files changed, 22 insertions(+), 6 deletions(-)
tools/libxl/libxl.c +1 -1
index 59992b6..16ebef3 100644
@@ -1253,7 +1253,7 @@ int libxl_vncviewer_exec(libxl_ctx *ctx, uint32_t domid, int autopass)
         args[2] = "-autopass";
     }
 
-    libxl__exec(autopass_fd, -1, -1, args[0], args);
+    libxl__exec(autopass_fd, -1, -1, args[0], args, NULL);
     abort();
 
  x_fail:
tools/libxl/libxl_bootloader.c +2 -2
index 2774062..7120dad 100644
@@ -113,12 +113,12 @@ static int open_xenconsoled_pty(int *master, int *slave, char *slave_path, size_
 static pid_t fork_exec_bootloader(int *master, const char *arg0, char **args)
 {
     struct termios termattr;
+    char *env[] = {"TERM", "vt100", NULL};
     pid_t pid = forkpty(master, NULL, NULL, NULL);
     if (pid == -1)
         return -1;
     else if (pid == 0) {
-        setenv("TERM", "vt100", 1);
-        libxl__exec(-1, -1, -1, arg0, args);
+        libxl__exec(-1, -1, -1, arg0, args, env);
         return -1;
     }
 
tools/libxl/libxl_dm.c +1 -1
index 1261499..30908d1 100644
@@ -991,7 +991,7 @@ retry_transaction:
         goto out_close;
     if (!rc) { /* inner child */
         setsid();
-        libxl__exec(null, logfile_w, logfile_w, dm, args);
+        libxl__exec(null, logfile_w, logfile_w, dm, args, NULL);
     }
 
     rc = 0;
tools/libxl/libxl_exec.c +6 -1
index b10e79f..be9e407 100644
@@ -72,7 +72,7 @@ static void check_open_fds(const char *what)
 }
 
 void libxl__exec(int stdinfd, int stdoutfd, int stderrfd, const char *arg0,
-                char **args)
+                char **args, char **env)
      /* call this in the child */
 {
     if (stdinfd != -1)
@@ -95,6 +95,11 @@ void libxl__exec(int stdinfd, int stdoutfd, int stderrfd, const char *arg0,
     /* in case our caller set it to IGN.  subprocesses are entitled
      * to assume they got DFL. */
 
+    if (env != NULL) {
+        for (int i = 0; env[i] != NULL && env[i+1] != NULL; i += 2) {
+            setenv(env[i], env[i+1], 1);
+        }
+    }
     execvp(arg0, args);
 
     fprintf(stderr, "libxl: cannot execute %s: %s\n", arg0, strerror(errno));
tools/libxl/libxl_internal.h +12 -1
index d486af2..2181774 100644
@@ -949,8 +949,19 @@ _hidden int libxl__spawn_check(libxl__gc *gc,
 
  /* low-level stuff, for synchronous subprocesses etc. */
 
+/*
+ * env should be passed using the following format,
+ *
+ * env[0]: name of env variable
+ * env[1]: value of env variable
+ *
+ * So it efectively becomes something like:
+ * export env[0]=env[1]
+ *
+ * The last entry of the array always has to be NULL.
+ */
 _hidden void libxl__exec(int stdinfd, int stdoutfd, int stderrfd,
-               const char *arg0, char **args); // logs errors, never returns
+               const char *arg0, char **args, char **env); // logs errors, never returns
 
 /* from xl_create */
 _hidden int libxl__domain_make(libxl__gc *gc,
Signature · 1 line
1.7.7.5 (Apple Git-26)
#2 lore raw

PATCH 2/5 libxl: call hotplug scripts from libxl for vbd

In reply to Roger Pau Monne

This is a rather big change, that adds the necessary machinery to perform hotplug script calling from libxl for Linux. This patch launches the necessary scripts to attach and detach PHY and TAP backend types (Qemu doesn't use hotplug scripts).

Here's a list of the major changes introduced:

* libxl_device_disk_add makes use of the new event library and takes the optional parameter libxl_asyncop_how, to choose how the operation has to be issued (sync or async).

* libxl_device_disk_add waits for backend to switch to state 2 (XenbusInitWait) and then launches the hotplug script.

* libxl__devices_destroy no longer calls libxl__device_destroy, and instead calls libxl__initiate_device_remove, so we can disconnect the device and execute the necessary hotplug scripts instead of just deleting the backend entries. So libxl__devices_destroy now uses the event library, and so does libxl_domain_destroy.

* Since libxl__devices_destroy calls multiple times libxl__initiate_device_remove, this function now returns a different value regarding the actions taken (if an event was added or not). The user has to call libxl__ao_complete after using this function if necessary.

* The internal API for hotplug scripts has been added, which consists of one function; libxl__device_hotplug that takes the device and the action to execute.

* Linux hotplug scripts are called by setting the necessary env variables to emulate udev rules, so there's no need to change them (although a rework to pass this as parameters insted of env variables would be suitable, so both NetBSD and Linux hotplug scripts take the same parameters).

* Added a check in xen-hotplug-common.sh, so scripts are only executed from udev when using xend. xl adds an execute_udev=n to xenstore device backend and passes XL_CALL=y to the env of the script call, and udev calls check that execute_udev is not set and XL_CALL is empty also.

I've also modified the python binding for pyxl_domain_destroy, that now take the ao_how parameter, but I'm not really sure if it's done correctly, let's just say that it compiles.

---
 tools/hotplug/Linux/xen-hotplug-common.sh |    6 ++
 tools/libxl/Makefile                      |    3 +-
 tools/libxl/libxl.c                       |  104 ++++++++++++++++++----
 tools/libxl/libxl.h                       |    7 +-
 tools/libxl/libxl_create.c                |    4 +-
 tools/libxl/libxl_device.c                |  140 +++++++++++++++++++++++++++--
 tools/libxl/libxl_dm.c                    |    4 +-
 tools/libxl/libxl_hotplug.c               |   67 ++++++++++++++
 tools/libxl/libxl_internal.h              |   43 +++++++++-
 tools/libxl/libxl_linux.c                 |  117 ++++++++++++++++++++++++
 tools/libxl/xl_cmdimpl.c                  |   14 ++--
 tools/python/xen/lowlevel/xl/xl.c         |    5 +-
 12 files changed, 474 insertions(+), 40 deletions(-)
 create mode 100644 tools/libxl/libxl_hotplug.c
tools/hotplug/Linux/xen-hotplug-common.sh +6 -0
index 8f6557d..dc3e867 100644
@@ -15,6 +15,12 @@
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 #
 
+# Hack to prevent the execution of hotplug scripts form udev if the domain
+# has ben launched from libxl
+execute_udev=`xenstore-read $XENBUS_PATH/execute_udev 2>/dev/null`
+if [ -n "$execute_udev" ] && [ -z "$XL_CALL" ]; then
+    exit 0
+fi
 
 dir=$(dirname "$0")
 . "$dir/hotplugpath.sh"
tools/libxl/Makefile +2 -1
index b30d11f..ac8b810 100644
@@ -53,7 +53,8 @@ LIBXL_LIBS += -lyajl
 LIBXL_OBJS = flexarray.o libxl.o libxl_create.o libxl_dm.o libxl_pci.o \
 			libxl_dom.o libxl_exec.o libxl_xshelp.o libxl_device.o \
 			libxl_internal.o libxl_utils.o libxl_uuid.o libxl_json.o \
-			libxl_qmp.o libxl_event.o libxl_fork.o $(LIBXL_OBJS-y)
+			libxl_qmp.o libxl_event.o libxl_fork.o libxl_hotplug.o \
+			$(LIBXL_OBJS-y)
 LIBXL_OBJS += _libxl_types.o libxl_flask.o _libxl_types_internal.o
 
 $(LIBXL_OBJS): CFLAGS += $(CFLAGS_libxenctrl) $(CFLAGS_libxenguest) $(CFLAGS_libxenstore) $(CFLAGS_libblktapctl) -include $(XEN_ROOT)/tools/config.h
tools/libxl/libxl.c +88 -16

204 lines not on this page · raw message

tools/libxl/libxl.h +5 -2
index 50bae2f..b7347be 100644
@@ -394,7 +394,8 @@ int libxl_domain_suspend(libxl_ctx *ctx, libxl_domain_suspend_info *info,
 int libxl_domain_resume(libxl_ctx *ctx, uint32_t domid);
 int libxl_domain_shutdown(libxl_ctx *ctx, uint32_t domid);
 int libxl_domain_reboot(libxl_ctx *ctx, uint32_t domid);
-int libxl_domain_destroy(libxl_ctx *ctx, uint32_t domid);
+int libxl_domain_destroy(libxl_ctx *ctx, uint32_t domid,
+                         const libxl_asyncop_how *ao_how);
 int libxl_domain_preserve(libxl_ctx *ctx, uint32_t domid, libxl_domain_create_info *info, const char *name_suffix, libxl_uuid new_uuid);
 
 /* get max. number of cpus supported by hypervisor */
@@ -523,7 +524,9 @@ void libxl_vminfo_list_free(libxl_vminfo *list, int nr);
  */
 
 /* Disks */
-int libxl_device_disk_add(libxl_ctx *ctx, uint32_t domid, libxl_device_disk *disk);
+int libxl_device_disk_add(libxl_ctx *ctx, uint32_t domid,
+                          libxl_device_disk *disk,
+                          const libxl_asyncop_how *ao_how);
 int libxl_device_disk_remove(libxl_ctx *ctx, uint32_t domid,
                              libxl_device_disk *disk,
                              const libxl_asyncop_how *ao_how);
tools/libxl/libxl_create.c +2 -2
index 3675afe..de598ad 100644
@@ -598,7 +598,7 @@ static int do_domain_create(libxl__gc *gc, libxl_domain_config *d_config,
     store_libxl_entry(gc, domid, &d_config->b_info);
 
     for (i = 0; i < d_config->num_disks; i++) {
-        ret = libxl_device_disk_add(ctx, domid, &d_config->disks[i]);
+        ret = libxl_device_disk_add(ctx, domid, &d_config->disks[i], 0);
         if (ret) {
             LIBXL__LOG(ctx, LIBXL__LOG_ERROR,
                        "cannot add disk %d to domain: %d", i, ret);
@@ -721,7 +721,7 @@ static int do_domain_create(libxl__gc *gc, libxl_domain_config *d_config,
 
 error_out:
     if (domid)
-        libxl_domain_destroy(ctx, domid);
+        libxl_domain_destroy(ctx, domid, 0);
 
     return ret;
 }
tools/libxl/libxl_device.c +133 -7

211 lines not on this page · raw message

tools/libxl/libxl_dm.c +2 -2
index 30908d1..2d51a7f 100644
@@ -790,7 +790,7 @@ retry_transaction:
             goto retry_transaction;
 
     for (i = 0; i < dm_config.num_disks; i++) {
-        ret = libxl_device_disk_add(ctx, dm_domid, &dm_config.disks[i]);
+        ret = libxl_device_disk_add(ctx, dm_domid, &dm_config.disks[i], 0);
         if (ret)
             goto out_free;
     }
@@ -1044,7 +1044,7 @@ int libxl__destroy_device_model(libxl__gc *gc, uint32_t domid)
             goto out;
         }
         LIBXL__LOG(ctx, LIBXL__LOG_DEBUG, "Device model is a stubdom, domid=%d", stubdomid);
-        ret = libxl_domain_destroy(ctx, stubdomid);
+        ret = libxl_domain_destroy(ctx, stubdomid, 0);
         if (ret)
             goto out;
 
tools/libxl/libxl_hotplug.c new file +67 -0

67 lines not on this page · raw message

tools/libxl/libxl_internal.h +42 -1

67 lines not on this page · raw message

tools/libxl/libxl_linux.c +117 -0

120 lines not on this page · raw message

tools/libxl/xl_cmdimpl.c +7 -7
index 08815a3..01ff363 100644
@@ -1301,7 +1301,7 @@ static int handle_domain_death(libxl_ctx *ctx, uint32_t domid,
         /* fall-through */
     case LIBXL_ACTION_ON_SHUTDOWN_DESTROY:
         LOG("Domain %d needs to be cleaned up: destroying the domain", domid);
-        libxl_domain_destroy(ctx, domid);
+        libxl_domain_destroy(ctx, domid, 0);
         break;
 
     case LIBXL_ACTION_ON_SHUTDOWN_COREDUMP_DESTROY:
@@ -1862,7 +1862,7 @@ start:
 error_out:
     release_lock();
     if (libxl_domid_valid_guest(domid))
-        libxl_domain_destroy(ctx, domid);
+        libxl_domain_destroy(ctx, domid, 0);
 
 out:
     if (logfile != 2)
@@ -2339,7 +2339,7 @@ static void destroy_domain(const char *p)
         fprintf(stderr, "Cannot destroy privileged domain 0.\n\n");
         exit(-1);
     }
-    rc = libxl_domain_destroy(ctx, domid);
+    rc = libxl_domain_destroy(ctx, domid, 0);
     if (rc) { fprintf(stderr,"destroy failed (rc=%d)\n",rc); exit(-1); }
 }
 
@@ -2613,7 +2613,7 @@ static int save_domain(const char *p, const char *filename, int checkpoint,
     if (checkpoint)
         libxl_domain_unpause(ctx, domid);
     else
-        libxl_domain_destroy(ctx, domid);
+        libxl_domain_destroy(ctx, domid, 0);
 
     exit(0);
 }
@@ -2846,7 +2846,7 @@ static void migrate_domain(const char *domain_spec, const char *rune,
     }
 
     fprintf(stderr, "migration sender: Target reports successful startup.\n");
-    libxl_domain_destroy(ctx, domid); /* bang! */
+    libxl_domain_destroy(ctx, domid, 0); /* bang! */
     fprintf(stderr, "Migration successful.\n");
     exit(0);
 
@@ -2964,7 +2964,7 @@ static void migrate_receive(int debug, int daemonize, int monitor)
     if (rc) {
         fprintf(stderr, "migration target: Failure, destroying our copy.\n");
 
-        rc2 = libxl_domain_destroy(ctx, domid);
+        rc2 = libxl_domain_destroy(ctx, domid, 0);
         if (rc2) {
             fprintf(stderr, "migration target: Failed to destroy our copy"
                     " (code %d).\n", rc2);
@@ -5011,7 +5011,7 @@ int main_blockattach(int argc, char **argv)
         return 0;
     }
 
-    if (libxl_device_disk_add(ctx, fe_domid, &disk)) {
+    if (libxl_device_disk_add(ctx, fe_domid, &disk, 0)) {
         fprintf(stderr, "libxl_device_disk_add failed.\n");
     }
     return 0;
tools/python/xen/lowlevel/xl/xl.c +3 -2
index bbbf2a9..a41a720 100644
@@ -444,9 +444,10 @@ static PyObject *pyxl_domain_reboot(XlObject *self, PyObject *args)
 static PyObject *pyxl_domain_destroy(XlObject *self, PyObject *args)
 {
     int domid;
-    if ( !PyArg_ParseTuple(args, "i", &domid) )
+    const libxl_asyncop_how *ao_how;
+    if ( !PyArg_ParseTuple(args, "ii", &domid, &ao_how) )
         return NULL;
-    if ( libxl_domain_destroy(self->ctx, domid) ) {
+    if ( libxl_domain_destroy(self->ctx, domid, ao_how) ) {
         PyErr_SetString(xl_error_obj, "cannot destroy domain");
         return NULL;
     }
Signature · 1 line
1.7.7.5 (Apple Git-26)
#3 lore raw

Re: [PATCH 2/5] libxl: call hotplug scripts from libxl for vbd

Quoted 65 lines · Roger Pau Monne

This is a rather big change, that adds the necessary machinery to perform hotplug script calling from libxl for Linux. This patch launches the necessary scripts to attach and detach PHY and TAP backend types (Qemu doesn't use hotplug scripts).

Here's a list of the major changes introduced:

* libxl_device_disk_add makes use of the new event library and takes the optional parameter libxl_asyncop_how, to choose how the operation has to be issued (sync or async).

* libxl_device_disk_add waits for backend to switch to state 2 (XenbusInitWait) and then launches the hotplug script.

* libxl__devices_destroy no longer calls libxl__device_destroy, and instead calls libxl__initiate_device_remove, so we can disconnect the device and execute the necessary hotplug scripts instead of just deleting the backend entries. So libxl__devices_destroy now uses the event library, and so does libxl_domain_destroy.

* Since libxl__devices_destroy calls multiple times libxl__initiate_device_remove, this function now returns a different value regarding the actions taken (if an event was added or not). The user has to call libxl__ao_complete after using this function if necessary.

* The internal API for hotplug scripts has been added, which consists of one function; libxl__device_hotplug that takes the device and the action to execute.

* Linux hotplug scripts are called by setting the necessary env variables to emulate udev rules, so there's no need to change them (although a rework to pass this as parameters insted of env variables would be suitable, so both NetBSD and Linux hotplug scripts take the same parameters).

* Added a check in xen-hotplug-common.sh, so scripts are only executed from udev when using xend. xl adds an execute_udev=n to xenstore device backend and passes XL_CALL=y to the env of the script call, and udev calls check that execute_udev is not set and XL_CALL is empty also.

I've also modified the python binding for pyxl_domain_destroy, that now take the ao_how parameter, but I'm not really sure if it's done correctly, let's just say that it compiles.

---
 tools/hotplug/Linux/xen-hotplug-common.sh |    6 ++
 tools/libxl/Makefile                      |    3 +-
 tools/libxl/libxl.c                       |  104 ++++++++++++++++++----
 tools/libxl/libxl.h                       |    7 +-
 tools/libxl/libxl_create.c                |    4 +-
 tools/libxl/libxl_device.c                |  140 +++++++++++++++++++++++++++--
 tools/libxl/libxl_dm.c                    |    4 +-
 tools/libxl/libxl_hotplug.c               |   67 ++++++++++++++
 tools/libxl/libxl_internal.h              |   43 +++++++++-
 tools/libxl/libxl_linux.c                 |  117 ++++++++++++++++++++++++
 tools/libxl/xl_cmdimpl.c                  |   14 ++--
 tools/python/xen/lowlevel/xl/xl.c         |    5 +-
 12 files changed, 474 insertions(+), 40 deletions(-)
 create mode 100644 tools/libxl/libxl_hotplug.c
tools/hotplug/Linux/xen-hotplug-common.sh +0 -0
index 8f6557d..dc3e867 100644

tools/hotplug/Linux/xen-hotplug-common.sh line 18

Quoted 4 lines
tools/hotplug/Linux/xen-hotplug-common.sh +1 -0
@@ -15,6 +15,12 @@
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 #
 
+# Hack to prevent the execution of hotplug scripts form udev if the domain

from

tools/hotplug/Linux/xen-hotplug-common.sh line 19

Quoted 1 line
tools/hotplug/Linux/xen-hotplug-common.sh +1 -0
+# has ben launched from libxl

been

tools/hotplug/Linux/xen-hotplug-common.sh line 23

Quoted 4 lines
tools/hotplug/Linux/xen-hotplug-common.sh +4 -0
+execute_udev=`xenstore-read $XENBUS_PATH/execute_udev 2>/dev/null`
+if [ -n "$execute_udev" ] && [ -z "$XL_CALL" ]; then
+    exit 0
+fi

So, am I right that in some future world where we have got rid of xend and made this stuff work without udev everywhere (e.g. including driver domains) there is a path to deprecating this snippet without requiring everyone to go through some sort of transition?

Or are we stuck with this envvar forever? It's not a big deal but if we can invert it (e.g. by setting ENV{HOTPLUG_GATE}=${XENBUS}/evecute_udev in xen-backend.rules and ...if -n "${HOTPLUG_GATE}" && xenstore-read ${HOTPLUG_GATE}... etc) then that would be nicer?

Quoted 106 lines
tools/hotplug/Linux/xen-hotplug-common.sh +0 -0
 dir=$(dirname "$0")
 . "$dir/hotplugpath.sh"
tools/libxl/libxl.c +27 -8
index 16ebef3..fb4fbf2 100644
@@ -1062,13 +1062,15 @@ void libxl_evdisable_disk_eject(libxl_ctx *ctx, libxl_evgen_disk_eject *evg) {
     GC_FREE;
 }
 
-int libxl_domain_destroy(libxl_ctx *ctx, uint32_t domid)
+int libxl_domain_destroy(libxl_ctx *ctx, uint32_t domid,
+                         const libxl_asyncop_how *ao_how)
 {
-    GC_INIT(ctx);
+    AO_CREATE(ctx, domid, ao_how);
     char *dom_path;
     char *vm_path;
     char *pid;
     int rc, dm_present;
+    int rc_ao = 0;
 
     rc = libxl_domain_info(ctx, NULL, domid);
     switch(rc) {
@@ -1110,7 +1112,8 @@ int libxl_domain_destroy(libxl_ctx *ctx, uint32_t domid)
 
         libxl__qmp_cleanup(gc, domid);
     }
-    if (libxl__devices_destroy(gc, domid) < 0)
+    rc_ao = libxl__devices_destroy(egc, ao, domid);
+    if (rc_ao < 0)
         LIBXL__LOG(ctx, LIBXL__LOG_ERROR,
                    "libxl__devices_destroy failed for %d", domid);
 
@@ -1133,9 +1136,10 @@ int libxl_domain_destroy(libxl_ctx *ctx, uint32_t domid)
         goto out;
     }
     rc = 0;
+
 out:
-    GC_FREE;
-    return rc;
+    if (rc_ao) return AO_ABORT(rc_ao);
+    return AO_INPROGRESS;
 }
 
 int libxl_console_exec(libxl_ctx *ctx, uint32_t domid, int cons_num, libxl_console_type type)
@@ -1313,9 +1317,11 @@ static int libxl__device_from_disk(libxl__gc *gc, uint32_t domid,
     return 0;
 }
 
-int libxl_device_disk_add(libxl_ctx *ctx, uint32_t domid, libxl_device_disk *disk)
+int libxl_device_disk_add(libxl_ctx *ctx, uint32_t domid,
+                          libxl_device_disk *disk,
+                          const libxl_asyncop_how *ao_how)
 {
-    GC_INIT(ctx);
+    AO_CREATE(ctx, domid, ao_how);
     flexarray_t *front;
     flexarray_t *back;
     char *dev;
@@ -1330,7 +1336,7 @@ int libxl_device_disk_add(libxl_ctx *ctx, uint32_t domid, libxl_device_disk *dis
         rc = ERROR_NOMEM;
         goto out;
     }
-    back = flexarray_make(16, 1);
+    back = flexarray_make(20, 1);
     if (!back) {
         rc = ERROR_NOMEM;
         goto out_free;
@@ -1361,6 +1367,11 @@ int libxl_device_disk_add(libxl_ctx *ctx, uint32_t domid, libxl_device_disk *dis
             flexarray_append(back, "params");
             flexarray_append(back, dev);
 
+            flexarray_append(back, "script");
+            flexarray_append(back, libxl__sprintf(gc, "%s/%s",
+                                                  libxl_xen_script_dir_path(),
+                                                  "block"));
+
             assert(device.backend_kind == LIBXL__DEVICE_KIND_VBD);
             break;
         case LIBXL_DISK_BACKEND_TAP:
@@ -1374,6 +1385,11 @@ int libxl_device_disk_add(libxl_ctx *ctx, uint32_t domid, libxl_device_disk *dis
                 libxl__device_disk_string_of_format(disk->format),
                 disk->pdev_path));
 
+            flexarray_append(back, "script");
+            flexarray_append(back, libxl__sprintf(gc, "%s/%s",
+                             libxl_xen_script_dir_path(),
+                             "blktap"));
+
             /* now create a phy device to export the device to the guest */
             goto do_backend_phy;
         case LIBXL_DISK_BACKEND_QDISK:
@@ -1406,6 +1422,9 @@ int libxl_device_disk_add(libxl_ctx *ctx, uint32_t domid, libxl_device_disk *dis
     flexarray_append(back, disk->readwrite ? "w" : "r");
     flexarray_append(back, "device-type");
     flexarray_append(back, disk->is_cdrom ? "cdrom" : "disk");
+    /* compatibility addon to keep udev rules */
+    flexarray_append(back, "execute_udev");
+    flexarray_append(back, "n");
 
     flexarray_append(front, "backend-id");
     flexarray_append(front, libxl__sprintf(gc, "%d", disk->backend_domid));
@@ -1420,14 +1439,23 @@ int libxl_device_disk_add(libxl_ctx *ctx, uint32_t domid, libxl_device_disk *dis
                              libxl__xs_kvs_of_flexarray(gc, back, back->count),

tools/libxl/libxl.c int libxl_device_disk_add(libxl_ctx *ctx, uint32_t domid, libxl_device_disk *dis · line 1449

Quoted 10 lines
tools/libxl/libxl.c +8 -0
                              libxl__xs_kvs_of_flexarray(gc, front, front->count));
 
+    if (disk->backend == LIBXL_DISK_BACKEND_PHY ||
+        disk->backend == LIBXL_DISK_BACKEND_TAP) {
+        rc = libxl__initiate_device_add(egc, ao, &device);
+        if (rc) goto out_free;
+    } else {
+        /* no need to execute hotplug scripts */
+        libxl__ao_complete(egc, ao, 0);
+    }

This would be better as a switch, since it would make it more obvious that the "else" is actually "case LIBXL_DISK_BACKEND_QDISK" etc.

[...]

tools/libxl/libxl.c int libxl_device_disk_add(libxl_ctx *ctx, uint32_t domid, libxl_device_disk *dis · line 1454

Quoted 5 lines
tools/libxl/libxl.c +5 -0
+
+/*
+ * Return codes:
+ * 1 Success and event(s) HAVE BEEN added
+ * 0 Success and NO events where added

were

(I saw a few of these)

Quoted 10 lines
tools/libxl/libxl.c +6 -0
+ * < 0 Error
+ *
+ * Since this function can be called several times, and several events
+ * can be added to the same context, the user has to call
+ * libxl__ao_complete when necessary (if no events are added).
+ */
 int libxl__initiate_device_remove(libxl__egc *egc, libxl__ao *ao,
                                   libxl__device *dev)
 {
@@ -392,7 +461,6 @@ int libxl__initiate_device_remove(libxl__egc *egc, libxl__ao *ao,

[...]

#4 lore raw

Re: [PATCH 2/5] libxl: call hotplug scripts from libxl for vbd

Quoted 69 lines · Ian Campbell
Quoted 68 lines · Roger Pau Monne

This is a rather big change, that adds the necessary machinery to perform hotplug script calling from libxl for Linux. This patch launches the necessary scripts to attach and detach PHY and TAP backend types (Qemu doesn't use hotplug scripts).

Here's a list of the major changes introduced:

* libxl_device_disk_add makes use of the new event library and takes the optional parameter libxl_asyncop_how, to choose how the operation has to be issued (sync or async).

* libxl_device_disk_add waits for backend to switch to state 2 (XenbusInitWait) and then launches the hotplug script.

* libxl__devices_destroy no longer calls libxl__device_destroy, and instead calls libxl__initiate_device_remove, so we can disconnect the device and execute the necessary hotplug scripts instead of just deleting the backend entries. So libxl__devices_destroy now uses the event library, and so does libxl_domain_destroy.

* Since libxl__devices_destroy calls multiple times libxl__initiate_device_remove, this function now returns a different value regarding the actions taken (if an event was added or not). The user has to call libxl__ao_complete after using this function if necessary.

* The internal API for hotplug scripts has been added, which consists of one function; libxl__device_hotplug that takes the device and the action to execute.

* Linux hotplug scripts are called by setting the necessary env variables to emulate udev rules, so there's no need to change them (although a rework to pass this as parameters insted of env variables would be suitable, so both NetBSD and Linux hotplug scripts take the same parameters).

* Added a check in xen-hotplug-common.sh, so scripts are only executed from udev when using xend. xl adds an execute_udev=n to xenstore device backend and passes XL_CALL=y to the env of the script call, and udev calls check that execute_udev is not set and XL_CALL is empty also.

I've also modified the python binding for pyxl_domain_destroy, that now take the ao_how parameter, but I'm not really sure if it's done correctly, let's just say that it compiles.

---

tools/hotplug/Linux/xen-hotplug-common.sh |    6 ++
tools/libxl/Makefile                      |    3 +-
tools/libxl/libxl.c                       |  104 ++++++++++++++++++----
tools/libxl/libxl.h                       |    7 +-
tools/libxl/libxl_create.c                |    4 +-
tools/libxl/libxl_device.c                |  140 +++++++++++++++++++++++++++--
tools/libxl/libxl_dm.c                    |    4 +-
tools/libxl/libxl_hotplug.c               |   67 ++++++++++++++
tools/libxl/libxl_internal.h              |   43 +++++++++-
tools/libxl/libxl_linux.c                 |  117 ++++++++++++++++++++++++
tools/libxl/xl_cmdimpl.c                  |   14 ++--
tools/python/xen/lowlevel/xl/xl.c         |    5 +-
12 files changed, 474 insertions(+), 40 deletions(-)

create mode 100644 tools/libxl/libxl_hotplug.c

tools/hotplug/Linux/xen-hotplug-common.sh +0 -0
index 8f6557d..dc3e867 100644
@@ -15,6 +15,12 @@
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 #
 
Quoted 6 lines

tools/hotplug/Linux/xen-hotplug-common.sh line 18

Quoted 1 line
tools/hotplug/Linux/xen-hotplug-common.sh +1 -0
+# Hack to prevent the execution of hotplug scripts form udev if the domain

from

tools/hotplug/Linux/xen-hotplug-common.sh line 19

Quoted 1 line
tools/hotplug/Linux/xen-hotplug-common.sh +1 -0
+# has ben launched from libxl

been

Done

Quoted 11 lines

tools/hotplug/Linux/xen-hotplug-common.sh line 23

Quoted 5 lines
tools/hotplug/Linux/xen-hotplug-common.sh +4 -0
+execute_udev=`xenstore-read $XENBUS_PATH/execute_udev 2>/dev/null`
+if [ -n "$execute_udev" ] && [ -z "$XL_CALL" ]; then
+    exit 0
+fi

So, am I right that in some future world where we have got rid of xend and made this stuff work without udev everywhere (e.g. including driver domains) there is a path to deprecating this snippet without requiring everyone to go through some sort of transition?

Quoted 4 lines

Or are we stuck with this envvar forever? It's not a big deal but if we can invert it (e.g. by setting ENV{HOTPLUG_GATE}=${XENBUS}/evecute_udev in xen-backend.rules and ...if -n "${HOTPLUG_GATE}" && xenstore-read ${HOTPLUG_GATE}... etc) then that would be nicer?

I will change it to something like:

if [ -z "${HOTPLUG_GATE}" ] && xenstore-read "$HOTPLUG_GATE" 2>/dev/null && \
[ -z "$XL_CALL" ]; then

and then set HOTPLUG_GATE from udev rules. I will change the xenstore gate to "disable_udev", which makes more sense, since we will be setting "disable_udev=y" or nothing.

Quoted 108 lines
Quoted 108 lines
tools/hotplug/Linux/xen-hotplug-common.sh +0 -0
 dir=$(dirname "$0")

. "$dir/hotplugpath.sh"

tools/libxl/libxl.c +7 -3
index 16ebef3..fb4fbf2 100644
@@ -1062,13 +1062,15 @@ void libxl_evdisable_disk_eject(libxl_ctx *ctx, libxl_evgen_disk_eject *evg) {
    GC_FREE;
 }
 
-int libxl_domain_destroy(libxl_ctx *ctx, uint32_t domid)
+int libxl_domain_destroy(libxl_ctx *ctx, uint32_t domid,
+                         const libxl_asyncop_how *ao_how)
 {
-    GC_INIT(ctx);
+    AO_CREATE(ctx, domid, ao_how);
    char *dom_path;
    char *vm_path;
    char *pid;
    int rc, dm_present;
+    int rc_ao = 0;
 
    rc = libxl_domain_info(ctx, NULL, domid);
    switch(rc) {
@@ -1110,7 +1112,8 @@ int libxl_domain_destroy(libxl_ctx *ctx, uint32_t domid)
 
        libxl__qmp_cleanup(gc, domid);
    }
-    if (libxl__devices_destroy(gc, domid) < 0)
+    rc_ao = libxl__devices_destroy(egc, ao, domid);
+    if (rc_ao < 0)
        LIBXL__LOG(ctx, LIBXL__LOG_ERROR,
                   "libxl__devices_destroy failed for %d", domid);
 
@@ -1133,9 +1136,10 @@ int libxl_domain_destroy(libxl_ctx *ctx, uint32_t domid)
        goto out;
    }
    rc = 0;
+

out:

tools/libxl/libxl.c +2 -2
-    GC_FREE;
-    return rc;
+    if (rc_ao) return AO_ABORT(rc_ao);
+    return AO_INPROGRESS;

}

int libxl_console_exec(libxl_ctx *ctx, uint32_t domid, int cons_num, libxl_console_type type)

tools/libxl/libxl.c +18 -3
@@ -1313,9 +1317,11 @@ static int libxl__device_from_disk(libxl__gc *gc, uint32_t domid,
    return 0;
 }
 
-int libxl_device_disk_add(libxl_ctx *ctx, uint32_t domid, libxl_device_disk *disk)
+int libxl_device_disk_add(libxl_ctx *ctx, uint32_t domid,
+                          libxl_device_disk *disk,
+                          const libxl_asyncop_how *ao_how)
 {
-    GC_INIT(ctx);
+    AO_CREATE(ctx, domid, ao_how);
    flexarray_t *front;
    flexarray_t *back;
    char *dev;
@@ -1330,7 +1336,7 @@ int libxl_device_disk_add(libxl_ctx *ctx, uint32_t domid, libxl_device_disk *dis
        rc = ERROR_NOMEM;
        goto out;
    }
-    back = flexarray_make(16, 1);
+    back = flexarray_make(20, 1);
    if (!back) {
        rc = ERROR_NOMEM;
        goto out_free;
@@ -1361,6 +1367,11 @@ int libxl_device_disk_add(libxl_ctx *ctx, uint32_t domid, libxl_device_disk *dis
            flexarray_append(back, "params");
            flexarray_append(back, dev);
 
+            flexarray_append(back, "script");
+            flexarray_append(back, libxl__sprintf(gc, "%s/%s",
+                                                  libxl_xen_script_dir_path(),
+                                                  "block"));
+
            assert(device.backend_kind == LIBXL__DEVICE_KIND_VBD);
            break;
        case LIBXL_DISK_BACKEND_TAP:
@@ -1374,6 +1385,11 @@ int libxl_device_disk_add(libxl_ctx *ctx, uint32_t domid, libxl_device_disk *dis
                libxl__device_disk_string_of_format(disk->format),
                disk->pdev_path));
 
+            flexarray_append(back, "script");
+            flexarray_append(back, libxl__sprintf(gc, "%s/%s",
+                             libxl_xen_script_dir_path(),
+                             "blktap"));
+
            /* now create a phy device to export the device to the guest */
            goto do_backend_phy;
        case LIBXL_DISK_BACKEND_QDISK:
@@ -1406,6 +1422,9 @@ int libxl_device_disk_add(libxl_ctx *ctx, uint32_t domid, libxl_device_disk *dis
    flexarray_append(back, disk->readwrite ? "w" : "r");
    flexarray_append(back, "device-type");
    flexarray_append(back, disk->is_cdrom ? "cdrom" : "disk");
+    /* compatibility addon to keep udev rules */
+    flexarray_append(back, "execute_udev");
+    flexarray_append(back, "n");
 
    flexarray_append(front, "backend-id");
    flexarray_append(front, libxl__sprintf(gc, "%d", disk->backend_domid));
@@ -1420,14 +1439,23 @@ int libxl_device_disk_add(libxl_ctx *ctx, uint32_t domid, libxl_device_disk *dis
                             libxl__xs_kvs_of_flexarray(gc, back, back->count),
                             libxl__xs_kvs_of_flexarray(gc, front, front->count));
 
Quoted 12 lines

tools/libxl/libxl.c int libxl_device_disk_add(libxl_ctx *ctx, uint32_t domid, libxl_device_disk *dis · line 1449

Quoted 8 lines
tools/libxl/libxl.c +8 -0
+    if (disk->backend == LIBXL_DISK_BACKEND_PHY ||
+        disk->backend == LIBXL_DISK_BACKEND_TAP) {
+        rc = libxl__initiate_device_add(egc, ao, &device);
+        if (rc) goto out_free;
+    } else {
+        /* no need to execute hotplug scripts */
+        libxl__ao_complete(egc, ao, 0);
+    }

This would be better as a switch, since it would make it more obvious that the "else" is actually "case LIBXL_DISK_BACKEND_QDISK" etc.

Yes

Quoted 10 lines

[...]

tools/libxl/libxl.c

Quoted 5 lines
tools/libxl/libxl.c +5 -0
+
+/*
+ * Return codes:
+ * 1 Success and event(s) HAVE BEEN added
+ * 0 Success and NO events where added

were

(I saw a few of these)

Will do a grep to see what I can find…

Thanks for the review.

Quoted 14 lines
Quoted 11 lines

+ * < 0 Error
+ *
+ * Since this function can be called several times, and several events
+ * can be added to the same context, the user has to call
+ * libxl__ao_complete when necessary (if no events are added).
+ */
int libxl__initiate_device_remove(libxl__egc *egc, libxl__ao *ao,
libxl__device *dev)
{

tools/libxl/libxl.c +0 -0
@@ -392,7 +461,6 @@ int libxl__initiate_device_remove(libxl__egc *egc, libxl__ao *ao,

[...]

#5 lore raw

Re: [PATCH 2/5] libxl: call hotplug scripts from libxl for vbd

Quoted 17 lines · Roger Pau Monne
Quoted 10 lines · Ian Campbell

tools/hotplug/Linux/xen-hotplug-common.sh line 23

Quoted 4 lines
tools/hotplug/Linux/xen-hotplug-common.sh +4 -0
+execute_udev=`xenstore-read $XENBUS_PATH/execute_udev 2>/dev/null`
+if [ -n "$execute_udev" ] && [ -z "$XL_CALL" ]; then
+    exit 0
+fi

So, am I right that in some future world where we have got rid of xend and made this stuff work without udev everywhere (e.g. including driver domains) there is a path to deprecating this snippet without requiring everyone to go through some sort of transition?

Quoted 4 lines

Or are we stuck with this envvar forever? It's not a big deal but if we can invert it (e.g. by setting ENV{HOTPLUG_GATE}=${XENBUS}/evecute_udev in xen-backend.rules and ...if -n "${HOTPLUG_GATE}" && xenstore-read ${HOTPLUG_GATE}... etc) then that would be nicer?

Quoted 4 lines

I will change it to something like:

if [ -z "${HOTPLUG_GATE}" ] && `xenstore-read "$HOTPLUG_GATE" 2>/dev/null` && \
   [ -z "$XL_CALL" ]; then

Do you still need $XL_CALL?

Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#6 lore raw

Re: [PATCH 2/5] libxl: call hotplug scripts from libxl for vbd

Quoted 18 lines · Roger Pau Monne
Quoted 17 lines · Roger Pau Monne
Quoted 14 lines · Ian Campbell

tools/hotplug/Linux/xen-hotplug-common.sh line 23

Quoted 4 lines
tools/hotplug/Linux/xen-hotplug-common.sh +4 -0
+execute_udev=`xenstore-read $XENBUS_PATH/execute_udev 2>/dev/null`
+if [ -n "$execute_udev" ] && [ -z "$XL_CALL" ]; then
+    exit 0
+fi

So, am I right that in some future world where we have got rid of xend and made this stuff work without udev everywhere (e.g. including driver domains) there is a path to deprecating this snippet without requiring everyone to go through some sort of transition?

Or are we stuck with this envvar forever? It's not a big deal but if we can invert it (e.g. by setting ENV{HOTPLUG_GATE}=${XENBUS}/evecute_udev in xen-backend.rules and ...if -n "${HOTPLUG_GATE}" && xenstore-read ${HOTPLUG_GATE}... etc) then that would be nicer?

Quoted 6 lines
Quoted 4 lines

I will change it to something like:

if [ -z "${HOTPLUG_GATE}" ] && xenstore-read "$HOTPLUG_GATE" 2>/dev/null && \
[ -z "$XL_CALL" ]; then

Do you still need $XL_CALL?

No, with HOTPLUG_GATE it's enough, thanks again.

Quoted 5 lines

Ian.

#7 lore raw

PATCH 3/5 libxl: call hotplug scripts from libxl for vif

In reply to Roger Pau Monne

As the previous change already introduces most of needed machinery to call hotplug scripts from libxl, this only adds the necessary bits to call this scripts for vif interfaces also.

libxl_device_nic_add has been changed to make use of the new event functionality, and the necessary vif hotplug code has been added. No changes where needed in the teardown part, since it uses exactly the same code introduced for vbd.

An exception has been introduced for tap devices, since hotplug scripts should be called after the device model has been created, so the hotplug call for those is done in do_domain_create after confirmation of the device model startup. On the other hand, tap devices don't use teardown scripts, so add another exception for that.

libxl__device_from_nic was moved to libxl_device.c, so it can be used in libxl_create.c, and libxl__device_from_disk was also moved to mantain the simmetry.

libxl__initiate_device_remove has been changed a little, to nuke the frontend xenstore path before trying to perform device teardown, this allows for unitialized devices to be closed gracefully, specially vif interfaces added to HVM machines and not used.

PV nic devices are set to LIBXL_NIC_TYPE_VIF, since the default value is LIBXL_NIC_TYPE_IOEMU regardless of the guest type.

A new gobal option, called disable_vif_scripts has been added to allow the user decide if he wants to execute the hotplug scripts from xl or from udev. This has been documented in the xl.conf man page.

---
 docs/man/xl.conf.pod.5       |    7 ++
 tools/libxl/libxl.c          |   85 ++++++++------------------
 tools/libxl/libxl.h          |    3 +-
 tools/libxl/libxl_create.c   |   22 ++++++-
 tools/libxl/libxl_device.c   |   77 +++++++++++++++++++++--
 tools/libxl/libxl_dm.c       |    2 +-
 tools/libxl/libxl_internal.h |    6 ++
 tools/libxl/libxl_linux.c    |  138 +++++++++++++++++++++++++++++++++++++++++-
 tools/libxl/libxl_types.idl  |    1 +
 tools/libxl/xl.c             |    4 +
 tools/libxl/xl.h             |    1 +
 tools/libxl/xl_cmdimpl.c     |   15 ++++-
 12 files changed, 289 insertions(+), 72 deletions(-)
docs/man/xl.conf.pod.5 +7 -0
index 8bd45ea..cf2c477 100644
@@ -55,6 +55,13 @@ default.
 
 Default: C<1>
 
+=item B<disable_vif_scripts=BOOLEAN>
+
+If enabled xl will not execute nic hotplug scripts itself, and instead
+relegate this task to udev.
+
+Default: C<0>
+
 =item B<lockfile="PATH">
 
 Sets the path to the lock file used by xl to serialise certain
tools/libxl/libxl.c +25 -60

121 lines not on this page · raw message

tools/libxl/libxl.h +2 -1
index b7347be..6da6107 100644
@@ -551,7 +551,8 @@ char * libxl_device_disk_local_attach(libxl_ctx *ctx, libxl_device_disk *disk);
 int libxl_device_disk_local_detach(libxl_ctx *ctx, libxl_device_disk *disk);
 
 /* Network Interfaces */
-int libxl_device_nic_add(libxl_ctx *ctx, uint32_t domid, libxl_device_nic *nic);
+int libxl_device_nic_add(libxl_ctx *ctx, uint32_t domid, libxl_device_nic *nic,
+                         const libxl_asyncop_how *ao_how);
 int libxl_device_nic_remove(libxl_ctx *ctx, uint32_t domid,
                             libxl_device_nic *nic,
                             const libxl_asyncop_how *ao_how);
tools/libxl/libxl_create.c +21 -1
index de598ad..a1f5731 100644
@@ -607,7 +607,7 @@ static int do_domain_create(libxl__gc *gc, libxl_domain_config *d_config,
         }
     }
     for (i = 0; i < d_config->num_vifs; i++) {
-        ret = libxl_device_nic_add(ctx, domid, &d_config->vifs[i]);
+        ret = libxl_device_nic_add(ctx, domid, &d_config->vifs[i], 0);
         if (ret) {
             LIBXL__LOG(ctx, LIBXL__LOG_ERROR,
                        "cannot add nic %d to domain: %d", i, ret);
@@ -685,6 +685,26 @@ static int do_domain_create(libxl__gc *gc, libxl_domain_config *d_config,
                        "device model did not start: %d", ret);
             goto error_out;
         }
+        /* 
+         * Execute hotplug scripts for tap devices, this has to be done
+         * after the domain model has been started.
+        */
+        for (i = 0; i < d_config->num_vifs; i++) {
+            if (d_config->vifs[i].nictype == LIBXL_NIC_TYPE_IOEMU &&
+                !d_config->vifs[i].disable_vif_script) {
+                libxl__device device;
+                ret = libxl__device_from_nic(gc, domid, &d_config->vifs[i],
+                                             &device);
+                if (ret < 0) goto error_out;
+                ret = libxl__device_hotplug(gc, &device, CONNECT);
+                if (ret < 0) {
+                    LIBXL__LOG(ctx, LIBXL__LOG_ERROR,
+                               "unable to launch hotplug script for device: "
+                               "%"PRIu32, device.devid);
+                    goto error_out;
+                }
+            }
+        }
     }
 
     for (i = 0; i < d_config->num_pcidevs; i++)
tools/libxl/libxl_device.c +70 -7

112 lines not on this page · raw message

tools/libxl/libxl_dm.c +1 -1
index 2d51a7f..ba5bef7 100644
@@ -795,7 +795,7 @@ retry_transaction:
             goto out_free;
     }
     for (i = 0; i < dm_config.num_vifs; i++) {
-        ret = libxl_device_nic_add(ctx, dm_domid, &dm_config.vifs[i]);
+        ret = libxl_device_nic_add(ctx, dm_domid, &dm_config.vifs[i], 0);
         if (ret)
             goto out_free;
     }
tools/libxl/libxl_internal.h +6 -0
index a39346c..3787217 100644
@@ -756,6 +756,12 @@ _hidden int libxl__domain_pvcontrol_write(libxl__gc *gc, xs_transaction_t t,
 _hidden char *libxl__device_disk_string_of_backend(libxl_disk_backend backend);
 _hidden char *libxl__device_disk_string_of_format(libxl_disk_format format);
 _hidden int libxl__device_disk_set_backend(libxl__gc*, libxl_device_disk*);
+_hidden int libxl__device_from_nic(libxl__gc *gc, uint32_t domid,
+                                   libxl_device_nic *nic,
+                                   libxl__device *device);
+_hidden int libxl__device_from_disk(libxl__gc *gc, uint32_t domid,
+                                    libxl_device_disk *disk,
+                                    libxl__device *device);
 
 _hidden int libxl__device_physdisk_major_minor(const char *physpath, int *major, int *minor);
 _hidden int libxl__device_disk_dev_number(const char *virtpath,
tools/libxl/libxl_linux.c +137 -1

168 lines not on this page · raw message

tools/libxl/libxl_types.idl +1 -0
index 09089b2..ac3e79f 100644
@@ -343,6 +343,7 @@ libxl_device_nic = Struct("device_nic", [
     ("ifname", string),
     ("script", string),
     ("nictype", libxl_nic_type),
+    ("disable_vif_script", integer),
     ])
 
 libxl_device_pci = Struct("device_pci", [
tools/libxl/xl.c +4 -0
index a6ffd25..2a705b8 100644
@@ -35,6 +35,7 @@
 xentoollog_logger_stdiostream *logger;
 int dryrun_only;
 int autoballoon = 1;
+int disable_vif_scripts = 0;
 char *lockfile;
 char *default_vifscript = NULL;
 char *default_bridge = NULL;
@@ -66,6 +67,9 @@ static void parse_global_config(const char *configfile,
     if (!xlu_cfg_get_long (config, "autoballoon", &l, 0))
         autoballoon = l;
 
+    if (!xlu_cfg_get_long (config, "disable_vif_scripts", &l, 0))
+        disable_vif_scripts = l;
+
     if (!xlu_cfg_get_string (config, "lockfile", &buf, 0))
         lockfile = strdup(buf);
     else {
tools/libxl/xl.h +1 -0
index 7e258d5..13619e7 100644
@@ -109,6 +109,7 @@ void postfork(void);
 
 /* global options */
 extern int autoballoon;
+extern int disable_vif_scripts;
 extern int dryrun_only;
 extern char *lockfile;
 extern char *default_vifscript;
tools/libxl/xl_cmdimpl.c +14 -1
index 01ff363..41230a6 100644
@@ -846,6 +846,19 @@ static void parse_config_data(const char *configfile_filename_report,
                 nic->script = strdup(default_vifscript);
             }
 
+            /* Set default nic type for PV guests correctly */
+            if (b_info->type == LIBXL_DOMAIN_TYPE_PV) {
+                nic->nictype = LIBXL_NIC_TYPE_VIF;
+            }
+
+            /*
+             * Disable nic network script calling, to allow the user
+             * to attach the nic backend from a different domain.
+             */
+            if (disable_vif_scripts) {
+                nic->disable_vif_script = 1;
+            }
+
 	    if (default_bridge) {
 		free(nic->bridge);
 		nic->bridge = strdup(default_bridge);
@@ -4901,7 +4914,7 @@ int main_networkattach(int argc, char **argv)
             return 1;
         }
     }
-    if (libxl_device_nic_add(ctx, domid, &nic)) {
+    if (libxl_device_nic_add(ctx, domid, &nic, 0)) {
         fprintf(stderr, "libxl_device_nic_add failed.\n");
         return 1;
     }
Signature · 1 line
1.7.7.5 (Apple Git-26)
#8 lore raw

PATCH 4/5 libxl: add "downscript=no" to Qemu call

In reply to Roger Pau Monne

Currently we only pass script=no to Qemu, to avoid calling any scripts when attaching a tap interface, but we should also pass downscript=no to avoid Qemu trying to execute a script when disconnecting the interface. This prevents the following harmless error message:

/etc/qemu-ifdown: could not launch network script

---
 tools/libxl/libxl_dm.c |   17 +++++++++++------
 1 files changed, 11 insertions(+), 6 deletions(-)
tools/libxl/libxl_dm.c +11 -6
index ba5bef7..8dc588d 100644
@@ -216,11 +216,14 @@ static char ** libxl__build_device_model_args_old(libxl__gc *gc,
                 else
                     ifname = vifs[i].ifname;
                 flexarray_vappend(dm_args,
-                                "-net", libxl__sprintf(gc, "nic,vlan=%d,macaddr=%s,model=%s",
-                                                       vifs[i].devid, smac, vifs[i].model),
-                                "-net", libxl__sprintf(gc, "tap,vlan=%d,ifname=%s,bridge=%s,script=%s",
-                                                       vifs[i].devid, ifname, vifs[i].bridge, libxl_tapif_script(gc)),
-                                NULL);
+                "-net", libxl__sprintf(gc, "nic,vlan=%d,macaddr=%s,model=%s",
+                                       vifs[i].devid, smac, vifs[i].model),
+                "-net", libxl__sprintf(gc,
+                               "tap,vlan=%d,ifname=%s,bridge=%s,script=%s,"
+                               "downscript=%s",
+                               vifs[i].devid, ifname, vifs[i].bridge,
+                               libxl_tapif_script(gc), libxl_tapif_script(gc)),
+                               NULL);
                 ioemu_vifs++;
             }
         }
@@ -462,8 +465,10 @@ static char ** libxl__build_device_model_args_new(libxl__gc *gc,
                                                 vifs[i].devid, smac));
                 flexarray_append(dm_args, "-netdev");
                 flexarray_append(dm_args,
-                   libxl__sprintf(gc, "type=tap,id=net%d,ifname=%s,script=%s",
+                   libxl__sprintf(gc, "type=tap,id=net%d,ifname=%s,script=%s,"
+                                      "downscript=%s",
                                                 vifs[i].devid, ifname,
+                                                libxl_tapif_script(gc),
                                                 libxl_tapif_script(gc)));
                 ioemu_vifs++;
             }
Signature · 1 line
1.7.7.5 (Apple Git-26)
Acked-by on v1 4/5
#9 lore raw

Re: [PATCH 4/5] libxl: add "downscript=no" to Qemu call

Quoted 23 lines · Roger Pau Monne

Currently we only pass script=no to Qemu, to avoid calling any scripts when attaching a tap interface, but we should also pass downscript=no to avoid Qemu trying to execute a script when disconnecting the interface. This prevents the following harmless error message:

/etc/qemu-ifdown: could not launch network script

---
 tools/libxl/libxl_dm.c |   17 +++++++++++------
 1 files changed, 11 insertions(+), 6 deletions(-)
tools/libxl/libxl_dm.c +0 -3
index ba5bef7..8dc588d 100644
@@ -216,11 +216,14 @@ static char ** libxl__build_device_model_args_old(libxl__gc *gc,
                 else
                     ifname = vifs[i].ifname;
                 flexarray_vappend(dm_args,
-                                "-net", libxl__sprintf(gc, "nic,vlan=%d,macaddr=%s,model=%s",
-                                                       vifs[i].devid, smac, vifs[i].model),
-                                "-net", libxl__sprintf(gc, "tap,vlan=%d,ifname=%s,bridge=%s,script=%s",

tools/libxl/libxl_dm.c static char ** libxl__build_device_model_args_old(libxl__gc *gc, · line 226

Quoted 10 lines
tools/libxl/libxl_dm.c +8 -2
-                                                       vifs[i].devid, ifname, vifs[i].bridge, libxl_tapif_script(gc)),
-                                NULL);
+                "-net", libxl__sprintf(gc, "nic,vlan=%d,macaddr=%s,model=%s",
+                                       vifs[i].devid, smac, vifs[i].model),
+                "-net", libxl__sprintf(gc,
+                               "tap,vlan=%d,ifname=%s,bridge=%s,script=%s,"
+                               "downscript=%s",
+                               vifs[i].devid, ifname, vifs[i].bridge,
+                               libxl_tapif_script(gc), libxl_tapif_script(gc)),
+                               NULL);

I think these should be indented at least a little bit wrt the flexarray_vappend. Since you've already split the string you might just need to re-wrap a bit to fit in 80 chars (which I guess is why you changed this)

tools/libxl/libxl_dm.c static char ** libxl__build_device_model_args_new(libxl__gc *gc, · line 472

Quoted 13 lines
tools/libxl/libxl_dm.c +3 -1
                 ioemu_vifs++;
             }
         }
@@ -462,8 +465,10 @@ static char ** libxl__build_device_model_args_new(libxl__gc *gc,
                                                 vifs[i].devid, smac));
                 flexarray_append(dm_args, "-netdev");
                 flexarray_append(dm_args,
-                   libxl__sprintf(gc, "type=tap,id=net%d,ifname=%s,script=%s",
+                   libxl__sprintf(gc, "type=tap,id=net%d,ifname=%s,script=%s,"
+                                      "downscript=%s",
                                                 vifs[i].devid, ifname,
+                                                libxl_tapif_script(gc),
                                                 libxl_tapif_script(gc)));

The indentation here is now inconsistent.

Other than the whitepace issues:

Quoted 2 lines
tools/libxl/libxl_dm.c +0 -0
                 ioemu_vifs++;
             }
#10 lore raw

PATCH 5/5 libxl: clean xenstore console directories recursively on destroy

In reply to Roger Pau Monne

Clean xenstore, to prevent leaving empty directories in the tree, like:

/local/domain/0/backend/console = "" (n0)
/local/domain/0/backend/console/3 = "" (n0)

That was left after a guest was destroyed.

---
 tools/libxl/libxl_device.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)
tools/libxl/libxl_device.c +2 -3
index d773d71..4161d1bd 100644
@@ -609,12 +609,11 @@ out_ok:
 
 int libxl__device_destroy(libxl__gc *gc, libxl__device *dev)
 {
-    libxl_ctx *ctx = libxl__gc_owner(gc);
     char *be_path = libxl__device_backend_path(gc, dev);
     char *fe_path = libxl__device_frontend_path(gc, dev);
 
-    xs_rm(ctx->xsh, XBT_NULL, be_path);
-    xs_rm(ctx->xsh, XBT_NULL, fe_path);
+    libxl__xs_path_cleanup(gc, fe_path);
+    libxl__xs_path_cleanup(gc, be_path);
 
     libxl__device_destroy_tapdisk(gc, be_path);
 
Signature · 1 line
1.7.7.5 (Apple Git-26)
#11 lore raw

Re: [PATCH 5/5] libxl: clean xenstore console directories recursively on destroy

Quoted 18 lines · Roger Pau Monne

Clean xenstore, to prevent leaving empty directories in the tree, like:

/local/domain/0/backend/console = "" (n0)
/local/domain/0/backend/console/3 = "" (n0)

That was left after a guest was destroyed.

---
 tools/libxl/libxl_device.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)
tools/libxl/libxl_device.c +0 -0
index d773d71..4161d1bd 100644
@@ -609,12 +609,11 @@ out_ok:
 

tools/libxl/libxl_device.c out_ok: · line 616

Quoted 10 lines
tools/libxl/libxl_device.c +2 -3
 int libxl__device_destroy(libxl__gc *gc, libxl__device *dev)
 {
-    libxl_ctx *ctx = libxl__gc_owner(gc);
     char *be_path = libxl__device_backend_path(gc, dev);
     char *fe_path = libxl__device_frontend_path(gc, dev);
 
-    xs_rm(ctx->xsh, XBT_NULL, be_path);
-    xs_rm(ctx->xsh, XBT_NULL, fe_path);
+    libxl__xs_path_cleanup(gc, fe_path);
+    libxl__xs_path_cleanup(gc, be_path);

is xs_rm not recursive? At least from the CLI it seems to be

quartz:~# xenstore-write /foo/bar/baz 123
quartz:~# xenstore-ls -f | grep foo
/foo = ""
/foo/bar = ""
/foo/bar/baz = "123"
quartz:~# xenstore-rm  /foo
quartz:~# xenstore-ls -f | grep foo
quartz:~# 

looking at xenstore_client.c it seems to only call xs_rm() and not do any traversal itself?

Quoted 3 lines
tools/libxl/libxl_device.c +0 -0
     libxl__device_destroy_tapdisk(gc, be_path);
 
#12 lore raw

Re: [PATCH 5/5] libxl: clean xenstore console directories recursively on destroy

Quoted 41 lines · Ian Campbell
Quoted 18 lines · Roger Pau Monne

Clean xenstore, to prevent leaving empty directories in the tree, like:

/local/domain/0/backend/console = "" (n0)
/local/domain/0/backend/console/3 = "" (n0)

That was left after a guest was destroyed.

---
tools/libxl/libxl_device.c | 5 ++---

1 files changed, 2 insertions(+), 3 deletions(-)
tools/libxl/libxl_device.c +0 -0
index d773d71..4161d1bd 100644
@@ -609,12 +609,11 @@ out_ok:
 

tools/libxl/libxl_device.c out_ok: · line 616

Quoted 10 lines
tools/libxl/libxl_device.c +2 -3
 int libxl__device_destroy(libxl__gc *gc, libxl__device *dev)
 {
-    libxl_ctx *ctx = libxl__gc_owner(gc);
    char *be_path = libxl__device_backend_path(gc, dev);
    char *fe_path = libxl__device_frontend_path(gc, dev);
 
-    xs_rm(ctx->xsh, XBT_NULL, be_path);
-    xs_rm(ctx->xsh, XBT_NULL, fe_path);
+    libxl__xs_path_cleanup(gc, fe_path);
+    libxl__xs_path_cleanup(gc, be_path);

is xs_rm not recursive? At least from the CLI it seems to be

quartz:~# xenstore-write /foo/bar/baz 123
quartz:~# xenstore-ls -f | grep foo
/foo = ""
/foo/bar = ""
/foo/bar/baz = "123"
quartz:~# xenstore-rm  /foo
quartz:~# xenstore-ls -f | grep foo
quartz:~# 
Quoted 2 lines

looking at xenstore_client.c it seems to only call xs_rm() and not do any traversal itself?

Sure! I had an error probably somewhere else in the code, and changing libxl__xs_path_cleanup to xs_rm didn't make it happen again, so forget about this. I will send an updated version of the series without this stuff (and the appropriate changes).

Quoted 6 lines
Quoted 4 lines
tools/libxl/libxl_device.c +0 -0
    libxl__device_destroy_tapdisk(gc, be_path);
 
#13 lore raw

Re: [PATCH 5/5] libxl: clean xenstore console directories recursively on destroy

In reply to Ian Campbell
Quoted 25 lines · Ian Campbell
Quoted 24 lines · Roger Pau Monne

Clean xenstore, to prevent leaving empty directories in the tree, like:

/local/domain/0/backend/console = "" (n0)
/local/domain/0/backend/console/3 = "" (n0)

That was left after a guest was destroyed.

---
tools/libxl/libxl_device.c | 5 ++---

1 files changed, 2 insertions(+), 3 deletions(-)
tools/libxl/libxl_device.c +0 -1
index d773d71..4161d1bd 100644
@@ -609,12 +609,11 @@ out_ok:
 
 int libxl__device_destroy(libxl__gc *gc, libxl__device *dev)
 {
-    libxl_ctx *ctx = libxl__gc_owner(gc);
    char *be_path = libxl__device_backend_path(gc, dev);
    char *fe_path = libxl__device_frontend_path(gc, dev);
 
Quoted 6 lines

tools/libxl/libxl_device.c out_ok: · line 616

Quoted 4 lines
tools/libxl/libxl_device.c +2 -2
-    xs_rm(ctx->xsh, XBT_NULL, be_path);
-    xs_rm(ctx->xsh, XBT_NULL, fe_path);
+    libxl__xs_path_cleanup(gc, fe_path);
+    libxl__xs_path_cleanup(gc, be_path);

is xs_rm not recursive? At least from the CLI it seems to be

Ok, I got messed up here, what my function did was purge a directory tree from top to bottom, so using your example, doing a:

libxl__xs_path_cleanup(gc, "/foo/bar/baz");

Would have erased /foo/bar/baz, /foo/bar and /foo, because they where all empty (had no more files or subfolders inside) after deleting "baz".

So I guess this is really needed.

Quoted 18 lines
quartz:~# xenstore-write /foo/bar/baz 123
quartz:~# xenstore-ls -f | grep foo
/foo = ""
/foo/bar = ""
/foo/bar/baz = "123"
quartz:~# xenstore-rm  /foo
quartz:~# xenstore-ls -f | grep foo
quartz:~# 

looking at xenstore_client.c it seems to only call xs_rm() and not do any traversal itself?

Quoted 3 lines
tools/libxl/libxl_device.c +0 -0
    libxl__device_destroy_tapdisk(gc, be_path);
 
#14 lore raw

Re: [PATCH 5/5] libxl: clean xenstore console directories recursively on destroy

Quoted 33 lines · Roger Pau Monne
Quoted 25 lines · Ian Campbell
Quoted 24 lines · Roger Pau Monne

Clean xenstore, to prevent leaving empty directories in the tree, like:

/local/domain/0/backend/console = "" (n0)
/local/domain/0/backend/console/3 = "" (n0)

That was left after a guest was destroyed.

---
tools/libxl/libxl_device.c | 5 ++---

1 files changed, 2 insertions(+), 3 deletions(-)
tools/libxl/libxl_device.c +0 -1
index d773d71..4161d1bd 100644
@@ -609,12 +609,11 @@ out_ok:
 
 int libxl__device_destroy(libxl__gc *gc, libxl__device *dev)
 {
-    libxl_ctx *ctx = libxl__gc_owner(gc);
    char *be_path = libxl__device_backend_path(gc, dev);
    char *fe_path = libxl__device_frontend_path(gc, dev);
 
Quoted 6 lines

tools/libxl/libxl_device.c out_ok: · line 616

Quoted 4 lines
tools/libxl/libxl_device.c +2 -2
-    xs_rm(ctx->xsh, XBT_NULL, be_path);
-    xs_rm(ctx->xsh, XBT_NULL, fe_path);
+    libxl__xs_path_cleanup(gc, fe_path);
+    libxl__xs_path_cleanup(gc, be_path);

is xs_rm not recursive? At least from the CLI it seems to be

Quoted 8 lines

Ok, I got messed up here, what my function did was purge a directory tree from top to bottom, so using your example, doing a:

libxl__xs_path_cleanup(gc, "/foo/bar/baz");

Would have erased /foo/bar/baz, /foo/bar and /foo, because they where all empty (had no more files or subfolders inside) after deleting "baz".

IFF they are empty? So the presence of /foo/bob would have made only /foo/bar/baz and /foo/bar but not /foo get deleted?

IOW it behaves like "xenstore-rm -t" (t for tidy)?

Quoted 23 lines

So I guess this is really needed.

Quoted 18 lines
quartz:~# xenstore-write /foo/bar/baz 123
quartz:~# xenstore-ls -f | grep foo
/foo = ""
/foo/bar = ""
/foo/bar/baz = "123"
quartz:~# xenstore-rm  /foo
quartz:~# xenstore-ls -f | grep foo
quartz:~# 

looking at xenstore_client.c it seems to only call xs_rm() and not do any traversal itself?

Quoted 3 lines
tools/libxl/libxl_device.c +0 -0
    libxl__device_destroy_tapdisk(gc, be_path);
 

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#15 lore raw

Re: [PATCH 5/5] libxl: clean xenstore console directories recursively on destroy

Quoted 37 lines · Roger Pau Monne
Quoted 36 lines · Roger Pau Monne
Quoted 25 lines · Ian Campbell
Quoted 24 lines · Roger Pau Monne

Clean xenstore, to prevent leaving empty directories in the tree, like:

/local/domain/0/backend/console = "" (n0)
/local/domain/0/backend/console/3 = "" (n0)

That was left after a guest was destroyed.

---
tools/libxl/libxl_device.c | 5 ++---

1 files changed, 2 insertions(+), 3 deletions(-)
tools/libxl/libxl_device.c +0 -1
index d773d71..4161d1bd 100644
@@ -609,12 +609,11 @@ out_ok:
 
 int libxl__device_destroy(libxl__gc *gc, libxl__device *dev)
 {
-    libxl_ctx *ctx = libxl__gc_owner(gc);
   char *be_path = libxl__device_backend_path(gc, dev);
   char *fe_path = libxl__device_frontend_path(gc, dev);
 
Quoted 6 lines

tools/libxl/libxl_device.c out_ok: · line 616

Quoted 4 lines
tools/libxl/libxl_device.c +2 -2
-    xs_rm(ctx->xsh, XBT_NULL, be_path);
-    xs_rm(ctx->xsh, XBT_NULL, fe_path);
+    libxl__xs_path_cleanup(gc, fe_path);
+    libxl__xs_path_cleanup(gc, be_path);

is xs_rm not recursive? At least from the CLI it seems to be

Ok, I got messed up here, what my function did was purge a directory tree from top to bottom, so using your example, doing a:

Quoted 8 lines
Quoted 5 lines

libxl__xs_path_cleanup(gc, "/foo/bar/baz");

Would have erased /foo/bar/baz, /foo/bar and /foo, because they where all empty (had no more files or subfolders inside) after deleting "baz".

IFF they are empty? So the presence of /foo/bob would have made only /foo/bar/baz and /foo/bar but not /foo get deleted?

Yes, if there's a /foo/bob that would prevent the deletion of /foo.

Quoted 31 lines

IOW it behaves like "xenstore-rm -t" (t for tidy)?

From what I saw, yes (although I didn't even know of "xenstore-rm -t").

Quoted 23 lines

So I guess this is really needed.

Quoted 18 lines
quartz:~# xenstore-write /foo/bar/baz 123
quartz:~# xenstore-ls -f | grep foo
/foo = ""
/foo/bar = ""
/foo/bar/baz = "123"
quartz:~# xenstore-rm  /foo
quartz:~# xenstore-ls -f | grep foo
quartz:~# 

looking at xenstore_client.c it seems to only call xs_rm() and not do any traversal itself?

Quoted 3 lines
tools/libxl/libxl_device.c +0 -0
   libxl__device_destroy_tapdisk(gc, be_path);
 
#16 lore raw

Re: [PATCH 5/5] libxl: clean xenstore console directories recursively on destroy

Quoted 48 lines · Roger Pau Monne
Quoted 37 lines · Roger Pau Monne
Quoted 36 lines · Roger Pau Monne
Quoted 25 lines · Ian Campbell
Quoted 24 lines · Roger Pau Monne

Clean xenstore, to prevent leaving empty directories in the tree, like:

/local/domain/0/backend/console = "" (n0)
/local/domain/0/backend/console/3 = "" (n0)

That was left after a guest was destroyed.

---
tools/libxl/libxl_device.c | 5 ++---

1 files changed, 2 insertions(+), 3 deletions(-)
tools/libxl/libxl_device.c +0 -1
index d773d71..4161d1bd 100644
@@ -609,12 +609,11 @@ out_ok:
 
 int libxl__device_destroy(libxl__gc *gc, libxl__device *dev)
 {
-    libxl_ctx *ctx = libxl__gc_owner(gc);
   char *be_path = libxl__device_backend_path(gc, dev);
   char *fe_path = libxl__device_frontend_path(gc, dev);
 
Quoted 6 lines

tools/libxl/libxl_device.c out_ok: · line 616

Quoted 4 lines
tools/libxl/libxl_device.c +2 -2
-    xs_rm(ctx->xsh, XBT_NULL, be_path);
-    xs_rm(ctx->xsh, XBT_NULL, fe_path);
+    libxl__xs_path_cleanup(gc, fe_path);
+    libxl__xs_path_cleanup(gc, be_path);

is xs_rm not recursive? At least from the CLI it seems to be

Ok, I got messed up here, what my function did was purge a directory tree from top to bottom, so using your example, doing a:

Quoted 8 lines
Quoted 5 lines

libxl__xs_path_cleanup(gc, "/foo/bar/baz");

Would have erased /foo/bar/baz, /foo/bar and /foo, because they where all empty (had no more files or subfolders inside) after deleting "baz".

IFF they are empty? So the presence of /foo/bob would have made only /foo/bar/baz and /foo/bar but not /foo get deleted?

Quoted 5 lines

Yes, if there's a /foo/bob that would prevent the deletion of /foo.

Quoted 2 lines

IOW it behaves like "xenstore-rm -t" (t for tidy)?

From what I saw, yes (although I didn't even know of "xenstore-rm -t").

Me neither till I looked at xenstore_client.c to see how my experiments related to xs_rm...

Quoted 30 lines
Quoted 19 lines
Quoted 19 lines

So I guess this is really needed.

Quoted 14 lines
quartz:~# xenstore-write /foo/bar/baz 123
quartz:~# xenstore-ls -f | grep foo
/foo = ""
/foo/bar = ""
/foo/bar/baz = "123"
quartz:~# xenstore-rm  /foo
quartz:~# xenstore-ls -f | grep foo
quartz:~# 

looking at xenstore_client.c it seems to only call xs_rm() and not do any traversal itself?

Quoted 1 line
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
   libxl__device_destroy_tapdisk(gc, be_path);
Quoted 4 lines

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#17 lore raw

Re: [PATCH 5/5] libxl: clean xenstore console directories recursively on destroy

Quoted 3 lines · Ian Campbell

On Tue, 2012-04-17 at 15:32 +0100, Roger Pau Monne wrote:
Me neither till I looked at xenstore_client.c to see how my experiments related to xs_rm…

I've looked at the code, but I prefer mine, since it makes use of the handy libxl__xs_directory libxl function (and I think is cleaner to use a for loop than the goto that's used on xenstore_client.c). I've added it again to the series, and I'm going to resend it with the necessary fixes.