We are going to want to talk to two different qemus for some domains. This will involve a different xenstore path for the two qemus, so libxl__device_model_xs_path will need to take a parameter to say which.
Most call sites will want to talk to the main (device model, `DM') emulator. So introduce that parameter now, currently always passing EMUID_DM, which is defined in a dummy way that ensures the actual argument is EMUID_DM. No functional change. Signed-off-by: Stefano Stabellini <stefano.stabell...@eu.citrix.com> Signed-off-by: Ian Jackson <ian.jack...@eu.citrix.com> --- v6: Largely rewritten, but in some sense (at least conceptually) based on a similar concept in v5. --- tools/libxl/libxl_device.c | 3 ++- tools/libxl/libxl_dm.c | 11 ++++++----- tools/libxl/libxl_dom.c | 12 +++++++----- tools/libxl/libxl_dom_suspend.c | 3 ++- tools/libxl/libxl_internal.c | 4 +++- tools/libxl/libxl_internal.h | 9 ++++++--- tools/libxl/libxl_pci.c | 4 ++-- 7 files changed, 28 insertions(+), 18 deletions(-) diff --git a/tools/libxl/libxl_device.c b/tools/libxl/libxl_device.c index 8bb5e93..22665e4 100644 --- a/tools/libxl/libxl_device.c +++ b/tools/libxl/libxl_device.c @@ -1183,7 +1183,8 @@ 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, dm_domid, domid, + EMUID_DM, "/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 6f5fe45..ea82e11 100644 --- a/tools/libxl/libxl_dm.c +++ b/tools/libxl/libxl_dm.c @@ -1558,7 +1558,7 @@ void libxl__spawn_stub_dm(libxl__egc *egc, libxl__stub_dm_spawn_state *sdss) retry_transaction: t = xs_transaction_start(ctx->xsh); const char *dmpath = libxl__device_model_xs_path(gc, - dm_domid, guest_domid, ""); + dm_domid, guest_domid, EMUID_DM, ""); xs_mkdir(ctx->xsh, t, dmpath); xs_set_permissions(ctx->xsh, t, dmpath, @@ -1724,7 +1724,7 @@ static void stubdom_pvqemu_cb(libxl__egc *egc, dm_domid, sdss->dm.guest_domid); sdss->xswait.path = libxl__device_model_xs_path(gc, dm_domid, sdss->dm.guest_domid, - "/state"); + EMUID_DM, "/state"); sdss->xswait.timeout_ms = LIBXL_STUBDOM_START_TIMEOUT * 1000; sdss->xswait.callback = stubdom_xswait_cb; rc = libxl__xswait_start(gc, &sdss->xswait); @@ -1831,7 +1831,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, LIBXL_TOOLSTACK_DOMID, + domid, EMUID_DM, ""); xs_mkdir(ctx->xsh, XBT_NULL, path); if (b_info->type == LIBXL_DOMAIN_TYPE_HVM && @@ -1886,7 +1887,7 @@ retry_transaction: spawn->what = GCSPRINTF("domain %d device model", domid); spawn->xspath = libxl__device_model_xs_path(gc, LIBXL_TOOLSTACK_DOMID, - domid, "/state"); + domid, EMUID_DM, "/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; @@ -2099,7 +2100,7 @@ out: int libxl__destroy_device_model(libxl__gc *gc, uint32_t domid) { char *path = libxl__device_model_xs_path(gc, LIBXL_TOOLSTACK_DOMID, - domid, ""); + domid, EMUID_DM, ""); if (!xs_rm(CTX->xsh, XBT_NULL, path)) LOG(ERROR, "xs_rm failed for %s", path); /* We should try to destroy the device model anyway. */ diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c index 47971a9..6ded9c1 100644 --- a/tools/libxl/libxl_dom.c +++ b/tools/libxl/libxl_dom.c @@ -1103,7 +1103,8 @@ 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, dm_domid, + domid, EMUID_DM, "/command"); return libxl__xs_printf(gc, XBT_NULL, path, "%s", cmd); } @@ -1134,7 +1135,8 @@ int libxl__restore_emulator_xenstore_data(libxl__domain_create_state *dcs, const uint32_t domid = dcs->guest_domid; const uint32_t dm_domid = libxl_get_stubdom_id(CTX, domid); - const char *xs_root = libxl__device_model_xs_path(gc, dm_domid, domid, ""); + const char *xs_root = libxl__device_model_xs_path(gc, dm_domid, + domid, EMUID_DM, ""); while (next < end) { key = next; @@ -1225,9 +1227,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, - "/logdirty/cmd"); + EMUID_DM, "/logdirty/cmd"); lds->ret_path = libxl__device_model_xs_path(gc, dm_domid, domid, - "/logdirty/ret"); + EMUID_DM, "/logdirty/ret"); } lds->cmd = enable ? "enable" : "disable"; @@ -1442,7 +1444,7 @@ int libxl__save_emulator_xenstore_data(libxl__domain_suspend_state *dss, const uint32_t domid = dss->domid; const uint32_t dm_domid = libxl_get_stubdom_id(CTX, domid); - xs_root = libxl__device_model_xs_path(gc, dm_domid, domid, ""); + xs_root = libxl__device_model_xs_path(gc, dm_domid, domid, EMUID_DM, ""); entries = libxl__xs_directory(gc, 0, GCSPRINTF("%s/physmap", xs_root), &nr_entries); diff --git a/tools/libxl/libxl_dom_suspend.c b/tools/libxl/libxl_dom_suspend.c index 3313ad1..d25fb59 100644 --- a/tools/libxl/libxl_dom_suspend.c +++ b/tools/libxl/libxl_dom_suspend.c @@ -383,7 +383,8 @@ int libxl__domain_resume_device_model(libxl__gc *gc, uint32_t domid) case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL: { 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, dm_domid, domid, + EMUID_DM, "/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_internal.c b/tools/libxl/libxl_internal.c index 328046b..ec93797 100644 --- a/tools/libxl/libxl_internal.c +++ b/tools/libxl/libxl_internal.c @@ -554,7 +554,9 @@ void libxl__update_domain_configuration(libxl__gc *gc, } char *libxl__device_model_xs_path(libxl__gc *gc, uint32_t dm_domid, - uint32_t domid, const char *format, ...) + uint32_t domid, + struct dummy_qemu_emulator_id emuid, + const char *format, ...) { char *s, *fmt; va_list ap; diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index fd6ef61..ea56cda 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -1955,9 +1955,12 @@ _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); + +static const struct dummy_qemu_emulator_id { int x; } EMUID_DM; +_hidden char *libxl__device_model_xs_path(libxl__gc *gc, + uint32_t dm_domid, + uint32_t domid, struct dummy_qemu_emulator_id, + const char *format, ...) PRINTF_ATTRIBUTE(5, 6); /* * Calling context and GC for event-generating functions: diff --git a/tools/libxl/libxl_pci.c b/tools/libxl/libxl_pci.c index 2c7a2c6..86b8cf3 100644 --- a/tools/libxl/libxl_pci.c +++ b/tools/libxl/libxl_pci.c @@ -967,7 +967,7 @@ static int qemu_pci_add_xenstore(libxl__gc *gc, uint32_t domid, uint32_t dm_domid; #define DMPATH(suffix) \ - libxl__device_model_xs_path(gc, dm_domid, domid, (suffix)) + libxl__device_model_xs_path(gc, dm_domid, domid, EMUID_DM, (suffix)) dm_domid = libxl_get_stubdom_id(CTX, domid); path = DMPATH("/state"); @@ -1313,7 +1313,7 @@ static int qemu_pci_remove_xenstore(libxl__gc *gc, uint32_t domid, dm_domid = libxl_get_stubdom_id(CTX, domid); #define DMPATH(suffix) \ - libxl__device_model_xs_path(gc, dm_domid, domid, suffix) + libxl__device_model_xs_path(gc, dm_domid, domid, EMUID_DM, suffix) path = DMPATH("/state"); state = libxl__xs_read(gc, XBT_NULL, path); -- 1.7.10.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel