xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Ian Jackson <ian.jackson@eu.citrix.com>
To: Wei Liu <wei.liu2@citrix.com>
Cc: Anthony PERARD <anthony.perard@citrix.com>,
	Xen-devel <xen-devel@lists.xenproject.org>
Subject: Re: [PATCH v3 4/5] libxl: update vcpus bitmap in retrieved guest config
Date: Fri, 8 Jul 2016 18:44:28 +0100	[thread overview]
Message-ID: <22399.59004.935094.420724@mariner.uk.xensource.com> (raw)
In-Reply-To: <1465983102-19308-5-git-send-email-wei.liu2@citrix.com>

Wei Liu writes ("[PATCH v3 4/5] libxl: update vcpus bitmap in retrieved guest config"):
> ... 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.
...
> +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.

This comment is confusing to me.  Perhaps `return' should read
`provide' ?  But the connection between the body of this function and
the comment is still obscure.

> +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;
...
> +    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 (!strcmp(content, "online"))
> +            libxl_bitmap_set(map, i);

Firstly, this should be libxl__xs_read_checked.  Secondly if "content"
is NULL, this will crash.

> @@ -7294,6 +7341,55 @@ 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_device_model_version version;
> +
> +        libxl_bitmap_dispose(map);
> +        libxl_bitmap_init(map);
> +        libxl_bitmap_alloc(CTX, map, max_vcpus);
> +        libxl_bitmap_set_none(map);

I see that this function already trashes the domain config when it
fails (leaving it up to the caller to free the partial config) but
that this is not documented :-/.

> +        /* If the user did not explicitly specify a device model
> +         * version, we need to use the same logic used during domain
> +         * creation to derive the device model version.
> +         */
> +        version = d_config->b_info.device_model_version;
> +        if (version == LIBXL_DEVICE_MODEL_VERSION_UNKNOWN)
> +            version = libxl__get_device_model_version(gc, &d_config->b_info);

I think this is rather unfortunate.  Won't changing the default device
model while the domain is running will cause this function to give
wrong answers ?

Thanks,
Ian.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

  parent reply	other threads:[~2016-07-08 17:44 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-15  9:31 [PATCH v3 0/5] libxl: libxl: update available vcpus map in retrieve configuration function Wei Liu
2016-06-15  9:31 ` [PATCH v3 1/5] libxl: libxl_domain_need_memory shouldn't modify b_info Wei Liu
2016-06-15 13:31   ` Dario Faggioli
2016-06-15 13:38     ` Wei Liu
2016-07-08 17:35   ` Ian Jackson
2016-07-11 11:03     ` Wei Liu
2016-06-15  9:31 ` [PATCH v3 2/5] libxl: factor out libxl__get_device_modlel_version Wei Liu
2016-06-15 13:27   ` Dario Faggioli
2016-06-15 17:04   ` Anthony PERARD
2016-07-08 17:37   ` Ian Jackson
2016-06-15  9:31 ` [PATCH v3 3/5] libxl: introduce libxl__qmp_query_cpus Wei Liu
2016-06-15 13:26   ` Dario Faggioli
2016-06-15 16:48   ` Anthony PERARD
2016-07-08 17:45   ` Ian Jackson
2016-06-15  9:31 ` [PATCH v3 4/5] libxl: update vcpus bitmap in retrieved guest config Wei Liu
2016-06-15 17:20   ` Anthony PERARD
2016-07-08 17:44   ` Ian Jackson [this message]
2016-07-11 11:31     ` Wei Liu
2016-07-11 14:59       ` Wei Liu
2016-06-15  9:31 ` [PATCH v3 5/5] libxl: only issue cpu-add call to QEMU for not present CPU Wei Liu
2016-07-08 17:48   ` Ian Jackson
2016-07-11 11:32     ` Wei Liu
2016-07-02 10:22 ` [PATCH v3 0/5] libxl: libxl: update available vcpus map in retrieve configuration function Wei Liu

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=22399.59004.935094.420724@mariner.uk.xensource.com \
    --to=ian.jackson@eu.citrix.com \
    --cc=anthony.perard@citrix.com \
    --cc=wei.liu2@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).