[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 3/5] libxl: use new QEMU xenstore protocol
Originally both QEMU traditional and QEMU upstream used hardcoded /local/domain/0 paths. This patch changes the protocol to use /local/domain/$dm_domid path. For QEMU traditional and upstream without stubdom, $dm_domid is 0 so the path is in fact still /local/domain/0. For QEMU traditional stubdom, this is incompatible protocol change. However QEMU traditional is shipped with Xen so we are allowed to do such change. This change needs to work with corresponding QEMU traditional changeset. There is no compatibility issue with QEMU upstream stubdom, because QEMU upstream stubdom doesn't exist yet. Signed-off-by: Wei Liu <wei.liu2@xxxxxxxxxx> --- tools/libxl/libxl.c | 5 ++++- tools/libxl/libxl_device.c | 5 ++++- tools/libxl/libxl_dm.c | 14 ++++++------- tools/libxl/libxl_dom.c | 51 ++++++++++++++++++++++++++++++---------------- tools/libxl/libxl_pci.c | 29 +++++++++++++++++--------- 5 files changed, 67 insertions(+), 37 deletions(-) diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c index 46a43d5..bccb6cb 100644 --- a/tools/libxl/libxl.c +++ b/tools/libxl/libxl.c @@ -1033,7 +1033,10 @@ int libxl_domain_unpause(libxl_ctx *ctx, uint32_t domid) } if (type == LIBXL_DOMAIN_TYPE_HVM) { - path = libxl__sprintf(gc, "/local/domain/0/device-model/%d/state", domid); + uint32_t dm_domid = libxl_get_stubdom_id(ctx, domid); + + path = GCSPRINTF("/local/domain/%d/device-model/%d/state", + dm_domid, domid); 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_device.c b/tools/libxl/libxl_device.c index 0f50d04..b5a30b4 100644 --- a/tools/libxl/libxl_device.c +++ b/tools/libxl/libxl_device.c @@ -1188,7 +1188,10 @@ int libxl__wait_for_device_model_deprecated(libxl__gc *gc, void *check_callback_userdata) { char *path; - path = GCSPRINTF("/local/domain/0/device-model/%d/state", domid); + uint32_t dm_domid = libxl_get_stubdom_id(CTX, domid); + + path = GCSPRINTF("/local/domain/%d/device-model/%d/state", + dm_domid, domid); 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 3dedad4..4a38455 100644 --- a/tools/libxl/libxl_dm.c +++ b/tools/libxl/libxl_dm.c @@ -998,7 +998,7 @@ void libxl__spawn_stub_dm(libxl__egc *egc, libxl__stub_dm_spawn_state *sdss) libxl_device_vfb *vfb; libxl_device_vkb *vkb; char **args; - struct xs_permissions perm[2]; + struct xs_permissions perm[1]; xs_transaction_t t; /* convenience aliases */ @@ -1106,16 +1106,16 @@ void libxl__spawn_stub_dm(libxl__egc *egc, libxl__stub_dm_spawn_state *sdss) } xs_set_target(ctx->xsh, dm_domid, guest_domid); - perm[0].id = dm_domid; - perm[0].perms = XS_PERM_NONE; - perm[1].id = guest_domid; - perm[1].perms = XS_PERM_READ; + perm[0].id = guest_domid; + perm[0].perms = XS_PERM_READ; retry_transaction: t = xs_transaction_start(ctx->xsh); xs_mkdir(ctx->xsh, t, - libxl__sprintf(gc, "/local/domain/0/device-model/%d", guest_domid)); + libxl__sprintf(gc, "/local/domain/%d/device-model/%d", + dm_domid, guest_domid)); xs_set_permissions(ctx->xsh, t, - libxl__sprintf(gc, "/local/domain/0/device-model/%d", guest_domid), + libxl__sprintf(gc, "/local/domain/%d/device-model/%d", + dm_domid, guest_domid), perm, ARRAY_SIZE(perm)); if (!xs_transaction_end(ctx->xsh, t, 0)) if (errno == EAGAIN) diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c index a16d4a1..1e2d145 100644 --- a/tools/libxl/libxl_dom.c +++ b/tools/libxl/libxl_dom.c @@ -846,7 +846,9 @@ int libxl__qemu_traditional_cmd(libxl__gc *gc, uint32_t domid, const char *cmd) { char *path = NULL; - path = GCSPRINTF("/local/domain/0/device-model/%d/command", domid); + uint32_t dm_domid = libxl_get_stubdom_id(CTX, domid); + path = GCSPRINTF("/local/domain/%d/device-model/%d/command", + dm_domid, domid); return libxl__xs_write(gc, XBT_NULL, path, "%s", cmd); } @@ -860,11 +862,12 @@ struct libxl__physmap_info { #define TOOLSTACK_SAVE_VERSION 1 -static inline char *restore_helper(libxl__gc *gc, uint32_t domid, - uint64_t phys_offset, char *node) +static inline char *restore_helper(libxl__gc *gc, uint32_t dm_domid, + uint32_t domid, + uint64_t phys_offset, char *node) { - return GCSPRINTF("/local/domain/0/device-model/%d/physmap/%"PRIx64"/%s", - domid, phys_offset, node); + return GCSPRINTF("/local/domain/%d/device-model/%d/physmap/%"PRIx64"/%s", + dm_domid, domid, phys_offset, node); } int libxl__toolstack_restore(uint32_t domid, const uint8_t *buf, @@ -878,6 +881,7 @@ int libxl__toolstack_restore(uint32_t domid, const uint8_t *buf, uint32_t count = 0, version = 0; struct libxl__physmap_info* pi; char *xs_path; + uint32_t dm_domid; LOG(DEBUG,"domain=%"PRIu32" toolstack data size=%"PRIu32, domid, size); @@ -903,20 +907,23 @@ int libxl__toolstack_restore(uint32_t domid, const uint8_t *buf, return -1; } + dm_domid = libxl_get_stubdom_id(CTX, domid); for (i = 0; i < count; i++) { pi = (struct libxl__physmap_info*) ptr; ptr += sizeof(struct libxl__physmap_info) + pi->namelen; - xs_path = restore_helper(gc, domid, pi->phys_offset, "start_addr"); + xs_path = restore_helper(gc, dm_domid, domid, + pi->phys_offset, "start_addr"); ret = libxl__xs_write(gc, 0, xs_path, "%"PRIx64, pi->start_addr); if (ret) return -1; - xs_path = restore_helper(gc, domid, pi->phys_offset, "size"); + xs_path = restore_helper(gc, dm_domid, domid, pi->phys_offset, "size"); ret = libxl__xs_write(gc, 0, xs_path, "%"PRIx64, pi->size); if (ret) return -1; if (pi->namelen > 0) { - xs_path = restore_helper(gc, domid, pi->phys_offset, "name"); + xs_path = restore_helper(gc, dm_domid, domid, + pi->phys_offset, "name"); ret = libxl__xs_write(gc, 0, xs_path, "%s", pi->name); if (ret) return -1; @@ -969,10 +976,13 @@ static void domain_suspend_switch_qemu_xen_traditional_logdirty const char *got; if (!lds->cmd_path) { + uint32_t dm_domid = libxl_get_stubdom_id(CTX, domid); lds->cmd_path = GCSPRINTF( - "/local/domain/0/device-model/%u/logdirty/cmd", domid); + "/local/domain/%u/device-model/%u/logdirty/cmd", + dm_domid, domid); lds->ret_path = GCSPRINTF( - "/local/domain/0/device-model/%u/logdirty/ret", domid); + "/local/domain/%u/device-model/%u/logdirty/ret", + dm_domid, domid); } lds->cmd = enable ? "enable" : "disable"; @@ -1491,11 +1501,12 @@ static void domain_suspend_common_done(libxl__egc *egc, dss->callback_common_done(egc, dss, ok); } -static inline char *physmap_path(libxl__gc *gc, uint32_t domid, - char *phys_offset, char *node) +static inline char *physmap_path(libxl__gc *gc, uint32_t dm_domid, + uint32_t domid, + char *phys_offset, char *node) { - return GCSPRINTF("/local/domain/0/device-model/%d/physmap/%s/%s", - domid, phys_offset, node); + return GCSPRINTF("/local/domain/%d/device-model/%d/physmap/%s/%s", + dm_domid, domid, phys_offset, node); } int libxl__toolstack_save(uint32_t domid, uint8_t **buf, @@ -1510,9 +1521,13 @@ int libxl__toolstack_save(uint32_t domid, uint8_t **buf, uint8_t *ptr = NULL; char **entries = NULL; struct libxl__physmap_info *pi; + uint32_t dm_domid; + + dm_domid = libxl_get_stubdom_id(CTX, domid); entries = libxl__xs_directory(gc, 0, GCSPRINTF( - "/local/domain/0/device-model/%d/physmap", domid), &num); + "/local/domain/%d/device-model/%d/physmap", + dm_domid, domid), &num); count = num; *len = sizeof(version) + sizeof(count); @@ -1535,21 +1550,21 @@ int libxl__toolstack_save(uint32_t domid, uint8_t **buf, return -1; } - xs_path = physmap_path(gc, domid, phys_offset, "start_addr"); + xs_path = physmap_path(gc, dm_domid, domid, phys_offset, "start_addr"); start_addr = libxl__xs_read(gc, 0, xs_path); if (start_addr == NULL) { LOG(ERROR, "%s is NULL", xs_path); return -1; } - xs_path = physmap_path(gc, domid, phys_offset, "size"); + xs_path = physmap_path(gc, dm_domid, domid, phys_offset, "size"); size = libxl__xs_read(gc, 0, xs_path); if (size == NULL) { LOG(ERROR, "%s is NULL", xs_path); return -1; } - xs_path = physmap_path(gc, domid, phys_offset, "name"); + xs_path = physmap_path(gc, dm_domid, domid, phys_offset, "name"); name = libxl__xs_read(gc, 0, xs_path); if (name == NULL) namelen = 0; diff --git a/tools/libxl/libxl_pci.c b/tools/libxl/libxl_pci.c index f3ae132..4aeb2bb 100644 --- a/tools/libxl/libxl_pci.c +++ b/tools/libxl/libxl_pci.c @@ -850,11 +850,14 @@ static int qemu_pci_add_xenstore(libxl__gc *gc, uint32_t domid, int rc = 0; char *path; char *state, *vdevfn; + uint32_t dm_domid; - path = libxl__sprintf(gc, "/local/domain/0/device-model/%d/state", domid); + dm_domid = libxl_get_stubdom_id(CTX, domid); + path = libxl__sprintf(gc, "/local/domain/%d/device-model/%d/state", + dm_domid, domid); state = libxl__xs_read(gc, XBT_NULL, path); - path = libxl__sprintf(gc, "/local/domain/0/device-model/%d/parameter", - domid); + path = libxl__sprintf(gc, "/local/domain/%d/device-model/%d/parameter", + dm_domid, domid); if (pcidev->vdevfn) { libxl__xs_write(gc, XBT_NULL, path, PCI_BDF_VDEVFN","PCI_OPTIONS, pcidev->domain, pcidev->bus, pcidev->dev, @@ -869,11 +872,11 @@ 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__sprintf(gc, "/local/domain/0/device-model/%d/parameter", - domid); + path = libxl__sprintf(gc, "/local/domain/%d/device-model/%d/parameter", + dm_domid, domid); vdevfn = libxl__xs_read(gc, XBT_NULL, path); - path = libxl__sprintf(gc, "/local/domain/0/device-model/%d/state", - domid); + path = libxl__sprintf(gc, "/local/domain/%d/device-model/%d/state", + dm_domid, domid); if ( rc < 0 ) LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "qemu refused to add device: %s", vdevfn); @@ -1175,10 +1178,15 @@ static int qemu_pci_remove_xenstore(libxl__gc *gc, uint32_t domid, libxl_ctx *ctx = libxl__gc_owner(gc); char *state; char *path; + uint32_t dm_domid; - path = libxl__sprintf(gc, "/local/domain/0/device-model/%d/state", domid); + dm_domid = libxl_get_stubdom_id(CTX, domid); + + path = libxl__sprintf(gc, "/local/domain/%d/device-model/%d/state", + dm_domid, domid); state = libxl__xs_read(gc, XBT_NULL, path); - path = libxl__sprintf(gc, "/local/domain/0/device-model/%d/parameter", domid); + path = libxl__sprintf(gc, "/local/domain/%d/device-model/%d/parameter", + dm_domid, domid); libxl__xs_write(gc, XBT_NULL, path, PCI_BDF, pcidev->domain, pcidev->bus, pcidev->dev, pcidev->func); @@ -1196,7 +1204,8 @@ static int qemu_pci_remove_xenstore(libxl__gc *gc, uint32_t domid, return ERROR_FAIL; } } - path = libxl__sprintf(gc, "/local/domain/0/device-model/%d/state", domid); + path = libxl__sprintf(gc, "/local/domain/%d/device-model/%d/state", + dm_domid, domid); xs_write(ctx->xsh, XBT_NULL, path, state, strlen(state)); return 0; -- 1.9.1 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |