[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v12 14/17] libxl: convert libxl_device_vkb_add to an async operation
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. Changes since v11: * libxl__device_vkb_add is no longer an ao operation. Changes since v9: * Fixed Ocaml bindings. * Don't abort if num_vkbs > 0. Cc: Ian Jackson <ian.jackson@xxxxxxxxxxxxx> Signed-off-by: Roger Pau Monne <roger.pau@xxxxxxxxxx> --- tools/libxl/libxl.c | 22 +++++++++++++++++++--- tools/libxl/libxl.h | 3 ++- tools/libxl/libxl_create.c | 4 ++-- tools/libxl/libxl_dm.c | 2 +- tools/libxl/libxl_internal.h | 4 ++++ tools/ocaml/libs/xl/xenlight_stubs.c | 2 +- 6 files changed, 29 insertions(+), 8 deletions(-) diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c index 14793f3..8d82526 100644 --- a/tools/libxl/libxl.c +++ b/tools/libxl/libxl.c @@ -2840,9 +2840,26 @@ 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) +int libxl_device_vkb_add(libxl_ctx *ctx, uint32_t domid, libxl_device_vkb *vkb, + const libxl_asyncop_how *ao_how) +{ + AO_CREATE(ctx, domid, ao_how); + int rc; + + rc = libxl__device_vkb_add(gc, domid, vkb); + if (rc) { + LOG(ERROR, "unable to add vkb device"); + goto out; + } + +out: + libxl__ao_complete(egc, ao, rc); + return AO_INPROGRESS; +} + +int libxl__device_vkb_add(libxl__gc *gc, uint32_t domid, + libxl_device_vkb *vkb) { - GC_INIT(ctx); flexarray_t *front; flexarray_t *back; libxl__device device; @@ -2887,7 +2904,6 @@ out_free: flexarray_free(back); flexarray_free(front); out: - GC_FREE; return rc; } 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 1cacfad..0a0ba5c 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -958,7 +958,7 @@ static void domcreate_launch_dm(libxl__egc *egc, libxl__ao_devices *aodevs, libxl__device_console_dispose(&console); libxl_device_vkb_init(&vkb); - libxl_device_vkb_add(ctx, domid, &vkb); + libxl__device_vkb_add(gc, domid, &vkb); libxl_device_vkb_dispose(&vkb); dcs->dmss.dm.guest_domid = domid; @@ -975,7 +975,7 @@ 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]); + libxl__device_vkb_add(gc, domid, &d_config->vkbs[i]); } ret = init_console_info(&console, 0); diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c index 606cc29..47a812f 100644 --- a/tools/libxl/libxl_dm.c +++ b/tools/libxl/libxl_dm.c @@ -905,7 +905,7 @@ 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]); + ret = libxl__device_vkb_add(gc, dm_domid, &dm_config->vkbs[0]); if (ret) goto out; diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index be6ca49..1e2d96b 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -1909,6 +1909,10 @@ _hidden void libxl__device_nic_add(libxl__egc *egc, uint32_t domid, libxl_device_nic *nic, libxl__ao_device *aodev); +/* Internal function to connect a vkb device */ +_hidden int libxl__device_vkb_add(libxl__gc *gc, uint32_t domid, + libxl_device_vkb *vkb); + /* 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 0e9c65e..3d2493b 100644 --- a/tools/ocaml/libs/xl/xenlight_stubs.c +++ b/tools/ocaml/libs/xl/xenlight_stubs.c @@ -315,7 +315,7 @@ value stub_xl_device_vkb_add(value info, value domid) device_vkb_val(&gc, &lg, &c_info, info); INIT_CTX(); - ret = libxl_device_vkb_add(ctx, Int_val(domid), &c_info); + ret = libxl_device_vkb_add(ctx, Int_val(domid), &c_info, 0); if (ret != 0) failwith_xl("vkb_add", &lg); FREE_CTX(); -- 1.7.7.5 (Apple Git-26) _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |