xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Roger Pau Monne <roger.pau@citrix.com>
To: xen-devel@lists.xen.org, ian.jackson@eu.citrix.com
Cc: Ian Campbell <ian.campbell@citrix.com>,
	Roger Pau Monne <roger.pau@citrix.com>
Subject: [PATCH v3 1/7] libxl: group hotplug related variables
Date: Wed, 17 Apr 2013 17:47:21 +0200	[thread overview]
Message-ID: <1366213647-38638-2-git-send-email-roger.pau@citrix.com> (raw)
In-Reply-To: <1366213647-38638-1-git-send-email-roger.pau@citrix.com>

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@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Ian Campbell <ian.campbell@citrix.com>
---
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@lists.xen.org
http://lists.xen.org/xen-devel

  reply	other threads:[~2013-04-17 15:47 UTC|newest]

Thread overview: 74+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-17 15:47 [PATCH v3 0/7] libxl: new hotplug calling convention Roger Pau Monne
2013-04-17 15:47 ` Roger Pau Monne [this message]
2013-04-17 15:47 ` [PATCH v3 2/7] libxl: add new hotplug interface support to hotplug script callers Roger Pau Monne
2013-03-18 11:47   ` [PATCH v2] libxl: new hotplug calling convention Roger Pau Monne
2013-03-18 11:47     ` [PATCH v2 1/7] libxl: group hotplug related variables Roger Pau Monne
2013-03-18 11:47     ` [PATCH v2 2/7] libxl: add new hotplug interface support to hotplug script callers Roger Pau Monne
2013-04-11 16:25       ` Ian Jackson
2013-04-16 11:30         ` Roger Pau Monné
2013-04-16 12:06           ` Ian Campbell
2013-04-16 14:42             ` Roger Pau Monné
2013-04-16 15:04           ` Ian Jackson
2013-04-11 16:33       ` Ian Jackson
2013-04-12 13:51         ` Roger Pau Monné
2013-04-18 17:23         ` [PATCH v2 2/7] libxl: add new hotplug interface support to hotplug script callers [and 1 more messages] Ian Jackson
2013-04-18 17:40           ` Roger Pau Monné
2013-04-18 17:52             ` Ian Jackson
2013-04-19  8:10               ` Roger Pau Monné
2013-03-18 11:47     ` [PATCH v2 3/7] libxl: add support for hotplug interface v2 in domain creation/destroy Roger Pau Monne
2013-03-18 11:47     ` [PATCH v2 4/7] libxl: chain prepare and attach in libxl_device_disk_add Roger Pau Monne
2013-03-18 11:47     ` [PATCH v2 5/7] libxl: add disk specific remove functions Roger Pau Monne
2013-01-23 17:48       ` [PATCH v1 0/12] libxl: new hotplug calling convention Roger Pau Monne
2013-01-23 17:48         ` [PATCH v1 01/12] libxl: libxl__prepare_ao_device should reset num_exec Roger Pau Monne
2013-01-25  8:57           ` Ian Campbell
2013-01-23 17:48         ` [PATCH v1 02/12] libxl: remove double check in NetBSD hotplug Roger Pau Monne
2013-03-13 14:45           ` Ian Jackson
2013-01-23 17:48         ` [PATCH v1 03/12] libxl: move libxl_device_action to idl Roger Pau Monne
2013-03-13 14:48           ` Ian Jackson
2013-01-23 17:48         ` [PATCH v1 04/12] libxl: pack hotplug related variables Roger Pau Monne
2013-03-13 14:49           ` Ian Jackson
2013-03-14 16:44             ` Roger Pau Monné
2013-01-23 17:48         ` [PATCH v1 05/12] libxl: add new hotplug interface support to hotplug script callers Roger Pau Monne
2013-03-13 14:53           ` Ian Jackson
2013-03-13 16:04             ` Roger Pau Monné
2013-03-13 16:10               ` Ian Jackson
2013-03-14 17:03                 ` Roger Pau Monné
2013-01-23 17:48         ` [PATCH v1 06/12] libxl: add support for different hotplug interfaces Roger Pau Monne
2013-03-13 16:17           ` Ian Jackson
2013-03-15 11:03             ` Roger Pau Monné
2013-03-15 11:24               ` Ian Jackson
2013-03-15 11:36                 ` Roger Pau Monné
2013-01-23 17:48         ` [PATCH v1 07/12] libxl: add prepare/unprepare operations to the libxl public interface Roger Pau Monne
2013-03-13 16:19           ` Ian Jackson
2013-03-15 11:33             ` Roger Pau Monné
2013-03-15 11:42               ` Roger Pau Monné
2013-03-15 12:20               ` Ian Jackson
2013-03-15 12:39                 ` Roger Pau Monné
2013-01-23 17:48         ` [PATCH v1 08/12] libxl: add disk specific remove functions Roger Pau Monne
2013-03-13 16:22           ` Ian Jackson
2013-03-15 11:52             ` Roger Pau Monné
2013-04-11 16:17               ` [PATCH v1 08/12] libxl: add disk specific remove functions [and 1 more messages] Ian Jackson
2013-04-15  7:33                 ` Roger Pau Monné
2013-01-23 17:48         ` [PATCH v1 09/12] xl: add support for new hotplug interface to block-attach/detach Roger Pau Monne
2013-03-13 16:22           ` Ian Jackson
2013-03-15 11:54             ` Roger Pau Monné
2013-01-23 17:48         ` [PATCH v1 10/12] libxl: add local attach support for new hotplug scripts Roger Pau Monne
2013-03-13 16:25           ` Ian Jackson
2013-03-15 11:59             ` Roger Pau Monné
2013-01-23 17:48         ` [PATCH v1 11/12] hotplug: document new hotplug interface Roger Pau Monne
2013-03-13 16:29           ` Ian Jackson
2013-03-15 12:29             ` Roger Pau Monné
2013-01-23 17:48         ` [PATCH v1 12/12] hotplug/Linux: add iscsi block hotplug script Roger Pau Monne
2013-03-13 16:31           ` Ian Jackson
2013-03-15 12:08             ` Roger Pau Monné
2013-03-15 12:24               ` Ian Jackson
2013-03-04 11:13         ` [PATCH v1 0/12] libxl: new hotplug calling convention Roger Pau Monné
2013-03-18 11:47     ` [PATCH v2 6/7] libxl: add local attach support for new hotplug scripts Roger Pau Monne
2013-03-18 11:47     ` [PATCH v2 7/7] hotplug/Linux: add iscsi block hotplug script Roger Pau Monne
2013-04-17 15:47 ` [PATCH v3 3/7] libxl: add support for hotplug interface v2 in domain creation/destroy Roger Pau Monne
2013-04-18 17:30   ` Ian Jackson
2013-04-17 15:47 ` [PATCH v3 4/7] libxl: chain prepare and attach in libxl_device_disk_add Roger Pau Monne
2013-04-17 15:47 ` [PATCH v3 5/7] libxl: add disk specific remove functions Roger Pau Monne
2013-04-17 15:47 ` [PATCH v3 6/7] libxl: add local attach support for new hotplug scripts Roger Pau Monne
2013-04-17 15:47 ` [PATCH v3 7/7] hotplug/Linux: add iscsi block hotplug script Roger Pau Monne
2013-04-18 16:28 ` [PATCH v3 0/7] libxl: new hotplug calling convention George Dunlap

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=1366213647-38638-2-git-send-email-roger.pau@citrix.com \
    --to=roger.pau@citrix.com \
    --cc=ian.campbell@citrix.com \
    --cc=ian.jackson@eu.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).