From: Wei Liu <wei.liu2@citrix.com>
To: Xen-devel <xen-devel@lists.xenproject.org>
Cc: Anthony PERARD <anthony.perard@citrix.com>,
Wei Liu <wei.liu2@citrix.com>,
Ian Jackson <Ian.Jackson@eu.citrix.com>
Subject: [PATCH v2 3/3] libxl: only issue cpu-add call to QEMU for not present CPU
Date: Wed, 8 Jun 2016 15:28:46 +0100 [thread overview]
Message-ID: <1465396126-27426-4-git-send-email-wei.liu2@citrix.com> (raw)
In-Reply-To: <1465396126-27426-1-git-send-email-wei.liu2@citrix.com>
Calculate the final bitmap for CPUs to add to avoid having annoying
error messages complaining those CPUs are already present.
We can also properly handle error from QMP now.
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
---
tools/libxl/libxl.c | 39 +++++++++++++++++++++++++++++----------
1 file changed, 29 insertions(+), 10 deletions(-)
diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
index 02706ab..62a7ade 100644
--- a/tools/libxl/libxl.c
+++ b/tools/libxl/libxl.c
@@ -5740,19 +5740,38 @@ static int libxl__set_vcpuonline_qmp(libxl__gc *gc, uint32_t domid,
libxl_bitmap *cpumap,
const libxl_dominfo *info)
{
- int i;
+ int i, rc;
+ libxl_bitmap current_map, final_map;
+
+ libxl_bitmap_init(¤t_map);
+ libxl_bitmap_init(&final_map);
+
+ libxl_bitmap_alloc(CTX, ¤t_map, info->vcpu_max_id + 1);
+ libxl_bitmap_set_none(¤t_map);
+ rc = libxl__qmp_query_cpus(gc, domid, ¤t_map);
+ if (rc) {
+ LOG(ERROR, "failed to query cpus for domain %d", domid);
+ goto out;
+ }
+
+ libxl_bitmap_copy_alloc(CTX, &final_map, cpumap);
- 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);
+ libxl_for_each_set_bit(i, current_map)
+ libxl_bitmap_reset(&final_map, i);
+
+ libxl_for_each_set_bit(i, final_map) {
+ rc = libxl__qmp_cpu_add(gc, domid, i);
+ if (rc) {
+ LOG(ERROR, "failed to add cpu %d to domain %d", i, domid);
+ goto out;
}
}
- return 0;
+
+ rc = 0;
+out:
+ libxl_bitmap_dispose(¤t_map);
+ libxl_bitmap_dispose(&final_map);
+ return rc;
}
int libxl_set_vcpuonline(libxl_ctx *ctx, uint32_t domid, libxl_bitmap *cpumap)
--
2.1.4
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
next prev parent reply other threads:[~2016-06-08 14:47 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-08 14:28 [PATCH v2 0/3] libxl: libxl: update available vcpus map in retrieve configuration function Wei Liu
2016-06-08 14:28 ` [PATCH v2 1/3] libxl: introduce libxl__qmp_query_cpus Wei Liu
2016-06-09 0:12 ` Dario Faggioli
2016-06-13 16:52 ` Anthony PERARD
2016-06-13 18:17 ` Wei Liu
2016-06-08 14:28 ` [PATCH v2 2/3] libxl: update vcpus bitmap in retrieved guest config Wei Liu
2016-06-09 0:11 ` Dario Faggioli
2016-06-13 17:39 ` Anthony PERARD
2016-06-13 18:21 ` Wei Liu
2016-06-14 10:47 ` Anthony PERARD
2016-06-14 10:50 ` Wei Liu
2016-06-14 10:58 ` Anthony PERARD
2016-06-14 11:00 ` Wei Liu
2016-06-14 16:27 ` Ian Jackson
2016-06-14 13:20 ` Anthony PERARD
2016-06-08 14:28 ` Wei Liu [this message]
2016-06-08 15:01 ` [PATCH v2 3/3] libxl: only issue cpu-add call to QEMU for not present CPU Jan Beulich
2016-06-13 17:47 ` Anthony PERARD
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=1465396126-27426-4-git-send-email-wei.liu2@citrix.com \
--to=wei.liu2@citrix.com \
--cc=Ian.Jackson@eu.citrix.com \
--cc=anthony.perard@citrix.com \
--cc=xen-devel@lists.xenproject.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).