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

[Xen-devel] [PATCH v9 17/17] libxl: convert libxl_device_vfb_add to an async operation



Split libxl_device_vfb_add into libxl__device_vfb_add (to be used
inside already running ao's), and make libxl_device_vfb_add a stub
to call libxl__device_vfb_add.

Cc: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
Signed-off-by: Roger Pau Monne <roger.pau@xxxxxxxxxx>
---
 tools/libxl/libxl.c          |   14 ++++++++++----
 tools/libxl/libxl.h          |    3 ++-
 tools/libxl/libxl_create.c   |   10 ++++------
 tools/libxl/libxl_device.c   |    2 ++
 tools/libxl/libxl_dm.c       |    9 +++++----
 tools/libxl/libxl_internal.h |    9 +++++++++
 6 files changed, 32 insertions(+), 15 deletions(-)

diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
index b07e4e5..fc4989c 100644
--- a/tools/libxl/libxl.c
+++ b/tools/libxl/libxl.c
@@ -2897,9 +2897,10 @@ static int libxl__device_from_vfb(libxl__gc *gc, 
uint32_t domid,
     return 0;
 }
 
-int libxl_device_vfb_add(libxl_ctx *ctx, uint32_t domid, libxl_device_vfb *vfb)
+void libxl__device_vfb_add(libxl__egc *egc, uint32_t domid,
+                           libxl_device_vfb *vfb, libxl__ao_device *aodev)
 {
-    GC_INIT(ctx);
+    STATE_AO_GC(aodev->ao);
     flexarray_t *front;
     flexarray_t *back;
     libxl__device device;
@@ -2957,8 +2958,9 @@ out_free:
     flexarray_free(front);
     flexarray_free(back);
 out:
-    GC_FREE;
-    return rc;
+    aodev->rc = rc;
+    aodev->callback(egc, aodev);
+    return;
 }
 
 
/******************************************************************************/
@@ -3029,6 +3031,7 @@ DEFINE_DEVICE_REMOVE(vfb, destroy, 1)
  * libxl_device_disk_add
  * libxl_device_nic_add
  * libxl_device_vkb_add
+ * libxl_device_vfb_add
  */
 
 #define DEFINE_DEVICE_ADD(type)                                         \
@@ -3058,6 +3061,9 @@ DEFINE_DEVICE_ADD(nic)
 /* vkb */
 DEFINE_DEVICE_ADD(vkb)
 
+/* vfb */
+DEFINE_DEVICE_ADD(vfb)
+
 #undef DEFINE_DEVICE_ADD
 
 
/******************************************************************************/
diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h
index 84d4efd..414475e 100644
--- a/tools/libxl/libxl.h
+++ b/tools/libxl/libxl.h
@@ -720,7 +720,8 @@ int libxl_device_vkb_destroy(libxl_ctx *ctx, uint32_t domid,
                              const libxl_asyncop_how *ao_how);
 
 /* Framebuffer */
-int libxl_device_vfb_add(libxl_ctx *ctx, uint32_t domid, libxl_device_vfb 
*vfb);
+int libxl_device_vfb_add(libxl_ctx *ctx, uint32_t domid, libxl_device_vfb *vfb,
+                         const libxl_asyncop_how *ao_how);
 int libxl_device_vfb_remove(libxl_ctx *ctx, uint32_t domid,
                             libxl_device_vfb *vfb,
                             const libxl_asyncop_how *ao_how);
diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c
index fdbcafc..8b5ea4c 100644
--- a/tools/libxl/libxl_create.c
+++ b/tools/libxl/libxl_create.c
@@ -911,12 +911,15 @@ static void domcreate_rebuild_done(libxl__egc *egc,
         d_config->num_vkbs = 1;
     }
 
-    dcs->aodevs.size = d_config->num_disks + d_config->num_vkbs;
+    dcs->aodevs.size = d_config->num_disks + d_config->num_vkbs +
+                       d_config->num_vfbs;
     dcs->aodevs.callback = domcreate_launch_dm;
     libxl__prepare_ao_devices(ao, &dcs->aodevs);
     libxl__add_disks(egc, ao, domid, 0, d_config, &dcs->aodevs);
     libxl__add_vkbs(egc, ao, domid, d_config->num_disks, d_config,
                     &dcs->aodevs);
+    libxl__add_vfbs(egc, ao, domid, d_config->num_disks + d_config->num_vkbs,
+                    d_config, &dcs->aodevs);
 
     return;
 
@@ -936,7 +939,6 @@ static void domcreate_launch_dm(libxl__egc *egc, 
libxl__ao_devices *aodevs,
     const uint32_t domid = dcs->guest_domid;
     libxl_domain_config *const d_config = dcs->guest_config;
     libxl__domain_build_state *const state = &dcs->build_state;
-    libxl_ctx *const ctx = CTX;
 
     if (ret) {
         LOG(ERROR, "unable to add misc devices");
@@ -972,10 +974,6 @@ static void domcreate_launch_dm(libxl__egc *egc, 
libxl__ao_devices *aodevs,
         int need_qemu = 0;
         libxl__device_console console;
 
-        for (i = 0; i < d_config->num_vfbs; i++) {
-            libxl_device_vfb_add(ctx, domid, &d_config->vfbs[i]);
-        }
-
         ret = init_console_info(&console, 0);
         if ( ret )
             goto error_out;
diff --git a/tools/libxl/libxl_device.c b/tools/libxl/libxl_device.c
index f6e5585..c550ea5 100644
--- a/tools/libxl/libxl_device.c
+++ b/tools/libxl/libxl_device.c
@@ -481,6 +481,7 @@ void libxl__ao_devices_callback(libxl__egc *egc, 
libxl__ao_device *aodev)
  * libxl__add_disks
  * libxl__add_nics
  * libxl__add_vkbs
+ * libxl__add_vfbs
  */
 
 #define DEFINE_DEVICES_ADD(type)                                               
\
@@ -501,6 +502,7 @@ void libxl__ao_devices_callback(libxl__egc *egc, 
libxl__ao_device *aodev)
 DEFINE_DEVICES_ADD(disk)
 DEFINE_DEVICES_ADD(nic)
 DEFINE_DEVICES_ADD(vkb)
+DEFINE_DEVICES_ADD(vfb)
 
 #undef DEFINE_DEVICES_ADD
 
diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c
index a6ee080..cc35380 100644
--- a/tools/libxl/libxl_dm.c
+++ b/tools/libxl/libxl_dm.c
@@ -833,12 +833,16 @@ retry_transaction:
         if (errno == EAGAIN)
             goto retry_transaction;
 
-    sdss->aodevs.size = dm_config->num_disks + dm_config->num_vkbs;
+    sdss->aodevs.size = dm_config->num_disks + dm_config->num_vkbs +
+                        dm_config->num_vfbs;
     sdss->aodevs.callback = spawn_stub_launch_dm;
     libxl__prepare_ao_devices(ao, &sdss->aodevs);
     libxl__add_disks(egc, ao, dm_domid, 0, dm_config, &sdss->aodevs);
     libxl__add_vkbs(egc, ao, dm_domid, dm_config->num_disks, dm_config,
                     &sdss->aodevs);
+    libxl__add_vfbs(egc, ao, dm_domid,
+                    dm_config->num_disks + dm_config->num_vfbs, dm_config,
+                    &sdss->aodevs);
 
     free(args);
     return;
@@ -879,9 +883,6 @@ static void spawn_stub_launch_dm(libxl__egc *egc,
          */
         libxl__device_nic_setdefault(gc, &dm_config->nics[i], dm_domid);
     }
-    ret = libxl_device_vfb_add(ctx, dm_domid, &dm_config->vfbs[0]);
-    if (ret)
-        goto out;
 
     if (guest_config->b_info.u.hvm.serial)
         num_console++;
diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
index 29d2fcd..d34b7ff 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -1832,6 +1832,11 @@ _hidden void libxl__device_vkb_add(libxl__egc *egc, 
uint32_t domid,
                                    libxl_device_vkb *vkb,
                                    libxl__ao_device *aodev);
 
+/* AO operation to connect a vfb device */
+_hidden void libxl__device_vfb_add(libxl__egc *egc, uint32_t domid,
+                                   libxl_device_vfb *vfb,
+                                   libxl__ao_device *aodev);
+
 /* Waits for the passed device to reach state XenbusStateInitWait.
  * This is not really useful by itself, but is important when executing
  * hotplug scripts, since we need to be sure the device is in the correct
@@ -2251,6 +2256,10 @@ _hidden void libxl__add_vkbs(libxl__egc *egc, libxl__ao 
*ao, uint32_t domid,
                              int start, libxl_domain_config *d_config,
                              libxl__ao_devices *aodevs);
 
+_hidden void libxl__add_vfbs(libxl__egc *egc, libxl__ao *ao, uint32_t domid,
+                             int start, libxl_domain_config *d_config,
+                             libxl__ao_devices *aodevs);
+
 /*----- device model creation -----*/
 
 /* First layer; wraps libxl__spawn_spawn. */
-- 
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®.