[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v3 4/6] libxl: change xs path for QEMU
Change the QEMU xenstore watch path to /local/domain/$LIBXL_TOOLSTACK_DOMID/device-model/$DOMID/$EMULATOR_ID. Currently two emulator_ids are statically allocated: one for device models and one for pv qemus. Add a parameter to libxl__device_model_xs_path to distinguish the device model from the pv backends provider. Store the device model binary path under /local/domain/$DOMID/device-model on xenstore, so that we can fetch it later and retrieve the list of supported options from /local/domain/$LIBXL_TOOLSTACK_DOMID/libxl/$device_model_binary, introduce in the previous path. Signed-off-by: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx> --- Changes in v3: - use LIBXL_TOOLSTACK_DOMID instead of 0 in the commit message - change xs path to include the emulator_id --- tools/libxl/libxl.c | 2 +- tools/libxl/libxl_create.c | 3 +++ tools/libxl/libxl_device.c | 2 +- tools/libxl/libxl_dm.c | 18 ++++++++++-------- tools/libxl/libxl_dom.c | 12 ++++++------ tools/libxl/libxl_internal.c | 19 +++++++++++++++---- tools/libxl/libxl_internal.h | 5 ++--- tools/libxl/libxl_pci.c | 14 +++++++------- 8 files changed, 45 insertions(+), 30 deletions(-) diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c index 516713e..bca4c88 100644 --- a/tools/libxl/libxl.c +++ b/tools/libxl/libxl.c @@ -1035,7 +1035,7 @@ int libxl_domain_unpause(libxl_ctx *ctx, uint32_t domid) if (type == LIBXL_DOMAIN_TYPE_HVM) { uint32_t dm_domid = libxl_get_stubdom_id(ctx, domid); - path = libxl__device_model_xs_path(gc, dm_domid, domid, "/state"); + path = libxl__device_model_xs_path(gc, false, dm_domid, domid, "/state"); state = libxl__xs_read(gc, XBT_NULL, path); if (state != NULL && !strcmp(state, "paused")) { libxl__qemu_traditional_cmd(gc, domid, "continue"); diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c index a74b340..df946e2 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -1002,6 +1002,9 @@ static void domcreate_bootloader_done(libxl__egc *egc, return; } + libxl__xs_write(gc, XBT_NULL, GCSPRINTF("/local/domain/%u/device-model", domid), + "%s", libxl__domain_device_model(gc, info)); + /* consume bootloader outputs. state->pv_{kernel,ramdisk} have * been initialised by the bootloader already. */ diff --git a/tools/libxl/libxl_device.c b/tools/libxl/libxl_device.c index 93bb41e..aadcd08 100644 --- a/tools/libxl/libxl_device.c +++ b/tools/libxl/libxl_device.c @@ -1190,7 +1190,7 @@ int libxl__wait_for_device_model_deprecated(libxl__gc *gc, char *path; uint32_t dm_domid = libxl_get_stubdom_id(CTX, domid); - path = libxl__device_model_xs_path(gc, dm_domid, domid, "/state"); + path = libxl__device_model_xs_path(gc, false, dm_domid, domid, "/state"); return libxl__xenstore_child_wait_deprecated(gc, domid, LIBXL_DEVICE_MODEL_START_TIMEOUT, "Device Model", path, state, spawning, diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c index bf77f50..7015729 100644 --- a/tools/libxl/libxl_dm.c +++ b/tools/libxl/libxl_dm.c @@ -1271,9 +1271,9 @@ void libxl__spawn_stub_dm(libxl__egc *egc, libxl__stub_dm_spawn_state *sdss) retry_transaction: t = xs_transaction_start(ctx->xsh); xs_mkdir(ctx->xsh, t, - libxl__device_model_xs_path(gc, dm_domid, guest_domid, "")); + libxl__device_model_xs_path(gc, false, dm_domid, guest_domid, "")); xs_set_permissions(ctx->xsh, t, - libxl__device_model_xs_path(gc, dm_domid, + libxl__device_model_xs_path(gc, false, dm_domid, guest_domid, ""), perm, ARRAY_SIZE(perm)); if (!xs_transaction_end(ctx->xsh, t, 0)) @@ -1434,7 +1434,7 @@ static void stubdom_pvqemu_cb(libxl__egc *egc, sdss->xswait.what = GCSPRINTF("Stubdom %u for %u startup", dm_domid, sdss->dm.guest_domid); sdss->xswait.path = - libxl__device_model_xs_path(gc, dm_domid, sdss->dm.guest_domid, + libxl__device_model_xs_path(gc, true, dm_domid, sdss->dm.guest_domid, "/state"); sdss->xswait.timeout_ms = LIBXL_STUBDOM_START_TIMEOUT * 1000; sdss->xswait.callback = stubdom_xswait_cb; @@ -1570,7 +1570,8 @@ void libxl__spawn_local_dm(libxl__egc *egc, libxl__dm_spawn_state *dmss) free(path); } - path = libxl__device_model_xs_path(gc, LIBXL_TOOLSTACK_DOMID, domid, ""); + path = libxl__device_model_xs_path(gc, b_info->type == LIBXL_DOMAIN_TYPE_PV, + LIBXL_TOOLSTACK_DOMID, domid, ""); if (b_info->device_model_version == LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN) { rwperm[0].id = LIBXL_TOOLSTACK_DOMID; rwperm[0].perms = XS_PERM_NONE; @@ -1627,8 +1628,9 @@ retry_transaction: LIBXL__LOG(CTX, XTL_DEBUG, " %s", *arg); spawn->what = GCSPRINTF("domain %d device model", domid); - spawn->xspath = libxl__device_model_xs_path(gc, LIBXL_TOOLSTACK_DOMID, - domid, "/state"); + spawn->xspath = libxl__device_model_xs_path(gc, + b_info->type == LIBXL_DOMAIN_TYPE_PV, LIBXL_TOOLSTACK_DOMID, + domid, "/state"); spawn->timeout_ms = LIBXL_DEVICE_MODEL_START_TIMEOUT * 1000; spawn->pidpath = GCSPRINTF("%s/image/device-model-pid", dom_path); spawn->midproc_cb = libxl__spawn_record_pid; @@ -1761,7 +1763,7 @@ void libxl__spawn_qdisk_backend(libxl__egc *egc, libxl__dm_spawn_state *dmss) dmss->build_state->saved_state = 0; dmss->spawn.what = GCSPRINTF("domain %u Qdisk backend", domid); - dmss->spawn.xspath = GCSPRINTF("device-model/%u/state", domid); + dmss->spawn.xspath = libxl__device_model_xs_path(gc, true, 0, domid, "/state"); dmss->spawn.timeout_ms = LIBXL_DEVICE_MODEL_START_TIMEOUT * 1000; /* * We cannot save Qemu pid anywhere in the xenstore guest dir, @@ -1844,7 +1846,7 @@ out: int libxl__destroy_device_model(libxl__gc *gc, uint32_t domid) { - char *path = libxl__device_model_xs_path(gc, LIBXL_TOOLSTACK_DOMID, + char *path = libxl__device_model_xs_path(gc, false, LIBXL_TOOLSTACK_DOMID, domid, ""); if (!xs_rm(CTX->xsh, XBT_NULL, path)) LOG(ERROR, "xs_rm failed for %s", path); diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c index 34b3c54..0f15a90 100644 --- a/tools/libxl/libxl_dom.c +++ b/tools/libxl/libxl_dom.c @@ -1016,7 +1016,7 @@ int libxl__qemu_traditional_cmd(libxl__gc *gc, uint32_t domid, { char *path = NULL; uint32_t dm_domid = libxl_get_stubdom_id(CTX, domid); - path = libxl__device_model_xs_path(gc, dm_domid, domid, "/command"); + path = libxl__device_model_xs_path(gc, false, dm_domid, domid, "/command"); return libxl__xs_write(gc, XBT_NULL, path, "%s", cmd); } @@ -1034,7 +1034,7 @@ static inline char *restore_helper(libxl__gc *gc, uint32_t dm_domid, uint32_t domid, uint64_t phys_offset, char *node) { - return libxl__device_model_xs_path(gc, dm_domid, domid, + return libxl__device_model_xs_path(gc, false, dm_domid, domid, "/physmap/%"PRIx64"/%s", phys_offset, node); } @@ -1146,9 +1146,9 @@ static void domain_suspend_switch_qemu_xen_traditional_logdirty if (!lds->cmd_path) { uint32_t dm_domid = libxl_get_stubdom_id(CTX, domid); - lds->cmd_path = libxl__device_model_xs_path(gc, dm_domid, domid, + lds->cmd_path = libxl__device_model_xs_path(gc, false, dm_domid, domid, "/logdirty/cmd"); - lds->ret_path = libxl__device_model_xs_path(gc, dm_domid, domid, + lds->ret_path = libxl__device_model_xs_path(gc, false, dm_domid, domid, "/logdirty/ret"); } lds->cmd = enable ? "enable" : "disable"; @@ -1672,7 +1672,7 @@ static inline char *physmap_path(libxl__gc *gc, uint32_t dm_domid, uint32_t domid, char *phys_offset, char *node) { - return libxl__device_model_xs_path(gc, dm_domid, domid, + return libxl__device_model_xs_path(gc, false, dm_domid, domid, "/physmap/%s/%s", phys_offset, node); } @@ -1696,7 +1696,7 @@ int libxl__toolstack_save(uint32_t domid, uint8_t **buf, dm_domid = libxl_get_stubdom_id(CTX, domid); entries = libxl__xs_directory(gc, 0, - libxl__device_model_xs_path(gc, dm_domid, domid, "/physmap"), + libxl__device_model_xs_path(gc, false, dm_domid, domid, "/physmap"), &num); count = num; diff --git a/tools/libxl/libxl_internal.c b/tools/libxl/libxl_internal.c index c2c67bd..5836742 100644 --- a/tools/libxl/libxl_internal.c +++ b/tools/libxl/libxl_internal.c @@ -567,14 +567,25 @@ void libxl__update_domain_configuration(libxl__gc *gc, dst->b_info.video_memkb = src->b_info.video_memkb; } -char *libxl__device_model_xs_path(libxl__gc *gc, uint32_t dm_domid, +char *libxl__device_model_xs_path(libxl__gc *gc, bool pvqemu, uint32_t dm_domid, uint32_t domid, const char *format, ...) { char *s, *fmt; va_list ap; - - fmt = GCSPRINTF("/local/domain/%u/device-model/%u%s", dm_domid, - domid, format); + char *dm; + int emulator_id = 0; + + dm = libxl__xs_read(gc, XBT_NULL, GCSPRINTF("/local/domain/%u/device-model", domid)); + if (dm) + emulator_id = libxl__check_qemu_supported(gc, dm, "emulator_id"); + + if (!emulator_id) { + fmt = GCSPRINTF("/local/domain/%u/device-model/%u%s", dm_domid, + domid, format); + } else { + fmt = GCSPRINTF("/local/domain/%u/device-model/%u/%u%s", dm_domid, + domid, pvqemu ? QEMU_XEN_PV_ID : QEMU_XEN_DEVICE_MODEL_ID, format); + } va_start(ap, format); s = libxl__vsprintf(gc, fmt, ap); diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index b4bae2f..e15cdc7 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -1830,9 +1830,8 @@ _hidden libxl__json_object *libxl__json_parse(libxl__gc *gc_opt, const char *s); _hidden int libxl__device_model_version_running(libxl__gc *gc, uint32_t domid); /* Return the system-wide default device model */ _hidden libxl_device_model_version libxl__default_device_model(libxl__gc *gc); -_hidden char *libxl__device_model_xs_path(libxl__gc *gc, uint32_t dm_domid, - uint32_t domid, - const char *format, ...) PRINTF_ATTRIBUTE(4, 5); +_hidden char *libxl__device_model_xs_path(libxl__gc *gc, bool pvqemu, uint32_t dm_domid, + uint32_t domid, const char *format, ...); /* Check how executes hotplug script currently */ int libxl__hotplug_settings(libxl__gc *gc, xs_transaction_t t); diff --git a/tools/libxl/libxl_pci.c b/tools/libxl/libxl_pci.c index e0743f8..07f6209 100644 --- a/tools/libxl/libxl_pci.c +++ b/tools/libxl/libxl_pci.c @@ -853,9 +853,9 @@ static int qemu_pci_add_xenstore(libxl__gc *gc, uint32_t domid, uint32_t dm_domid; dm_domid = libxl_get_stubdom_id(CTX, domid); - path = libxl__device_model_xs_path(gc, dm_domid, domid, "/state"); + path = libxl__device_model_xs_path(gc, false, dm_domid, domid, "/state"); state = libxl__xs_read(gc, XBT_NULL, path); - path = libxl__device_model_xs_path(gc, dm_domid, domid, "/parameter"); + path = libxl__device_model_xs_path(gc, false, dm_domid, domid, "/parameter"); if (pcidev->vdevfn) { libxl__xs_write(gc, XBT_NULL, path, PCI_BDF_VDEVFN","PCI_OPTIONS, pcidev->domain, pcidev->bus, pcidev->dev, @@ -870,9 +870,9 @@ static int qemu_pci_add_xenstore(libxl__gc *gc, uint32_t domid, libxl__qemu_traditional_cmd(gc, domid, "pci-ins"); rc = libxl__wait_for_device_model_deprecated(gc, domid, NULL, NULL, pci_ins_check, state); - path = libxl__device_model_xs_path(gc, dm_domid, domid, "/parameter"); + path = libxl__device_model_xs_path(gc, false, dm_domid, domid, "/parameter"); vdevfn = libxl__xs_read(gc, XBT_NULL, path); - path = libxl__device_model_xs_path(gc, dm_domid, domid, "/state"); + path = libxl__device_model_xs_path(gc, false, dm_domid, domid, "/state"); if ( rc < 0 ) LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "qemu refused to add device: %s", vdevfn); @@ -1178,9 +1178,9 @@ static int qemu_pci_remove_xenstore(libxl__gc *gc, uint32_t domid, dm_domid = libxl_get_stubdom_id(CTX, domid); - path = libxl__device_model_xs_path(gc, dm_domid, domid, "/state"); + path = libxl__device_model_xs_path(gc, false, dm_domid, domid, "/state"); state = libxl__xs_read(gc, XBT_NULL, path); - path = libxl__device_model_xs_path(gc, dm_domid, domid, "/parameter"); + path = libxl__device_model_xs_path(gc, false, dm_domid, domid, "/parameter"); libxl__xs_write(gc, XBT_NULL, path, PCI_BDF, pcidev->domain, pcidev->bus, pcidev->dev, pcidev->func); @@ -1198,7 +1198,7 @@ static int qemu_pci_remove_xenstore(libxl__gc *gc, uint32_t domid, return ERROR_FAIL; } } - path = libxl__device_model_xs_path(gc, dm_domid, domid, "/state"); + path = libxl__device_model_xs_path(gc, false, dm_domid, domid, "/state"); xs_write(ctx->xsh, XBT_NULL, path, state, strlen(state)); return 0; -- 1.7.10.4 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |