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 Jackson <ian.jackson@eu.citrix.com>,
	Roger Pau Monne <roger.pau@citrix.com>
Subject: [PATCH v9 16/17] libxl: convert libxl_device_vkb_add to an async operation
Date: Fri, 13 Jul 2012 10:44:55 +0100	[thread overview]
Message-ID: <1342172696-88347-17-git-send-email-roger.pau@citrix.com> (raw)
In-Reply-To: <1342172696-88347-1-git-send-email-roger.pau@citrix.com>

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

Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Signed-off-by: Roger Pau Monne <roger.pau@citrix.com>
---
 tools/libxl/libxl.c          |   14 ++++++++++----
 tools/libxl/libxl.h          |    3 ++-
 tools/libxl/libxl_create.c   |   19 +++++++++++--------
 tools/libxl/libxl_device.c   |    2 ++
 tools/libxl/libxl_dm.c       |    9 ++++-----
 tools/libxl/libxl_internal.h |    9 +++++++++
 6 files changed, 38 insertions(+), 18 deletions(-)

diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
index d0bbdce..b07e4e5 100644
--- a/tools/libxl/libxl.c
+++ b/tools/libxl/libxl.c
@@ -2811,9 +2811,10 @@ static int libxl__device_from_vkb(libxl__gc *gc, uint32_t domid,
     return 0;
 }
 
-int libxl_device_vkb_add(libxl_ctx *ctx, uint32_t domid, libxl_device_vkb *vkb)
+void libxl__device_vkb_add(libxl__egc *egc, uint32_t domid,
+                           libxl_device_vkb *vkb, libxl__ao_device *aodev)
 {
-    GC_INIT(ctx);
+    STATE_AO_GC(aodev->ao);
     flexarray_t *front;
     flexarray_t *back;
     libxl__device device;
@@ -2858,8 +2859,9 @@ out_free:
     flexarray_free(back);
     flexarray_free(front);
 out:
-    GC_FREE;
-    return rc;
+    aodev->rc = rc;
+    aodev->callback(egc, aodev);
+    return;
 }
 
 /******************************************************************************/
@@ -3026,6 +3028,7 @@ DEFINE_DEVICE_REMOVE(vfb, destroy, 1)
 /* The following functions are defined:
  * libxl_device_disk_add
  * libxl_device_nic_add
+ * libxl_device_vkb_add
  */
 
 #define DEFINE_DEVICE_ADD(type)                                         \
@@ -3052,6 +3055,9 @@ DEFINE_DEVICE_ADD(disk)
 /* nic */
 DEFINE_DEVICE_ADD(nic)
 
+/* vkb */
+DEFINE_DEVICE_ADD(vkb)
+
 #undef DEFINE_DEVICE_ADD
 
 /******************************************************************************/
diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h
index d548090..84d4efd 100644
--- a/tools/libxl/libxl.h
+++ b/tools/libxl/libxl.h
@@ -710,7 +710,8 @@ int libxl_device_nic_getinfo(libxl_ctx *ctx, uint32_t domid,
                               libxl_device_nic *nic, libxl_nicinfo *nicinfo);
 
 /* Keyboard */
-int libxl_device_vkb_add(libxl_ctx *ctx, uint32_t domid, libxl_device_vkb *vkb);
+int libxl_device_vkb_add(libxl_ctx *ctx, uint32_t domid, libxl_device_vkb *vkb,
+                         const libxl_asyncop_how *ao_how);
 int libxl_device_vkb_remove(libxl_ctx *ctx, uint32_t domid,
                             libxl_device_vkb *vkb,
                             const libxl_asyncop_how *ao_how);
diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c
index 7db9457..fdbcafc 100644
--- a/tools/libxl/libxl_create.c
+++ b/tools/libxl/libxl_create.c
@@ -904,10 +904,19 @@ static void domcreate_rebuild_done(libxl__egc *egc,
 
     store_libxl_entry(gc, domid, &d_config->b_info);
 
-    dcs->aodevs.size = d_config->num_disks;
+    if (d_config->c_info.type == LIBXL_DOMAIN_TYPE_HVM) {
+        assert(!d_config->vkbs && !d_config->num_vkbs);
+        d_config->vkbs = libxl__zalloc(NOGC, sizeof(*d_config->vkbs));
+        libxl_device_vkb_init(&d_config->vkbs[0]);
+        d_config->num_vkbs = 1;
+    }
+
+    dcs->aodevs.size = d_config->num_disks + d_config->num_vkbs;
     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);
 
     return;
 
@@ -930,7 +939,7 @@ static void domcreate_launch_dm(libxl__egc *egc, libxl__ao_devices *aodevs,
     libxl_ctx *const ctx = CTX;
 
     if (ret) {
-        LOG(ERROR, "unable to add disk devices");
+        LOG(ERROR, "unable to add misc devices");
         goto error_out;
     }
     for (i = 0; i < d_config->num_nics; i++) {
@@ -944,7 +953,6 @@ static void domcreate_launch_dm(libxl__egc *egc, libxl__ao_devices *aodevs,
     case LIBXL_DOMAIN_TYPE_HVM:
     {
         libxl__device_console console;
-        libxl_device_vkb vkb;
 
         ret = init_console_info(&console, 0);
         if ( ret )
@@ -952,10 +960,6 @@ static void domcreate_launch_dm(libxl__egc *egc, libxl__ao_devices *aodevs,
         libxl__device_console_add(gc, domid, &console, state);
         libxl__device_console_dispose(&console);
 
-        libxl_device_vkb_init(&vkb);
-        libxl_device_vkb_add(ctx, domid, &vkb);
-        libxl_device_vkb_dispose(&vkb);
-
         dcs->dmss.dm.guest_domid = domid;
         if (libxl_defbool_val(d_config->b_info.device_model_stubdomain))
             libxl__spawn_stub_dm(egc, &dcs->dmss);
@@ -970,7 +974,6 @@ static void domcreate_launch_dm(libxl__egc *egc, libxl__ao_devices *aodevs,
 
         for (i = 0; i < d_config->num_vfbs; i++) {
             libxl_device_vfb_add(ctx, domid, &d_config->vfbs[i]);
-            libxl_device_vkb_add(ctx, domid, &d_config->vkbs[i]);
         }
 
         ret = init_console_info(&console, 0);
diff --git a/tools/libxl/libxl_device.c b/tools/libxl/libxl_device.c
index 2f41b46..f6e5585 100644
--- a/tools/libxl/libxl_device.c
+++ b/tools/libxl/libxl_device.c
@@ -480,6 +480,7 @@ void libxl__ao_devices_callback(libxl__egc *egc, libxl__ao_device *aodev)
  * The following functions are defined:
  * libxl__add_disks
  * libxl__add_nics
+ * libxl__add_vkbs
  */
 
 #define DEFINE_DEVICES_ADD(type)                                               \
@@ -499,6 +500,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)
 
 #undef DEFINE_DEVICES_ADD
 
diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c
index cbe518f..a6ee080 100644
--- a/tools/libxl/libxl_dm.c
+++ b/tools/libxl/libxl_dm.c
@@ -833,10 +833,12 @@ retry_transaction:
         if (errno == EAGAIN)
             goto retry_transaction;
 
-    sdss->aodevs.size = dm_config->num_disks;
+    sdss->aodevs.size = dm_config->num_disks + dm_config->num_vkbs;
     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);
 
     free(args);
     return;
@@ -866,7 +868,7 @@ static void spawn_stub_launch_dm(libxl__egc *egc,
     uint32_t dm_domid = sdss->pvqemu.guest_domid;
 
     if (ret) {
-        LOG(ERROR, "error connecting disk devices");
+        LOG(ERROR, "error connecting misc devices");
         goto out;
      }
 
@@ -880,9 +882,6 @@ static void spawn_stub_launch_dm(libxl__egc *egc,
     ret = libxl_device_vfb_add(ctx, dm_domid, &dm_config->vfbs[0]);
     if (ret)
         goto out;
-    ret = libxl_device_vkb_add(ctx, dm_domid, &dm_config->vkbs[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 60b5bf3..29d2fcd 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -1827,6 +1827,11 @@ _hidden void libxl__device_nic_add(libxl__egc *egc, uint32_t domid,
                                    libxl_device_nic *nic,
                                    libxl__ao_device *aodev);
 
+/* AO operation to connect a vkb device */
+_hidden void libxl__device_vkb_add(libxl__egc *egc, uint32_t domid,
+                                   libxl_device_vkb *vkb,
+                                   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
@@ -2242,6 +2247,10 @@ _hidden void libxl__add_nics(libxl__egc *egc, libxl__ao *ao, uint32_t domid,
                              int start, libxl_domain_config *d_config,
                              libxl__ao_devices *aodevs);
 
+_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);
+
 /*----- device model creation -----*/
 
 /* First layer; wraps libxl__spawn_spawn. */
-- 
1.7.7.5 (Apple Git-26)

  parent reply	other threads:[~2012-07-13  9:44 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-13  9:44 [PATCH v9 00/15] execute hotplug scripts from libxl Roger Pau Monne
2012-07-13  9:44 ` [PATCH v9 01/17] libxl: change ao_device_remove to ao_device Roger Pau Monne
2012-07-18 16:29   ` Ian Jackson
2012-07-19 15:15     ` Roger Pau Monne
2012-07-13  9:44 ` [PATCH v9 02/17] libxl: move device model creation prototypes Roger Pau Monne
2012-07-13  9:44 ` [PATCH v9 03/17] libxl: convert libxl_domain_destroy to an async op Roger Pau Monne
2012-07-13  9:44 ` [PATCH v9 04/17] libxl: move bootloader data strucutres and prototypes Roger Pau Monne
2012-07-13  9:44 ` [PATCH v9 05/17] libxl: refactor disk addition to take a helper Roger Pau Monne
2012-07-17 16:46   ` Ian Jackson
2012-07-20 10:38     ` Roger Pau Monne
2012-07-13  9:44 ` [PATCH v9 06/17] libxl: convert libxl__device_disk_local_attach to an async op Roger Pau Monne
2012-07-19 16:16   ` Ian Jackson
2012-07-20  9:48     ` Roger Pau Monne
2012-07-20 11:27       ` Ian Jackson
2012-07-20 12:52         ` Roger Pau Monne
2012-07-20 17:45         ` Ian Jackson
2012-07-13  9:44 ` [PATCH v9 07/17] libxl: rename vifs to nics Roger Pau Monne
2012-07-19 15:12   ` Ian Jackson
2012-07-13  9:44 ` [PATCH v9 08/17] libxl: convert libxl_device_disk_add to an async op Roger Pau Monne
2012-07-19 15:58   ` Ian Jackson
2012-07-19 16:14     ` Roger Pau Monne
2012-07-20 10:43       ` Ian Jackson
2012-07-20  9:41   ` Ian Campbell
2012-07-20 10:54     ` Roger Pau Monne
2012-07-20 11:28       ` Ian Jackson
2012-07-13  9:44 ` [PATCH v9 09/17] libxl: convert libxl_device_nic_add to an async operation Roger Pau Monne
2012-07-13  9:44 ` [PATCH v9 10/17] libxl: add option to choose who executes hotplug scripts Roger Pau Monne
2012-07-13  9:44 ` [PATCH v9 11/17] libxl: rename _IOEMU nic type to VIF_IOEMU Roger Pau Monne
2012-07-13  9:44 ` [PATCH v9 12/17] libxl: set correct nic type depending on the guest Roger Pau Monne
2012-07-19 16:29   ` Ian Jackson
2012-07-13  9:44 ` [PATCH v9 13/17] libxl: use libxl__xs_path_cleanup on device_destroy Roger Pau Monne
2012-07-13  9:44 ` [PATCH v9 14/17] libxl: call hotplug scripts for disk devices from libxl Roger Pau Monne
2012-07-13  9:44 ` [PATCH v9 15/17] libxl: call hotplug scripts for nic " Roger Pau Monne
2012-07-13  9:44 ` Roger Pau Monne [this message]
2012-07-19 16:35   ` [PATCH v9 16/17] libxl: convert libxl_device_vkb_add to an async operation Ian Jackson
2012-07-19 16:41     ` Roger Pau Monne
2012-07-20 10:49       ` Ian Jackson
2012-07-20 11:00         ` Roger Pau Monne
2012-07-13  9:44 ` [PATCH v9 17/17] libxl: convert libxl_device_vfb_add " Roger Pau Monne
2012-07-26 10:42   ` Ian Jackson

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=1342172696-88347-17-git-send-email-roger.pau@citrix.com \
    --to=roger.pau@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).