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

[Xen-devel] [PATCH RFC 04/10] libxl: add prepare/unprepare operations to the libxl public interface



Add public functions for the prepare/unprepare disk operations.

Signed-off-by: Roger Pau Monnà <roger.pau@xxxxxxxxxx>
---
 tools/libxl/libxl.c |   26 +++++++++++++++-----------
 tools/libxl/libxl.h |    8 ++++++++
 2 files changed, 23 insertions(+), 11 deletions(-)

diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
index e141379..82034f1 100644
--- a/tools/libxl/libxl.c
+++ b/tools/libxl/libxl.c
@@ -1688,19 +1688,19 @@ int libxl_vncviewer_exec(libxl_ctx *ctx, uint32_t 
domid, int autopass)
 
/******************************************************************************/
 
 /* generic callback for devices that only need to set ao_complete */
-static void device_addrm_aocomplete(libxl__egc *egc, libxl__ao_device *aodev)
+static void device_aocomplete(libxl__egc *egc, libxl__ao_device *aodev)
 {
     STATE_AO_GC(aodev->ao);
 
     if (aodev->rc) {
         if (aodev->dev) {
             LOG(ERROR, "unable to %s %s with id %u",
-                        aodev->action == DEVICE_CONNECT ? "add" : "remove",
+                        libxl__device_hotplug_action(gc, 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_hotplug_action(gc, aodev->action));
         }
         goto out;
     }
@@ -3480,7 +3480,7 @@ out:
         libxl__prepare_ao_device(ao, aodev);                            \
         aodev->action = DEVICE_DISCONNECT;                              \
         aodev->dev = device;                                            \
-        aodev->callback = device_addrm_aocomplete;                      \
+        aodev->callback = device_aocomplete;                            \
         aodev->force = f;                                               \
         libxl__initiate_device_remove(egc, aodev);                      \
                                                                         \
@@ -3521,10 +3521,12 @@ DEFINE_DEVICE_REMOVE(vtpm, destroy, 1)
  * libxl_device_disk_add
  * libxl_device_nic_add
  * libxl_device_vtpm_add
+ * libxl_device_disk_prepare
+ * libxl_device_disk_unprepare
  */
 
-#define DEFINE_DEVICE_ADD(type)                                         \
-    int libxl_device_##type##_add(libxl_ctx *ctx,                       \
+#define DEFINE_DEVICE_FUNC(type, op)                                    \
+    int libxl_device_##type##_##op(libxl_ctx *ctx,                      \
         uint32_t domid, libxl_device_##type *type,                      \
         const libxl_asyncop_how *ao_how)                                \
     {                                                                   \
@@ -3533,8 +3535,8 @@ DEFINE_DEVICE_REMOVE(vtpm, destroy, 1)
                                                                         \
         GCNEW(aodev);                                                   \
         libxl__prepare_ao_device(ao, aodev);                            \
-        aodev->callback = device_addrm_aocomplete;                      \
-        libxl__device_##type##_add(egc, domid, type, aodev);            \
+        aodev->callback = device_aocomplete;                            \
+        libxl__device_##type##_##op(egc, domid, type, aodev);           \
                                                                         \
         return AO_INPROGRESS;                                           \
     }
@@ -3542,13 +3544,15 @@ DEFINE_DEVICE_REMOVE(vtpm, destroy, 1)
 /* Define alladd functions and undef the macro */
 
 /* disk */
-DEFINE_DEVICE_ADD(disk)
+DEFINE_DEVICE_FUNC(disk, add)
+DEFINE_DEVICE_FUNC(disk, prepare)
+DEFINE_DEVICE_FUNC(disk, unprepare)
 
 /* nic */
-DEFINE_DEVICE_ADD(nic)
+DEFINE_DEVICE_FUNC(nic, add)
 
 /* vtpm */
-DEFINE_DEVICE_ADD(vtpm)
+DEFINE_DEVICE_FUNC(vtpm, add)
 
 #undef DEFINE_DEVICE_ADD
 
diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h
index e2ba549..f3426f7 100644
--- a/tools/libxl/libxl.h
+++ b/tools/libxl/libxl.h
@@ -707,6 +707,10 @@ void libxl_vtpminfo_list_free(libxl_vtpminfo *, int 
nr_vtpms);
  */
 
 /* Disks */
+int libxl_device_disk_prepare(libxl_ctx *ctx, uint32_t domid,
+                              libxl_device_disk *disk,
+                              const libxl_asyncop_how *ao_how)
+                              LIBXL_EXTERNAL_CALLERS_ONLY;
 int libxl_device_disk_add(libxl_ctx *ctx, uint32_t domid,
                           libxl_device_disk *disk,
                           const libxl_asyncop_how *ao_how)
@@ -719,6 +723,10 @@ int libxl_device_disk_destroy(libxl_ctx *ctx, uint32_t 
domid,
                               libxl_device_disk *disk,
                               const libxl_asyncop_how *ao_how)
                               LIBXL_EXTERNAL_CALLERS_ONLY;
+int libxl_device_disk_unprepare(libxl_ctx *ctx, uint32_t domid,
+                                libxl_device_disk *disk,
+                                const libxl_asyncop_how *ao_how)
+                                LIBXL_EXTERNAL_CALLERS_ONLY;
 
 libxl_device_disk *libxl_device_disk_list(libxl_ctx *ctx, uint32_t domid, int 
*num);
 int libxl_device_disk_getinfo(libxl_ctx *ctx, uint32_t domid,
-- 
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®.