aboutsummaryrefslogtreecommitdiffstats
path: root/tools/libxl
diff options
context:
space:
mode:
authorShriram Rajagopalan <rshriram@cs.ubc.ca>2012-02-09 18:07:48 +0000
committerShriram Rajagopalan <rshriram@cs.ubc.ca>2012-02-09 18:07:48 +0000
commit0cb90b3184ebb05738ee1204e293c5fb265c507f (patch)
tree102515d48f15bb6757cd2b079631973918d28d51 /tools/libxl
parent490d431f99d32c2c700513b59f816729cfa1c1af (diff)
downloadxen-0cb90b3184ebb05738ee1204e293c5fb265c507f.tar.gz
xen-0cb90b3184ebb05738ee1204e293c5fb265c507f.tar.bz2
xen-0cb90b3184ebb05738ee1204e293c5fb265c507f.zip
libxl: helper function to send commands to traditional qemu
Introduce a helper function to send commands to traditional qemu. qemu_pci_add_xenstore, qemu_pci_remove_xenstore, libxl__domain_save_device_model and libxl_domain_unpause have been refactored to use this function. Signed-off-by: Shriram Rajagopalan <rshriram@cs.ubc.ca> Acked-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
Diffstat (limited to 'tools/libxl')
-rw-r--r--tools/libxl/libxl.c2
-rw-r--r--tools/libxl/libxl_dom.c14
-rw-r--r--tools/libxl/libxl_internal.h2
-rw-r--r--tools/libxl/libxl_pci.c8
4 files changed, 16 insertions, 10 deletions
diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
index 6fcd319b58..68bba8f499 100644
--- a/tools/libxl/libxl.c
+++ b/tools/libxl/libxl.c
@@ -586,7 +586,7 @@ int libxl_domain_unpause(libxl_ctx *ctx, uint32_t domid)
path = libxl__sprintf(gc, "/local/domain/0/device-model/%d/state", domid);
state = libxl__xs_read(gc, XBT_NULL, path);
if (state != NULL && !strcmp(state, "paused")) {
- libxl__xs_write(gc, XBT_NULL, libxl__sprintf(gc, "/local/domain/0/device-model/%d/command", domid), "continue");
+ libxl__qemu_traditional_cmd(gc, domid, "continue");
libxl__wait_for_device_model(gc, domid, "running",
NULL, NULL, NULL);
}
diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c
index 692ee30288..efaa86192f 100644
--- a/tools/libxl/libxl_dom.c
+++ b/tools/libxl/libxl_dom.c
@@ -355,6 +355,15 @@ out:
return rc;
}
+int libxl__qemu_traditional_cmd(libxl__gc *gc, uint32_t domid,
+ const char *cmd)
+{
+ char *path = NULL;
+ path = libxl__sprintf(gc, "/local/domain/0/device-model/%d/command",
+ domid);
+ return libxl__xs_write(gc, XBT_NULL, path, "%s", cmd);
+}
+
int libxl__domain_restore_common(libxl__gc *gc, uint32_t domid,
libxl_domain_build_info *info,
libxl__domain_build_state *state,
@@ -637,12 +646,9 @@ int libxl__domain_save_device_model(libxl__gc *gc, uint32_t domid, int fd)
switch (libxl__device_model_version_running(gc, domid)) {
case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL: {
- char *path = NULL;
LIBXL__LOG(ctx, LIBXL__LOG_DEBUG,
"Saving device model state to %s", filename);
- path = libxl__sprintf(gc, "/local/domain/0/device-model/%d/command",
- domid);
- libxl__xs_write(gc, XBT_NULL, path, "save");
+ libxl__qemu_traditional_cmd(gc, domid, "save");
libxl__wait_for_device_model(gc, domid, "paused", NULL, NULL, NULL);
break;
}
diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
index 832cf35a9e..7629ca4082 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -617,6 +617,8 @@ _hidden int libxl__build_hvm(libxl__gc *gc, uint32_t domid,
libxl_domain_build_info *info,
libxl__domain_build_state *state);
+_hidden int libxl__qemu_traditional_cmd(libxl__gc *gc, uint32_t domid,
+ const char *cmd);
_hidden int libxl__domain_rename(libxl__gc *gc, uint32_t domid,
const char *old_name, const char *new_name,
xs_transaction_t trans);
diff --git a/tools/libxl/libxl_pci.c b/tools/libxl/libxl_pci.c
index 99591c27ee..33425f5fe9 100644
--- a/tools/libxl/libxl_pci.c
+++ b/tools/libxl/libxl_pci.c
@@ -602,9 +602,8 @@ static int qemu_pci_add_xenstore(libxl__gc *gc, uint32_t domid,
libxl__xs_write(gc, XBT_NULL, path, PCI_BDF, pcidev->domain,
pcidev->bus, pcidev->dev, pcidev->func);
}
- path = libxl__sprintf(gc, "/local/domain/0/device-model/%d/command",
- domid);
- xs_write(ctx->xsh, XBT_NULL, path, "pci-ins", strlen("pci-ins"));
+
+ libxl__qemu_traditional_cmd(gc, domid, "pci-ins");
rc = libxl__wait_for_device_model(gc, domid, NULL, NULL,
pci_ins_check, state);
path = libxl__sprintf(gc, "/local/domain/0/device-model/%d/parameter",
@@ -857,12 +856,11 @@ static int qemu_pci_remove_xenstore(libxl__gc *gc, uint32_t domid,
path = libxl__sprintf(gc, "/local/domain/0/device-model/%d/parameter", domid);
libxl__xs_write(gc, XBT_NULL, path, PCI_BDF, pcidev->domain,
pcidev->bus, pcidev->dev, pcidev->func);
- path = libxl__sprintf(gc, "/local/domain/0/device-model/%d/command", domid);
/* Remove all functions at once atomically by only signalling
* device-model for function 0 */
if ( !force && (pcidev->vdevfn & 0x7) == 0 ) {
- xs_write(ctx->xsh, XBT_NULL, path, "pci-rem", strlen("pci-rem"));
+ libxl__qemu_traditional_cmd(gc, domid, "pci-rem");
if (libxl__wait_for_device_model(gc, domid, "pci-removed",
NULL, NULL, NULL) < 0) {
LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "Device Model didn't respond in time");