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 v10 18/19] libxl: convert libxl_device_vfb_add to an async operation
Date: Fri, 20 Jul 2012 15:12:27 +0100 [thread overview]
Message-ID: <1342793548-10239-19-git-send-email-roger.pau@citrix.com> (raw)
In-Reply-To: <1342793548-10239-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 v9:
* Fixed Ocaml bindings.
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Signed-off-by: Roger Pau Monne <roger.pau@citrix.com>
---
tools/libxl/libxl.c | 26 +++++++++++++++++++-------
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 +++++++++
tools/ocaml/libs/xl/xenlight_stubs.c | 2 +-
7 files changed, 42 insertions(+), 19 deletions(-)
diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
index 7de82a9..412794f 100644
--- a/tools/libxl/libxl.c
+++ b/tools/libxl/libxl.c
@@ -2923,12 +2923,13 @@ 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;
+ libxl__device *device;
int rc;
rc = libxl__device_vfb_setdefault(gc, vfb);
@@ -2945,7 +2946,8 @@ int libxl_device_vfb_add(libxl_ctx *ctx, uint32_t domid, libxl_device_vfb *vfb)
goto out_free;
}
- rc = libxl__device_from_vfb(gc, domid, vfb, &device);
+ GCNEW(device);
+ rc = libxl__device_from_vfb(gc, domid, vfb, device);
if (rc != 0) goto out_free;
flexarray_append_pair(back, "frontend-id", libxl__sprintf(gc, "%d", domid));
@@ -2975,16 +2977,22 @@ int libxl_device_vfb_add(libxl_ctx *ctx, uint32_t domid, libxl_device_vfb *vfb)
libxl__sprintf(gc, "%d", vfb->backend_domid));
flexarray_append_pair(front, "state", libxl__sprintf(gc, "%d", 1));
- libxl__device_generic_add(gc, XBT_NULL, &device,
+ libxl__device_generic_add(gc, XBT_NULL, device,
libxl__xs_kvs_of_flexarray(gc, back, back->count),
libxl__xs_kvs_of_flexarray(gc, front, front->count));
+
+ aodev->dev = device;
+ aodev->action = DEVICE_CONNECT;
+ libxl__wait_device_connection(egc, aodev);
+
rc = 0;
out_free:
flexarray_free(front);
flexarray_free(back);
out:
- GC_FREE;
- return rc;
+ aodev->rc = rc;
+ if (rc) aodev->callback(egc, aodev);
+ return;
}
/******************************************************************************/
@@ -3055,6 +3063,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) \
@@ -3084,6 +3093,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 39c858a..03edb3d 100644
--- a/tools/libxl/libxl_create.c
+++ b/tools/libxl/libxl_create.c
@@ -910,12 +910,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;
@@ -935,7 +938,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");
@@ -971,10 +973,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 65cd264..f9c8784 100644
--- a/tools/libxl/libxl_device.c
+++ b/tools/libxl/libxl_device.c
@@ -483,6 +483,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) \
@@ -503,6 +504,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 41c5e5b..d02c5ef 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -1914,6 +1914,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
@@ -2338,6 +2343,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. */
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)
next prev parent reply other threads:[~2012-07-20 14:12 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-20 14:12 [PATCH v10 01/19] execute hotplug scripts from libxl v10 Roger Pau Monne
2012-07-20 14:12 ` [PATCH v10 01/19] libxl: check backend state before setting it to "closing" Roger Pau Monne
2012-07-20 14:12 ` [PATCH v10 02/19] libxl: change ao_device_remove to ao_device Roger Pau Monne
2012-07-20 16:35 ` Ian Jackson
2012-07-20 14:12 ` [PATCH v10 03/19] libxl: move device model creation prototypes Roger Pau Monne
2012-07-20 14:12 ` [PATCH v10 04/19] libxl: convert libxl_domain_destroy to an async op Roger Pau Monne
2012-07-20 14:12 ` [PATCH v10 05/19] libxl: move bootloader data strucutres and prototypes Roger Pau Monne
2012-07-20 17:21 ` Ian Jackson
2012-07-20 14:12 ` [PATCH v10 06/19] libxl: refactor disk addition to take a helper Roger Pau Monne
2012-07-20 17:24 ` Ian Jackson
2012-07-20 14:12 ` [PATCH v10 07/19] libxl: convert libxl__device_disk_local_attach to an async op Roger Pau Monne
2012-07-20 18:03 ` Ian Jackson
2012-07-23 11:32 ` Roger Pau Monne
2012-07-20 14:12 ` [PATCH v10 08/19] libxl: rename vifs to nics Roger Pau Monne
2012-07-20 14:12 ` [PATCH v10 09/19] libxl: convert libxl_device_disk_add to an async op Roger Pau Monne
2012-07-20 18:04 ` Ian Jackson
2012-07-20 14:12 ` [PATCH v10 10/19] libxl: convert libxl_device_nic_add to an async operation Roger Pau Monne
2012-07-20 14:12 ` [PATCH v10 11/19] libxl: add option to choose who executes hotplug scripts Roger Pau Monne
2012-07-20 14:12 ` [PATCH v10 12/19] libxl: rename _IOEMU nic type to VIF_IOEMU Roger Pau Monne
2012-07-20 16:34 ` Ian Campbell
2012-07-20 16:39 ` Ian Campbell
2012-07-20 14:12 ` [PATCH v10 13/19] libxl: set correct nic type depending on the guest Roger Pau Monne
2012-07-20 18:06 ` Ian Jackson
2012-07-20 14:12 ` [PATCH v10 14/19] libxl: use libxl__xs_path_cleanup on device_destroy Roger Pau Monne
2012-07-20 15:38 ` Ian Campbell
2012-07-20 14:12 ` [PATCH v10 15/19] libxl: call hotplug scripts for disk devices from libxl Roger Pau Monne
2012-07-20 15:20 ` Ian Campbell
2012-07-20 14:12 ` [PATCH v10 16/19] libxl: call hotplug scripts for nic " Roger Pau Monne
2012-07-20 16:01 ` Ian Campbell
2012-07-20 16:12 ` Ian Campbell
2012-07-20 16:36 ` Ian Campbell
2012-07-23 9:22 ` Roger Pau Monne
2012-07-20 16:03 ` Ian Campbell
2012-07-20 14:12 ` [PATCH v10 17/19] libxl: convert libxl_device_vkb_add to an async operation Roger Pau Monne
2012-07-20 18:08 ` Ian Jackson
2012-07-23 8:58 ` Roger Pau Monne
2012-07-23 9:26 ` Ian Campbell
2012-07-23 11:44 ` Ian Jackson
2012-07-20 14:12 ` Roger Pau Monne [this message]
2012-07-20 18:11 ` [PATCH v10 18/19] libxl: convert libxl_device_vfb_add " Ian Jackson
2012-07-23 11:58 ` Roger Pau Monne
2012-07-20 14:12 ` [PATCH v10 19/19] xl: main_blockdetach don't call destroy if remove succeeds Roger Pau Monne
2012-07-20 14:55 ` Ian Campbell
2012-07-23 12:17 ` [PATCH v10 01/19] execute hotplug scripts from libxl v10 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=1342793548-10239-19-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).