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
Cc: Ian Campbell <ian.campbell@citrix.com>,
	Roger Pau Monne <roger.pau@citrix.com>
Subject: [PATCH v1 03/12] libxl: move libxl_device_action to idl
Date: Wed, 23 Jan 2013 18:48:28 +0100	[thread overview]
Message-ID: <1358963317-10221-4-git-send-email-roger.pau@citrix.com> (raw)
In-Reply-To: <1358963317-10221-1-git-send-email-roger.pau@citrix.com>

Move to idl for ease of expansion and auto-generated functions.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Cc: Ian Campbell <ian.campbell@citrix.com>
---
 tools/libxl/libxl.c                  |   18 +++++++++---------
 tools/libxl/libxl_device.c           |   11 ++++++-----
 tools/libxl/libxl_internal.h         |    6 ------
 tools/libxl/libxl_linux.c            |    7 ++++---
 tools/libxl/libxl_netbsd.c           |    2 +-
 tools/libxl/libxl_types_internal.idl |    5 +++++
 6 files changed, 25 insertions(+), 24 deletions(-)

diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
index 73e0dc3..a67c4dc 100644
--- a/tools/libxl/libxl.c
+++ b/tools/libxl/libxl.c
@@ -1695,12 +1695,12 @@ static void device_addrm_aocomplete(libxl__egc *egc, libxl__ao_device *aodev)
     if (aodev->rc) {
         if (aodev->dev) {
             LOG(ERROR, "unable to %s %s with id %u",
-                        aodev->action == DEVICE_CONNECT ? "add" : "remove",
+                        libxl__device_action_to_string(aodev->action),
                         libxl__device_kind_to_string(aodev->dev->kind),
                         aodev->dev->devid);
         } else {
             LOG(ERROR, "unable to %s device",
-                       aodev->action == DEVICE_CONNECT ? "add" : "remove");
+                       libxl__device_action_to_string(aodev->action));
         }
         goto out;
     }
@@ -1806,7 +1806,7 @@ void libxl__device_vtpm_add(libxl__egc *egc, uint32_t domid,
                              libxl__xs_kvs_of_flexarray(gc, front, front->count));
 
     aodev->dev = device;
-    aodev->action = DEVICE_CONNECT;
+    aodev->action = LIBXL__DEVICE_ACTION_ADD;
     libxl__wait_device_connection(egc, aodev);
 
     rc = 0;
@@ -2163,7 +2163,7 @@ static void device_disk_add(libxl__egc *egc, uint32_t domid,
     }
 
     aodev->dev = device;
-    aodev->action = DEVICE_CONNECT;
+    aodev->action = LIBXL__DEVICE_ACTION_ADD;
     libxl__wait_device_connection(egc, aodev);
 
     rc = 0;
@@ -2628,7 +2628,7 @@ static void local_device_attach_cb(libxl__egc *egc, libxl__ao_device *aodev)
     rc = aodev->rc;
     if (rc) {
         LOGE(ERROR, "unable to %s %s with id %u",
-                    aodev->action == DEVICE_CONNECT ? "add" : "remove",
+                    libxl__device_action_to_string(aodev->action),
                     libxl__device_kind_to_string(aodev->dev->kind),
                     aodev->dev->devid);
         goto out;
@@ -2682,7 +2682,7 @@ void libxl__device_disk_local_initiate_detach(libxl__egc *egc,
                                              disk, device);
                 if (rc != 0) goto out;
 
-                aodev->action = DEVICE_DISCONNECT;
+                aodev->action = LIBXL__DEVICE_ACTION_REMOVE;
                 aodev->dev = device;
                 aodev->callback = local_device_detach_cb;
                 aodev->force = 0;
@@ -2713,7 +2713,7 @@ static void local_device_detach_cb(libxl__egc *egc, libxl__ao_device *aodev)
 
     if (aodev->rc) {
         LOGE(ERROR, "unable to %s %s with id %u",
-                    aodev->action == DEVICE_CONNECT ? "add" : "remove",
+                    libxl__device_action_to_string(aodev->action),
                     libxl__device_kind_to_string(aodev->dev->kind),
                     aodev->dev->devid);
         goto out;
@@ -2892,7 +2892,7 @@ void libxl__device_nic_add(libxl__egc *egc, uint32_t domid,
                              libxl__xs_kvs_of_flexarray(gc, front, front->count));
 
     aodev->dev = device;
-    aodev->action = DEVICE_CONNECT;
+    aodev->action = LIBXL__DEVICE_ACTION_ADD;
     libxl__wait_device_connection(egc, aodev);
 
     rc = 0;
@@ -3370,7 +3370,7 @@ out:
                                                                         \
         GCNEW(aodev);                                                   \
         libxl__prepare_ao_device(ao, aodev);                            \
-        aodev->action = DEVICE_DISCONNECT;                              \
+        aodev->action = LIBXL__DEVICE_ACTION_REMOVE;                    \
         aodev->dev = device;                                            \
         aodev->callback = device_addrm_aocomplete;                      \
         aodev->force = f;                                               \
diff --git a/tools/libxl/libxl_device.c b/tools/libxl/libxl_device.c
index 58d3f35..eeea9d9 100644
--- a/tools/libxl/libxl_device.c
+++ b/tools/libxl/libxl_device.c
@@ -614,7 +614,7 @@ void libxl__devices_destroy(libxl__egc *egc, libxl__devices_remove_state *drs)
                     continue;
                 }
                 aodev = libxl__multidev_prepare(multidev);
-                aodev->action = DEVICE_DISCONNECT;
+                aodev->action = LIBXL__DEVICE_ACTION_REMOVE;
                 aodev->dev = dev;
                 aodev->force = drs->force;
                 libxl__initiate_device_remove(egc, aodev);
@@ -849,7 +849,8 @@ static void device_backend_callback(libxl__egc *egc, libxl__ev_devstate *ds,
 
     device_backend_cleanup(gc, aodev);
 
-    if (rc == ERROR_TIMEDOUT && aodev->action == DEVICE_DISCONNECT &&
+    if (rc == ERROR_TIMEDOUT &&
+        aodev->action == LIBXL__DEVICE_ACTION_REMOVE &&
         !aodev->force) {
         aodev->force = 1;
         libxl__initiate_device_remove(egc, aodev);
@@ -858,7 +859,7 @@ static void device_backend_callback(libxl__egc *egc, libxl__ev_devstate *ds,
 
     if (rc) {
         LOG(ERROR, "unable to %s device with path %s",
-                   aodev->action == DEVICE_CONNECT ? "connect" : "disconnect",
+                   libxl__device_action_to_string(aodev->action),
                    libxl__device_backend_path(gc, aodev->dev));
         goto out;
     }
@@ -981,7 +982,7 @@ static void device_hotplug_child_death_cb(libxl__egc *egc,
         if (hotplug_error)
             LOG(ERROR, "script: %s", hotplug_error);
         aodev->rc = ERROR_FAIL;
-        if (aodev->action == DEVICE_CONNECT)
+        if (aodev->action == LIBXL__DEVICE_ACTION_ADD)
             /*
              * Only fail on device connection, on disconnection
              * ignore error, and continue with the remove process
@@ -1011,7 +1012,7 @@ static void device_hotplug_done(libxl__egc *egc, libxl__ao_device *aodev)
     device_hotplug_clean(gc, aodev);
 
     /* Clean xenstore if it's a disconnection */
-    if (aodev->action == DEVICE_DISCONNECT) {
+    if (aodev->action == LIBXL__DEVICE_ACTION_REMOVE) {
         rc = libxl__device_destroy(gc, aodev->dev);
         if (!aodev->rc)
             aodev->rc = rc;
diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
index 0b38e3e..f127f8a 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -1829,12 +1829,6 @@ _hidden const char *libxl__run_dir_path(void);
 
 /*----- device addition/removal -----*/
 
-/* Action to perform (either connect or disconnect) */
-typedef enum {
-    DEVICE_CONNECT,
-    DEVICE_DISCONNECT
-} libxl__device_action;
-
 typedef struct libxl__ao_device libxl__ao_device;
 typedef struct libxl__multidev libxl__multidev;
 typedef void libxl__device_callback(libxl__egc*, libxl__ao_device*);
diff --git a/tools/libxl/libxl_linux.c b/tools/libxl/libxl_linux.c
index 1fed3cd..1ef13c0 100644
--- a/tools/libxl/libxl_linux.c
+++ b/tools/libxl/libxl_linux.c
@@ -173,11 +173,12 @@ static int libxl__hotplug_nic(libxl__gc *gc, libxl__device *dev,
     (*args)[nr++] = script;
 
     if (nictype == LIBXL_NIC_TYPE_VIF_IOEMU && num_exec) {
-        (*args)[nr++] = action == DEVICE_CONNECT ? "add" : "remove";
+        (*args)[nr++] = (char *) libxl__device_action_to_string(action);
         (*args)[nr++] = "type_if=tap";
         (*args)[nr++] = NULL;
     } else {
-        (*args)[nr++] = action == DEVICE_CONNECT ? "online" : "offline";
+        (*args)[nr++] = action == LIBXL__DEVICE_ACTION_ADD ? "online" :
+                                                             "offline";
         (*args)[nr++] = "type_if=vif";
         (*args)[nr++] = NULL;
     }
@@ -213,7 +214,7 @@ static int libxl__hotplug_disk(libxl__gc *gc, libxl__device *dev,
     const int arraysize = 3;
     GCNEW_ARRAY(*args, arraysize);
     (*args)[nr++] = script;
-    (*args)[nr++] = action == DEVICE_CONNECT ? "add" : "remove";
+    (*args)[nr++] = (char *) libxl__device_action_to_string(action);
     (*args)[nr++] = NULL;
     assert(nr == arraysize);
 
diff --git a/tools/libxl/libxl_netbsd.c b/tools/libxl/libxl_netbsd.c
index 36662c0..0ad69af 100644
--- a/tools/libxl/libxl_netbsd.c
+++ b/tools/libxl/libxl_netbsd.c
@@ -50,7 +50,7 @@ static int libxl__hotplug(libxl__gc *gc, libxl__device *dev, char ***args,
     GCNEW_ARRAY(*args, arraysize);
     (*args)[nr++] = script;
     (*args)[nr++] = be_path;
-    (*args)[nr++] = GCSPRINTF("%d", action == DEVICE_CONNECT ?
+    (*args)[nr++] = GCSPRINTF("%d", action == LIBXL__DEVICE_ACTION_ADD ?
                                     XenbusStateInitWait : XenbusStateClosed);
     (*args)[nr++] = NULL;
     assert(nr == arraysize);
diff --git a/tools/libxl/libxl_types_internal.idl b/tools/libxl/libxl_types_internal.idl
index c40120e..cb9444f 100644
--- a/tools/libxl/libxl_types_internal.idl
+++ b/tools/libxl/libxl_types_internal.idl
@@ -33,3 +33,8 @@ libxl__device_console = Struct("device_console", [
     ("consback", libxl__console_backend),
     ("output", string),
     ])
+
+libxl__device_action = Enumeration("device_action", [
+    (1, "ADD"),
+    (2, "REMOVE"),
+    ])
-- 
1.7.7.5 (Apple Git-26)


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

  parent reply	other threads:[~2013-01-23 17:48 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 ` [PATCH v3 1/7] libxl: group hotplug related variables Roger Pau Monne
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         ` Roger Pau Monne [this message]
2013-03-13 14:48           ` [PATCH v1 03/12] libxl: move libxl_device_action to idl 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=1358963317-10221-4-git-send-email-roger.pau@citrix.com \
    --to=roger.pau@citrix.com \
    --cc=ian.campbell@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).