aboutsummaryrefslogtreecommitdiffstats
path: root/tools/libxl
diff options
context:
space:
mode:
authorAnthony PERARD <anthony.perard@citrix.com>2013-06-26 16:54:31 +0100
committerIan Campbell <ian.campbell@citrix.com>2013-06-26 17:47:16 +0100
commit62fe11fbd8ceac1700c3494f1de4c688e6a118c1 (patch)
treee5aa809f48e9e9eba596c08d7d72dad6d3ee5352 /tools/libxl
parent3275031240b372d0f8c97f9662dec6b54e78c594 (diff)
downloadxen-62fe11fbd8ceac1700c3494f1de4c688e6a118c1.tar.gz
xen-62fe11fbd8ceac1700c3494f1de4c688e6a118c1.tar.bz2
xen-62fe11fbd8ceac1700c3494f1de4c688e6a118c1.zip
libxl: Use QMP cpu-add to hotplug CPU with qemu-xen.
Signed-off-by: Anthony PERARD <anthony.perard@citrix.com> Reviewed-by: George Dunlap <george.dunlap@eu.citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com>
Diffstat (limited to 'tools/libxl')
-rw-r--r--tools/libxl/libxl.c52
1 files changed, 46 insertions, 6 deletions
diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
index 1bbb990d29..3236aa96a0 100644
--- a/tools/libxl/libxl.c
+++ b/tools/libxl/libxl.c
@@ -4247,33 +4247,73 @@ int libxl_domain_get_nodeaffinity(libxl_ctx *ctx, uint32_t domid,
return 0;
}
-int libxl_set_vcpuonline(libxl_ctx *ctx, uint32_t domid, libxl_bitmap *cpumap)
+static int libxl__set_vcpuonline_xenstore(libxl__gc *gc, uint32_t domid,
+ libxl_bitmap *cpumap)
{
- GC_INIT(ctx);
libxl_dominfo info;
char *dompath;
xs_transaction_t t;
int i, rc = ERROR_FAIL;
- if (libxl_domain_info(ctx, &info, domid) < 0) {
- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "getting domain info list");
+ if (libxl_domain_info(CTX, &info, domid) < 0) {
+ LOGE(ERROR, "getting domain info list");
goto out;
}
if (!(dompath = libxl__xs_get_dompath(gc, domid)))
goto out;
retry_transaction:
- t = xs_transaction_start(ctx->xsh);
+ t = xs_transaction_start(CTX->xsh);
for (i = 0; i <= info.vcpu_max_id; i++)
libxl__xs_write(gc, t,
libxl__sprintf(gc, "%s/cpu/%u/availability", dompath, i),
"%s", libxl_bitmap_test(cpumap, i) ? "online" : "offline");
- if (!xs_transaction_end(ctx->xsh, t, 0)) {
+ if (!xs_transaction_end(CTX->xsh, t, 0)) {
if (errno == EAGAIN)
goto retry_transaction;
} else
rc = 0;
out:
+ return rc;
+}
+
+static int libxl__set_vcpuonline_qmp(libxl__gc *gc, uint32_t domid,
+ libxl_bitmap *cpumap)
+{
+ libxl_dominfo info;
+ int i;
+
+ if (libxl_domain_info(CTX, &info, domid) < 0) {
+ LOGE(ERROR, "getting domain info list");
+ return ERROR_FAIL;
+ }
+ for (i = 0; i <= info.vcpu_max_id; i++) {
+ if (libxl_bitmap_test(cpumap, i)) {
+ /* Return value is ignore because it does not tell anything useful
+ * on the completion of the command.
+ * (For instance, "CPU already plugged-in" give the same return
+ * value as "command not supported".)
+ */
+ libxl__qmp_cpu_add(gc, domid, i);
+ }
+ }
+ return 0;
+}
+
+int libxl_set_vcpuonline(libxl_ctx *ctx, uint32_t domid, libxl_bitmap *cpumap)
+{
+ GC_INIT(ctx);
+ int rc;
+ switch (libxl__device_model_version_running(gc, domid)) {
+ case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL:
+ rc = libxl__set_vcpuonline_xenstore(gc, domid, cpumap);
+ break;
+ case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN:
+ rc = libxl__set_vcpuonline_qmp(gc, domid, cpumap);
+ break;
+ default:
+ rc = ERROR_INVAL;
+ }
GC_FREE;
return rc;
}