From: Anthony PERARD <anthony.perard@citrix.com>
To: Xen Devel <xen-devel@lists.xen.org>
Cc: Anthony PERARD <anthony.perard@citrix.com>,
Stefano Stabellini <stefano.stabellini@citrix.com>,
Ian Campbell <ian.campbell@citrix.com>
Subject: [PATCH v4 2/2] libxl: Use QMP cpu-add to hotplug CPU with qemu-xen.
Date: Tue, 25 Jun 2013 11:07:53 +0100 [thread overview]
Message-ID: <1372154873-25790-3-git-send-email-anthony.perard@citrix.com> (raw)
In-Reply-To: <1372154873-25790-1-git-send-email-anthony.perard@citrix.com>
Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
---
Change: ignore qmp_cpu_add return value.
---
tools/libxl/libxl.c | 47 +++++++++++++++++++++++++++++++++++++++++------
1 file changed, 41 insertions(+), 6 deletions(-)
diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
index ee1fa9c..858a18d 100644
--- a/tools/libxl/libxl.c
+++ b/tools/libxl/libxl.c
@@ -4237,33 +4237,68 @@ 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)) {
+ 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;
}
--
Anthony PERARD
next prev parent reply other threads:[~2013-06-25 10:07 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-25 10:07 [PATCH v4 0/2] CPU hotplug for qemu-xen Anthony PERARD
2013-06-25 10:07 ` [PATCH v4 1/2] libxl: Add "cpu-add" QMP command Anthony PERARD
2013-06-25 10:07 ` Anthony PERARD [this message]
2013-06-26 10:56 ` [PATCH v4 2/2] libxl: Use QMP cpu-add to hotplug CPU with qemu-xen George Dunlap
2013-06-26 13:56 ` Ian Campbell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1372154873-25790-3-git-send-email-anthony.perard@citrix.com \
--to=anthony.perard@citrix.com \
--cc=ian.campbell@citrix.com \
--cc=stefano.stabellini@citrix.com \
--cc=xen-devel@lists.xen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).