From: Wei Liu <wei.liu2@citrix.com>
To: Anthony PERARD <anthony.perard@citrix.com>
Cc: Xen-devel <xen-devel@lists.xenproject.org>,
Wei Liu <wei.liu2@citrix.com>,
Ian Jackson <Ian.Jackson@eu.citrix.com>
Subject: Re: [PATCH v2 2/3] libxl: update vcpus bitmap in retrieved guest config
Date: Mon, 13 Jun 2016 19:21:53 +0100 [thread overview]
Message-ID: <20160613182153.GC23146@citrix.com> (raw)
In-Reply-To: <20160613173936.GG5666@perard.uk.xensource.com>
On Mon, Jun 13, 2016 at 06:39:36PM +0100, Anthony PERARD wrote:
> On Wed, Jun 08, 2016 at 03:28:45PM +0100, Wei Liu wrote:
> > ... because the available vcpu bitmap can change during domain life time
> > due to cpu hotplug and unplug.
> >
> > For QEMU upstream, we interrogate QEMU for the number of vcpus. For
> > others, we look directly into xenstore for information.
>
> I tried to migrate a guest, and libxl abort in
> libxl_retrieve_domain_configuration within the switch
> (device_model_version).
>
>
> > Reported-by: Jan Beulich <jbeulich@suse.com>
> > Signed-off-by: Wei Liu <wei.liu2@citrix.com>
> > ---
> > tools/libxl/libxl.c | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++++
> > 1 file changed, 87 insertions(+)
> >
> > diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
> > index 006b83f..02706ab 100644
> > --- a/tools/libxl/libxl.c
> > +++ b/tools/libxl/libxl.c
> > @@ -7222,6 +7222,53 @@ void libxl_mac_copy(libxl_ctx *ctx, libxl_mac *dst, libxl_mac *src)
> > (*dst)[i] = (*src)[i];
> > }
> >
> > +static int libxl__update_avail_vcpus_qmp(libxl__gc *gc, uint32_t domid,
> > + unsigned int max_vcpus,
> > + libxl_bitmap *map)
> > +{
> > + int rc;
> > +
> > + /* For QEMU upstream we always need to return the number
> > + * of cpus present to QEMU whether they are online or not;
> > + * otherwise QEMU won't accept the saved state.
> > + */
> > + rc = libxl__qmp_query_cpus(gc, domid, map);
> > + if (rc) {
> > + LOG(ERROR, "fail to get number of cpus for domain %d", domid);
> > + goto out;
> > + }
> > +
> > + rc = 0;
>
> The value should already be 0 at this point.
>
I would like to keep this as-is because this is an idiom that is safer
against further modification of this function.
> > +out:
> > + return rc;
> > +}
> > +
> > +static int libxl__update_avail_vcpus_xenstore(libxl__gc *gc, uint32_t domid,
> > + unsigned int max_vcpus,
> > + libxl_bitmap *map)
> > +{
> > + int rc;
> > + unsigned int i;
> > + const char *dompath;
> > +
> > + dompath = libxl__xs_get_dompath(gc, domid);
> > + if (!dompath) {
> > + rc = ERROR_FAIL;
> > + goto out;
> > + }
> > +
> > + for (i = 0; i < max_vcpus; i++) {
> > + const char *path = GCSPRINTF("%s/cpu/%u/availability", dompath, i);
> > + const char *content = libxl__xs_read(gc, XBT_NULL, path);
> > + if (!strncmp(content, "online", strlen("online")))
>
> I don't think strncmp is usefull here as one of the argument is a plain
> string. One could just use strcmp?
>
Fine by me of course.
> > + libxl_bitmap_set(map, i);
> > + }
> > +
> > + rc = 0;
> > +out:
> > + return rc;
> > +}
> > +
> > int libxl_retrieve_domain_configuration(libxl_ctx *ctx, uint32_t domid,
> > libxl_domain_config *d_config)
> > {
> > @@ -7270,6 +7317,46 @@ int libxl_retrieve_domain_configuration(libxl_ctx *ctx, uint32_t domid,
> > libxl_dominfo_dispose(&info);
> > }
> >
> > + /* VCPUs */
> > + {
> > + libxl_bitmap *map = &d_config->b_info.avail_vcpus;
> > + unsigned int max_vcpus = d_config->b_info.max_vcpus;
> > +
> > + libxl_bitmap_dispose(map);
> > + libxl_bitmap_init(map);
> > + libxl_bitmap_alloc(CTX, map, max_vcpus);
> > + libxl_bitmap_set_none(map);
> > +
> > + switch (d_config->b_info.type) {
> > + case LIBXL_DOMAIN_TYPE_HVM:
> > + switch (d_config->b_info.device_model_version) {
> > + case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN:
> > + rc = libxl__update_avail_vcpus_qmp(gc, domid,
> > + max_vcpus, map);
> > + break;
> > + case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL:
> > + case LIBXL_DEVICE_MODEL_VERSION_NONE:
> > + rc = libxl__update_avail_vcpus_xenstore(gc, domid,
> > + max_vcpus, map);
> > + break;
> > + default:
> > + abort();
>
> Missing indentation for abort.
>
Will fix.
> Also, that is where xl abort on migration.
>
Hmm... This means the device model version is not valid (unknown?).
Can you paste in your guest config?
Wei.
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
next prev parent reply other threads:[~2016-06-13 18:21 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 [this message]
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 ` [PATCH v2 3/3] libxl: only issue cpu-add call to QEMU for not present CPU Wei Liu
2016-06-08 15:01 ` 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=20160613182153.GC23146@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.