From mboxrd@z Thu Jan 1 00:00:00 1970 From: Anthony PERARD Subject: [PATCH v3 2/2] libxl: Use QMP cpu-add to hotplug CPU with qemu-xen. Date: Mon, 24 Jun 2013 14:33:00 +0100 Message-ID: <1372080780-17379-3-git-send-email-anthony.perard@citrix.com> References: <1372080780-17379-1-git-send-email-anthony.perard@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1372080780-17379-1-git-send-email-anthony.perard@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Xen Devel Cc: Anthony PERARD , Stefano Stabellini , Ian Campbell List-Id: xen-devel@lists.xenproject.org Signed-off-by: Anthony PERARD --- tools/libxl/libxl.c | 49 +++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 43 insertions(+), 6 deletions(-) diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c index ee1fa9c..95214ed 100644 --- a/tools/libxl/libxl.c +++ b/tools/libxl/libxl.c @@ -4237,33 +4237,70 @@ 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, rc = 0; + + if (libxl_domain_info(CTX, &info, domid) < 0) { + LOGE(ERROR, "getting domain info list"); + rc = ERROR_FAIL; + goto out; + } + for (i = 0; i <= info.vcpu_max_id; i++) { + if (libxl_bitmap_test(cpumap, i)) { + rc = libxl__qmp_cpu_add(gc, domid, i); + } + } +out: + return rc; +} + +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; } -- Anthony PERARD