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

[Xen-changelog] [xen master] libxl: move libxl_device_action to idl



commit d46d13606e5533d63a83c6541942d7d66f217896
Author:     Roger Pau Monne <roger.pau@xxxxxxxxxx>
AuthorDate: Wed Jan 23 17:55:39 2013 +0000
Commit:     Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>
CommitDate: Wed Mar 13 14:48:00 2013 +0000

    libxl: move libxl_device_action to idl
    
    Move to idl for ease of expansion and auto-generated functions.
    
    Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
    Cc: Ian Campbell <ian.campbell@xxxxxxxxxx>
    Acked-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
---
 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 345d88b..a09c0fa 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;
@@ -2166,7 +2166,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;
@@ -2631,7 +2631,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;
@@ -2685,7 +2685,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;
@@ -2716,7 +2716,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;
@@ -2895,7 +2895,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;
@@ -3373,7 +3373,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 1567b4b..12b6a6c 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -1833,12 +1833,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"),
+    ])
--
generated by git-patchbot for /home/xen/git/xen.git#master

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.