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

[Xen-devel] [PATCH v3 1/7] libxl: group hotplug related variables



Create a new struct to hold hotplug related variables that are
scattered in libxl__ao_device. We will later expand the number of
hotplug related variables, so it's best to have them grouped.

Signed-off-by: Roger Pau Monnà <roger.pau@xxxxxxxxxx>
Acked-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
Cc: Ian Campbell <ian.campbell@xxxxxxxxxx>
---
Changes since v1:
 * s/packed/grouped in commit message
---
 tools/libxl/libxl_device.c   |    6 +++---
 tools/libxl/libxl_internal.h |   15 ++++++++++-----
 tools/libxl/libxl_linux.c    |   10 +++++-----
 tools/libxl/libxl_netbsd.c   |    4 ++--
 4 files changed, 20 insertions(+), 15 deletions(-)

diff --git a/tools/libxl/libxl_device.c b/tools/libxl/libxl_device.c
index eeea9d9..044cac5 100644
--- a/tools/libxl/libxl_device.c
+++ b/tools/libxl/libxl_device.c
@@ -409,7 +409,7 @@ void libxl__prepare_ao_device(libxl__ao *ao, 
libxl__ao_device *aodev)
     aodev->ao = ao;
     aodev->rc = 0;
     aodev->dev = NULL;
-    aodev->num_exec = 0;
+    aodev->hotplug.num_exec = 0;
     /* Initialize timer for QEMU Bodge and hotplug execution */
     libxl__ev_time_init(&aodev->timeout);
     aodev->active = 1;
@@ -892,7 +892,7 @@ static void device_hotplug(libxl__egc *egc, 
libxl__ao_device *aodev)
      * and return the necessary args/env vars for execution */
     hotplug = libxl__get_hotplug_script_info(gc, aodev->dev, &args, &env,
                                              aodev->action,
-                                             aodev->num_exec);
+                                             &aodev->hotplug);
     switch (hotplug) {
     case 0:
         /* no hotplug script to execute */
@@ -994,7 +994,7 @@ static void device_hotplug_child_death_cb(libxl__egc *egc,
      * If no more executions are needed, device_hotplug will call
      * device_hotplug_done breaking the loop.
      */
-    aodev->num_exec++;
+    aodev->hotplug.num_exec++;
     device_hotplug(egc, aodev);
 
     return;
diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
index 3ba3a21..8507ac3 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -1838,6 +1838,7 @@ _hidden const char *libxl__run_dir_path(void);
 
 typedef struct libxl__ao_device libxl__ao_device;
 typedef struct libxl__multidev libxl__multidev;
+typedef struct libxl__hotplug libxl__hotplug;
 typedef void libxl__device_callback(libxl__egc*, libxl__ao_device*);
 
 /* This functions sets the necessary libxl__ao_device struct values to use
@@ -1856,6 +1857,10 @@ typedef void libxl__device_callback(libxl__egc*, 
libxl__ao_device*);
  */
 _hidden void libxl__prepare_ao_device(libxl__ao *ao, libxl__ao_device *aodev);
 
+struct libxl__hotplug {
+    int num_exec;
+};
+
 struct libxl__ao_device {
     /* filled in by user */
     libxl__ao *ao;
@@ -1874,7 +1879,7 @@ struct libxl__ao_device {
     libxl__ev_time timeout;
     /* device hotplug execution */
     const char *what;
-    int num_exec;
+    libxl__hotplug hotplug;
     libxl__ev_child child;
 };
 
@@ -2055,18 +2060,18 @@ _hidden void libxl__initiate_device_remove(libxl__egc 
*egc,
  * 0: No need to execute hotplug script
  * 1: Execute hotplug script
  *
- * The last parameter, "num_exec" refeers to the number of times hotplug
- * scripts have been called for this device.
+ * The last parameter, libxl__hotplug contains information related to hotplug
+ * execution.
  *
  * The main body of libxl will, for each device, keep calling
  * libxl__get_hotplug_script_info, with incrementing values of
- * num_exec, and executing the resulting script accordingly,
+ * hotplug->num_exec, and executing the resulting script accordingly,
  * until libxl__get_hotplug_script_info returns<=0.
  */
 _hidden int libxl__get_hotplug_script_info(libxl__gc *gc, libxl__device *dev,
                                            char ***args, char ***env,
                                            libxl__device_action action,
-                                           int num_exec);
+                                           libxl__hotplug *hotplug);
 
 /*----- local disk attach: attach a disk locally to run the bootloader -----*/
 
diff --git a/tools/libxl/libxl_linux.c b/tools/libxl/libxl_linux.c
index 37815eb..be76045 100644
--- a/tools/libxl/libxl_linux.c
+++ b/tools/libxl/libxl_linux.c
@@ -234,7 +234,7 @@ error:
 int libxl__get_hotplug_script_info(libxl__gc *gc, libxl__device *dev,
                                    char ***args, char ***env,
                                    libxl__device_action action,
-                                   int num_exec)
+                                   libxl__hotplug *hotplug)
 {
     char *disable_udev = libxl__xs_read(gc, XBT_NULL, DISABLE_UDEV_PATH);
     int rc;
@@ -247,7 +247,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) {
+        if (hotplug->num_exec != 0) {
             rc = 0;
             goto out;
         }
@@ -258,12 +258,12 @@ int libxl__get_hotplug_script_info(libxl__gc *gc, 
libxl__device *dev,
          * If domain has a stubdom we don't have to execute hotplug scripts
          * for emulated interfaces
          */
-        if ((num_exec > 1) ||
-            (libxl_get_stubdom_id(CTX, dev->domid) && num_exec)) {
+        if ((hotplug->num_exec > 1) ||
+            (libxl_get_stubdom_id(CTX, dev->domid) && hotplug->num_exec)) {
             rc = 0;
             goto out;
         }
-        rc = libxl__hotplug_nic(gc, dev, args, env, action, num_exec);
+        rc = libxl__hotplug_nic(gc, dev, args, env, action, hotplug->num_exec);
         break;
     default:
         /* No need to execute any hotplug scripts */
diff --git a/tools/libxl/libxl_netbsd.c b/tools/libxl/libxl_netbsd.c
index 898e160..48c87eb 100644
--- a/tools/libxl/libxl_netbsd.c
+++ b/tools/libxl/libxl_netbsd.c
@@ -62,13 +62,13 @@ out:
 int libxl__get_hotplug_script_info(libxl__gc *gc, libxl__device *dev,
                                    char ***args, char ***env,
                                    libxl__device_action action,
-                                   int num_exec)
+                                   libxl__hotplug *hotplug)
 {
     char *disable_udev = libxl__xs_read(gc, XBT_NULL, DISABLE_UDEV_PATH);
     int rc;
 
     /* Check if we have to run hotplug scripts */
-    if (!disable_udev || num_exec > 0) {
+    if (!disable_udev || hotplug->num_exec > 0) {
         rc = 0;
         goto out;
     }
-- 
1.7.7.5 (Apple Git-26)


_______________________________________________
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®.