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 v13 11/11] libxl: convert libxl_device_vfb_add to an async operation
Date: Thu, 26 Jul 2012 15:55:22 +0100	[thread overview]
Message-ID: <1343314522-32298-12-git-send-email-roger.pau@citrix.com> (raw)
In-Reply-To: <1343314522-32298-1-git-send-email-roger.pau@citrix.com>

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.

Changes since v11:

 * libxl__device_vfb_add is no longer an ao operation.

Changes since v9:

 * Fixed Ocaml bindings.

Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Signed-off-by: Roger Pau Monne <roger.pau@citrix.com>
---
 tools/libxl/libxl.c                  |   21 ++++++++++++++++++---
 tools/libxl/libxl.h                  |    3 ++-
 tools/libxl/libxl_create.c           |    3 +--
 tools/libxl/libxl_dm.c               |    2 +-
 tools/libxl/libxl_internal.h         |    4 ++++
 tools/ocaml/libs/xl/xenlight_stubs.c |    2 +-
 6 files changed, 27 insertions(+), 8 deletions(-)

diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
index a23769f..de70e60 100644
--- a/tools/libxl/libxl.c
+++ b/tools/libxl/libxl.c
@@ -2960,9 +2960,25 @@ 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)
+int libxl_device_vfb_add(libxl_ctx *ctx, uint32_t domid, libxl_device_vfb *vfb,
+                         const libxl_asyncop_how *ao_how)
+{
+    AO_CREATE(ctx, domid, ao_how);
+    int rc;
+
+    rc = libxl__device_vfb_add(gc, domid, vfb);
+    if (rc) {
+        LOG(ERROR, "unable to add vfb device");
+        goto out;
+    }
+
+out:
+    libxl__ao_complete(egc, ao, rc);
+    return AO_INPROGRESS;
+}
+
+int libxl__device_vfb_add(libxl__gc *gc, uint32_t domid, libxl_device_vfb *vfb)
 {
-    GC_INIT(ctx);
     flexarray_t *front;
     flexarray_t *back;
     libxl__device device;
@@ -3020,7 +3036,6 @@ out_free:
     flexarray_free(front);
     flexarray_free(back);
 out:
-    GC_FREE;
     return rc;
 }
 
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 0a0ba5c..5859c09 100644
--- a/tools/libxl/libxl_create.c
+++ b/tools/libxl/libxl_create.c
@@ -930,7 +930,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 disk devices");
@@ -974,7 +973,7 @@ static void domcreate_launch_dm(libxl__egc *egc, libxl__ao_devices *aodevs,
         libxl__device_console console;
 
         for (i = 0; i < d_config->num_vfbs; i++) {
-            libxl_device_vfb_add(ctx, domid, &d_config->vfbs[i]);
+            libxl__device_vfb_add(gc, domid, &d_config->vfbs[i]);
             libxl__device_vkb_add(gc, domid, &d_config->vkbs[i]);
         }
 
diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c
index 47a812f..f2e9572 100644
--- a/tools/libxl/libxl_dm.c
+++ b/tools/libxl/libxl_dm.c
@@ -902,7 +902,7 @@ static void spawn_stub_launch_dm(libxl__egc *egc,
         if (ret)
             goto out;
     }
-    ret = libxl_device_vfb_add(ctx, dm_domid, &dm_config->vfbs[0]);
+    ret = libxl__device_vfb_add(gc, dm_domid, &dm_config->vfbs[0]);
     if (ret)
         goto out;
     ret = libxl__device_vkb_add(gc, dm_domid, &dm_config->vkbs[0]);
diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
index c075d33..3e91529 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -1948,6 +1948,10 @@ _hidden void libxl__device_nic_add(libxl__egc *egc, uint32_t domid,
 _hidden int libxl__device_vkb_add(libxl__gc *gc, uint32_t domid,
                                   libxl_device_vkb *vkb);
 
+/* Internal function to connect a vfb device */
+_hidden int libxl__device_vfb_add(libxl__gc *gc, uint32_t domid,
+                                  libxl_device_vfb *vfb);
+
 /* 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
diff --git a/tools/ocaml/libs/xl/xenlight_stubs.c b/tools/ocaml/libs/xl/xenlight_stubs.c
index 3d2493b..adda67f 100644
--- a/tools/ocaml/libs/xl/xenlight_stubs.c
+++ b/tools/ocaml/libs/xl/xenlight_stubs.c
@@ -369,7 +369,7 @@ value stub_xl_device_vfb_add(value info, value domid)
 	device_vfb_val(&gc, &lg, &c_info, info);
 
 	INIT_CTX();
-	ret = libxl_device_vfb_add(ctx, Int_val(domid), &c_info);
+	ret = libxl_device_vfb_add(ctx, Int_val(domid), &c_info, 0);
 	if (ret != 0)
 		failwith_xl("vfb_add", &lg);
 	FREE_CTX();
-- 
1.7.7.5 (Apple Git-26)

  parent reply	other threads:[~2012-07-26 14:55 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-26 14:55 [PATCH v13 00/11] execute hotplug scripts from libxl Roger Pau Monne
2012-07-26 14:55 ` [PATCH v13 01/11] libxl: fix removal of secondary consoles Roger Pau Monne
2012-07-26 15:16   ` Ian Jackson
2012-07-26 14:55 ` [PATCH v13 02/11] libxl: refactor disk addition to take a helper Roger Pau Monne
2012-07-26 15:15   ` Ian Jackson
2012-07-26 14:55 ` [PATCH v13 03/11] libxl: convert libxl__device_disk_local_attach to an async op Roger Pau Monne
2012-07-26 14:55 ` [PATCH v13 04/11] libxl: convert libxl_device_disk_add " Roger Pau Monne
2012-07-26 15:33   ` Ian Campbell
2012-07-26 14:55 ` [PATCH v13 05/11] libxl: convert libxl_device_nic_add to an async operation Roger Pau Monne
2012-07-26 14:55 ` [PATCH v13 06/11] libxl: add option to choose who executes hotplug scripts Roger Pau Monne
2012-07-26 14:55 ` [PATCH v13 07/11] libxl: set correct nic type depending on the guest Roger Pau Monne
2012-07-26 15:16   ` Ian Jackson
2012-07-26 14:55 ` [PATCH v13 08/11] libxl: call hotplug scripts for disk devices from libxl Roger Pau Monne
2012-07-26 14:55 ` [PATCH v13 09/11] libxl: call hotplug scripts for nic " Roger Pau Monne
2012-07-26 14:55 ` [PATCH v13 10/11] libxl: convert libxl_device_vkb_add to an async operation Roger Pau Monne
2012-07-26 14:55 ` Roger Pau Monne [this message]
2012-07-26 15:05   ` [PATCH v13 11/11] libxl: convert libxl_device_vfb_add " Ian Campbell
2012-07-26 15:10     ` Roger Pau Monne
2012-07-26 15:48 ` [PATCH v13 00/11] execute hotplug scripts from libxl Ian Campbell

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=1343314522-32298-12-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).