xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] libxl: update available vcpus map in retrieve configuration function
@ 2016-06-07 11:23 Wei Liu
  2016-06-07 11:24 ` [PATCH 1/3] libxl: introduce libxl__json_array_count Wei Liu
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Wei Liu @ 2016-06-07 11:23 UTC (permalink / raw)
  To: Xen-devel
  Cc: Anthony PERARD, Wei Liu, Stefano Stabellini, Ian Jackson, Jan Beulich

Wei Liu (3):
  libxl: introduce libxl__json_array_count
  libxl: introduce libxl__qmp_query_cpus
  libxl: update vcpus bitmap in retrieved guest config

 tools/libxl/libxl.c          | 91 ++++++++++++++++++++++++++++++++++++++++++++
 tools/libxl/libxl_internal.h |  4 ++
 tools/libxl/libxl_json.c     | 11 ++++++
 tools/libxl/libxl_qmp.c      | 19 +++++++++
 4 files changed, 125 insertions(+)

-- 
2.1.4


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

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 1/3] libxl: introduce libxl__json_array_count
  2016-06-07 11:23 [PATCH 0/3] libxl: update available vcpus map in retrieve configuration function Wei Liu
@ 2016-06-07 11:24 ` Wei Liu
  2016-06-07 11:24 ` [PATCH 2/3] libxl: introduce libxl__qmp_query_cpus Wei Liu
  2016-06-07 11:24 ` [PATCH 3/3] libxl: update vcpus bitmap in retrieved guest config Wei Liu
  2 siblings, 0 replies; 13+ messages in thread
From: Wei Liu @ 2016-06-07 11:24 UTC (permalink / raw)
  To: Xen-devel
  Cc: Anthony PERARD, Wei Liu, Stefano Stabellini, Ian Jackson, Jan Beulich

It returns the number of elements in a json array.

It will be used later.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
---
 tools/libxl/libxl_internal.h |  1 +
 tools/libxl/libxl_json.c     | 11 +++++++++++
 2 files changed, 12 insertions(+)

diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
index ae16c25..38ec54d 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -1979,6 +1979,7 @@ _hidden int libxl__json_object_append_to(libxl__gc *gc_opt,
                                          libxl__yajl_ctx *ctx);
 _hidden libxl__json_object *libxl__json_array_get(const libxl__json_object *o,
                                                   int i);
+_hidden unsigned int libxl__json_array_count(const libxl__json_object *o);
 _hidden
 libxl__json_map_node *libxl__json_map_node_get(const libxl__json_object *o,
                                                int i);
diff --git a/tools/libxl/libxl_json.c b/tools/libxl/libxl_json.c
index b60ae2b..3b744fb 100644
--- a/tools/libxl/libxl_json.c
+++ b/tools/libxl/libxl_json.c
@@ -546,6 +546,17 @@ void libxl__json_object_free(libxl__gc *gc, libxl__json_object *obj)
     free(obj);
 }
 
+unsigned int libxl__json_array_count(const libxl__json_object *o)
+{
+    flexarray_t *array = NULL;
+
+    assert(libxl__json_object_is_array(o));
+    array = libxl__json_object_get_array(o);
+    assert(array);
+
+    return array->count;
+}
+
 libxl__json_object *libxl__json_array_get(const libxl__json_object *o, int i)
 {
     flexarray_t *array = NULL;
-- 
2.1.4


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

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 2/3] libxl: introduce libxl__qmp_query_cpus
  2016-06-07 11:23 [PATCH 0/3] libxl: update available vcpus map in retrieve configuration function Wei Liu
  2016-06-07 11:24 ` [PATCH 1/3] libxl: introduce libxl__json_array_count Wei Liu
@ 2016-06-07 11:24 ` Wei Liu
  2016-06-07 11:24 ` [PATCH 3/3] libxl: update vcpus bitmap in retrieved guest config Wei Liu
  2 siblings, 0 replies; 13+ messages in thread
From: Wei Liu @ 2016-06-07 11:24 UTC (permalink / raw)
  To: Xen-devel
  Cc: Anthony PERARD, Wei Liu, Stefano Stabellini, Ian Jackson, Jan Beulich

It interrogates QEMU for the number of cpus.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
---
 tools/libxl/libxl_internal.h |  3 +++
 tools/libxl/libxl_qmp.c      | 19 +++++++++++++++++++
 2 files changed, 22 insertions(+)

diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
index 38ec54d..5c22b97 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -1794,6 +1794,9 @@ _hidden int libxl__qmp_set_global_dirty_log(libxl__gc *gc, int domid, bool enabl
 _hidden int libxl__qmp_insert_cdrom(libxl__gc *gc, int domid, const libxl_device_disk *disk);
 /* Add a virtual CPU */
 _hidden int libxl__qmp_cpu_add(libxl__gc *gc, int domid, int index);
+/* Query the number of CPUs */
+_hidden int libxl__qmp_query_cpus(libxl__gc *gc, int domid,
+                                  unsigned int *count);
 /* Start NBD server */
 _hidden int libxl__qmp_nbd_server_start(libxl__gc *gc, int domid,
                                         const char *host, const char *port);
diff --git a/tools/libxl/libxl_qmp.c b/tools/libxl/libxl_qmp.c
index 3eb279a..b9de867 100644
--- a/tools/libxl/libxl_qmp.c
+++ b/tools/libxl/libxl_qmp.c
@@ -979,6 +979,25 @@ int libxl__qmp_cpu_add(libxl__gc *gc, int domid, int idx)
     return qmp_run_command(gc, domid, "cpu-add", args, NULL, NULL);
 }
 
+static int query_cpus_callback(libxl__qmp_handler *qmp,
+                               const libxl__json_object *response,
+                               void *opaque)
+{
+    unsigned int *count = opaque;
+    GC_INIT(qmp->ctx);
+
+    *count = libxl__json_array_count(response);
+
+    GC_FREE;
+    return 0;
+}
+
+int libxl__qmp_query_cpus(libxl__gc *gc, int domid, unsigned int *count)
+{
+    return qmp_run_command(gc, domid, "query-cpus", NULL,
+                           query_cpus_callback, count);
+}
+
 int libxl__qmp_nbd_server_start(libxl__gc *gc, int domid,
                                 const char *host, const char *port)
 {
-- 
2.1.4


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

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 3/3] libxl: update vcpus bitmap in retrieved guest config
  2016-06-07 11:23 [PATCH 0/3] libxl: update available vcpus map in retrieve configuration function Wei Liu
  2016-06-07 11:24 ` [PATCH 1/3] libxl: introduce libxl__json_array_count Wei Liu
  2016-06-07 11:24 ` [PATCH 2/3] libxl: introduce libxl__qmp_query_cpus Wei Liu
@ 2016-06-07 11:24 ` Wei Liu
  2016-06-07 14:45   ` Anthony PERARD
  2016-06-14 16:31   ` Ian Jackson
  2 siblings, 2 replies; 13+ messages in thread
From: Wei Liu @ 2016-06-07 11:24 UTC (permalink / raw)
  To: Xen-devel
  Cc: Anthony PERARD, Wei Liu, Stefano Stabellini, Ian Jackson, Jan Beulich

... 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.

Reported-by: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
---
 tools/libxl/libxl.c | 91 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 91 insertions(+)

diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
index 006b83f..4f8b663 100644
--- a/tools/libxl/libxl.c
+++ b/tools/libxl/libxl.c
@@ -7222,6 +7222,57 @@ 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)
+{
+    unsigned int count, i;
+    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, &count);
+    if (rc) {
+        LOG(ERROR, "fail to get number of cpus for domain %d", domid);
+        goto out;
+    }
+
+    for (i = 0; i < count; i++)
+        libxl_bitmap_set(map, i);
+
+    rc = 0;
+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")))
+            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 +7321,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();
+            }
+            break;
+        case LIBXL_DOMAIN_TYPE_PV:
+            rc = libxl__update_avail_vcpus_xenstore(gc, domid,
+                                                    max_vcpus, map);
+            break;
+        default:
+            abort();
+        }
+
+        if (rc) {
+            LOG(ERROR, "fail to update available cpu map for domain %d", domid);
+            goto out;
+        }
+    }
+
     /* Memory limits:
      *
      * Currently there are three memory limits:
-- 
2.1.4


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

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 3/3] libxl: update vcpus bitmap in retrieved guest config
  2016-06-07 11:24 ` [PATCH 3/3] libxl: update vcpus bitmap in retrieved guest config Wei Liu
@ 2016-06-07 14:45   ` Anthony PERARD
  2016-06-07 16:03     ` Wei Liu
  2016-06-14 16:31   ` Ian Jackson
  1 sibling, 1 reply; 13+ messages in thread
From: Anthony PERARD @ 2016-06-07 14:45 UTC (permalink / raw)
  To: Wei Liu; +Cc: Xen-devel, Stefano Stabellini, Ian Jackson, Jan Beulich

On Tue, Jun 07, 2016 at 12:24:02PM +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.
> 
> Reported-by: Jan Beulich <jbeulich@suse.com>
> Signed-off-by: Wei Liu <wei.liu2@citrix.com>
> ---
>  tools/libxl/libxl.c | 91 +++++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 91 insertions(+)
> 
> diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
> index 006b83f..4f8b663 100644
> --- a/tools/libxl/libxl.c
> +++ b/tools/libxl/libxl.c
> @@ -7222,6 +7222,57 @@ 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)
> +{
> +    unsigned int count, i;
> +    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, &count);
> +    if (rc) {
> +        LOG(ERROR, "fail to get number of cpus for domain %d", domid);
> +        goto out;
> +    }
> +
> +    for (i = 0; i < count; i++)
> +        libxl_bitmap_set(map, i);

What if I have cpu 1, 7 and 42 online, but all the other offline?

-- 
Anthony PERARD

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

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 3/3] libxl: update vcpus bitmap in retrieved guest config
  2016-06-07 14:45   ` Anthony PERARD
@ 2016-06-07 16:03     ` Wei Liu
  2016-06-07 16:22       ` Dario Faggioli
  2016-06-07 16:36       ` Anthony PERARD
  0 siblings, 2 replies; 13+ messages in thread
From: Wei Liu @ 2016-06-07 16:03 UTC (permalink / raw)
  To: Anthony PERARD
  Cc: Xen-devel, Stefano Stabellini, Wei Liu, Ian Jackson, Jan Beulich

On Tue, Jun 07, 2016 at 03:45:29PM +0100, Anthony PERARD wrote:
> On Tue, Jun 07, 2016 at 12:24:02PM +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.
> > 
> > Reported-by: Jan Beulich <jbeulich@suse.com>
> > Signed-off-by: Wei Liu <wei.liu2@citrix.com>
> > ---
> >  tools/libxl/libxl.c | 91 +++++++++++++++++++++++++++++++++++++++++++++++++++++
> >  1 file changed, 91 insertions(+)
> > 
> > diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
> > index 006b83f..4f8b663 100644
> > --- a/tools/libxl/libxl.c
> > +++ b/tools/libxl/libxl.c
> > @@ -7222,6 +7222,57 @@ 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)
> > +{
> > +    unsigned int count, i;
> > +    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, &count);
> > +    if (rc) {
> > +        LOG(ERROR, "fail to get number of cpus for domain %d", domid);
> > +        goto out;
> > +    }
> > +
> > +    for (i = 0; i < count; i++)
> > +        libxl_bitmap_set(map, i);
> 
> What if I have cpu 1, 7 and 42 online, but all the other offline?
> 

I have more or less the same question when I wrote this patch. At that
time I thought the avail_vcpus was only used for generating -smp option
to QEMU.

In your example, you will have -smp 3,maxvcpus=$Y. I think the migration
should still succeed. Furthermore, the cpu-add operation doesn't care,
so it probably won't have visible effect.

I agree it would be good to set the exact bits though -- if you can tell
me which field to test. 


-> { "execute": "query-cpus" }
<- {
      "return":[
         {
            "CPU":0,
            "current":true,
            "halted":false,
            "qom_path":"/machine/unattached/device[0]",
            "arch":"x86",
            "pc":3227107138,
            "thread_id":3134
         },
         {
            "CPU":1,
            "current":false,
            "halted":true,
            "qom_path":"/machine/unattached/device[2]",
            "arch":"x86",
            "pc":7108165,
            "thread_id":3135
         }
      ]
   }
EQMP

Wei.

> -- 
> Anthony PERARD

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

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 3/3] libxl: update vcpus bitmap in retrieved guest config
  2016-06-07 16:03     ` Wei Liu
@ 2016-06-07 16:22       ` Dario Faggioli
  2016-06-07 16:46         ` Wei Liu
  2016-06-07 16:36       ` Anthony PERARD
  1 sibling, 1 reply; 13+ messages in thread
From: Dario Faggioli @ 2016-06-07 16:22 UTC (permalink / raw)
  To: Wei Liu, Anthony PERARD
  Cc: Xen-devel, Stefano Stabellini, Ian Jackson, Jan Beulich


[-- Attachment #1.1: Type: text/plain, Size: 2269 bytes --]

On Tue, 2016-06-07 at 17:03 +0100, Wei Liu wrote:
> On Tue, Jun 07, 2016 at 03:45:29PM +0100, Anthony PERARD wrote:
> > 
> > > --- a/tools/libxl/libxl.c
> > > +++ b/tools/libxl/libxl.c
> > > @@ -7222,6 +7222,57 @@ 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)
> > > +{
> > > +    unsigned int count, i;
> > > +    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, &count);
> > > +    if (rc) {
> > > +        LOG(ERROR, "fail to get number of cpus for domain %d",
> > > domid);
> > > +        goto out;
> > > +    }
> > > +
> > > +    for (i = 0; i < count; i++)
> > > +        libxl_bitmap_set(map, i);
> > What if I have cpu 1, 7 and 42 online, but all the other offline?
> > 
> I have more or less the same question when I wrote this patch. At
> that
> time I thought the avail_vcpus was only used for generating -smp
> option
> to QEMU.
> 
> In your example, you will have -smp 3,maxvcpus=$Y. I think the
> migration
> should still succeed. Furthermore, the cpu-add operation doesn't
> care,
> so it probably won't have visible effect.
> 
> I agree it would be good to set the exact bits though -- if you can
> tell
> me which field to test. 
> 
Perhaps at least mention something about all this either in a comment
or in the changelog?

Regards,
Dario
-- 
<<This happens because I choose it to happen!>> (Raistlin Majere)
-----------------------------------------------------------------
Dario Faggioli, Ph.D, http://about.me/dario.faggioli
Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)


[-- Attachment #1.2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

[-- Attachment #2: Type: text/plain, Size: 126 bytes --]

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

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 3/3] libxl: update vcpus bitmap in retrieved guest config
  2016-06-07 16:03     ` Wei Liu
  2016-06-07 16:22       ` Dario Faggioli
@ 2016-06-07 16:36       ` Anthony PERARD
  2016-06-07 16:39         ` Wei Liu
  1 sibling, 1 reply; 13+ messages in thread
From: Anthony PERARD @ 2016-06-07 16:36 UTC (permalink / raw)
  To: Wei Liu; +Cc: Xen-devel, Stefano Stabellini, Ian Jackson, Jan Beulich

On Tue, Jun 07, 2016 at 05:03:07PM +0100, Wei Liu wrote:
> On Tue, Jun 07, 2016 at 03:45:29PM +0100, Anthony PERARD wrote:
> > On Tue, Jun 07, 2016 at 12:24:02PM +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.
> > > 
> > > Reported-by: Jan Beulich <jbeulich@suse.com>
> > > Signed-off-by: Wei Liu <wei.liu2@citrix.com>
> > > ---
> > >  tools/libxl/libxl.c | 91 +++++++++++++++++++++++++++++++++++++++++++++++++++++
> > >  1 file changed, 91 insertions(+)
> > > 
> > > diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
> > > index 006b83f..4f8b663 100644
> > > --- a/tools/libxl/libxl.c
> > > +++ b/tools/libxl/libxl.c
> > > @@ -7222,6 +7222,57 @@ 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)
> > > +{
> > > +    unsigned int count, i;
> > > +    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, &count);
> > > +    if (rc) {
> > > +        LOG(ERROR, "fail to get number of cpus for domain %d", domid);
> > > +        goto out;
> > > +    }
> > > +
> > > +    for (i = 0; i < count; i++)
> > > +        libxl_bitmap_set(map, i);
> > 
> > What if I have cpu 1, 7 and 42 online, but all the other offline?
> > 
> 
> I have more or less the same question when I wrote this patch. At that
> time I thought the avail_vcpus was only used for generating -smp option
> to QEMU.

Right, and -smp does not let you set a bitmap... I guess having a count
for this purpose is enough.

> In your example, you will have -smp 3,maxvcpus=$Y. I think the migration
> should still succeed. Furthermore, the cpu-add operation doesn't care,
> so it probably won't have visible effect.

What does cpu-add not care about?

> I agree it would be good to set the exact bits though -- if you can tell
> me which field to test. 
> 

From the example below, I guess it would be "CPU".

> 
> -> { "execute": "query-cpus" }
> <- {
>       "return":[
>          {
>             "CPU":0,
>             "current":true,
>             "halted":false,
>             "qom_path":"/machine/unattached/device[0]",
>             "arch":"x86",
>             "pc":3227107138,
>             "thread_id":3134
>          },
>          {
>             "CPU":1,
>             "current":false,
>             "halted":true,
>             "qom_path":"/machine/unattached/device[2]",
>             "arch":"x86",
>             "pc":7108165,
>             "thread_id":3135
>          }
>       ]
>    }
> EQMP

-- 
Anthony PERARD

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

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 3/3] libxl: update vcpus bitmap in retrieved guest config
  2016-06-07 16:36       ` Anthony PERARD
@ 2016-06-07 16:39         ` Wei Liu
  0 siblings, 0 replies; 13+ messages in thread
From: Wei Liu @ 2016-06-07 16:39 UTC (permalink / raw)
  To: Anthony PERARD
  Cc: Xen-devel, Stefano Stabellini, Wei Liu, Ian Jackson, Jan Beulich

On Tue, Jun 07, 2016 at 05:36:05PM +0100, Anthony PERARD wrote:
> On Tue, Jun 07, 2016 at 05:03:07PM +0100, Wei Liu wrote:
> > On Tue, Jun 07, 2016 at 03:45:29PM +0100, Anthony PERARD wrote:
> > > On Tue, Jun 07, 2016 at 12:24:02PM +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.
> > > > 
> > > > Reported-by: Jan Beulich <jbeulich@suse.com>
> > > > Signed-off-by: Wei Liu <wei.liu2@citrix.com>
> > > > ---
> > > >  tools/libxl/libxl.c | 91 +++++++++++++++++++++++++++++++++++++++++++++++++++++
> > > >  1 file changed, 91 insertions(+)
> > > > 
> > > > diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
> > > > index 006b83f..4f8b663 100644
> > > > --- a/tools/libxl/libxl.c
> > > > +++ b/tools/libxl/libxl.c
> > > > @@ -7222,6 +7222,57 @@ 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)
> > > > +{
> > > > +    unsigned int count, i;
> > > > +    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, &count);
> > > > +    if (rc) {
> > > > +        LOG(ERROR, "fail to get number of cpus for domain %d", domid);
> > > > +        goto out;
> > > > +    }
> > > > +
> > > > +    for (i = 0; i < count; i++)
> > > > +        libxl_bitmap_set(map, i);
> > > 
> > > What if I have cpu 1, 7 and 42 online, but all the other offline?
> > > 
> > 
> > I have more or less the same question when I wrote this patch. At that
> > time I thought the avail_vcpus was only used for generating -smp option
> > to QEMU.
> 
> Right, and -smp does not let you set a bitmap... I guess having a count
> for this purpose is enough.
> 
> > In your example, you will have -smp 3,maxvcpus=$Y. I think the migration
> > should still succeed. Furthermore, the cpu-add operation doesn't care,
> > so it probably won't have visible effect.
> 
> What does cpu-add not care about?
> 

Never mind. This is too wrong to explain. I was thinking about some
other stuff when writing that.

The libxl API does care about the bitmap, but QEMU parameter doesn't.

> > I agree it would be good to set the exact bits though -- if you can tell
> > me which field to test. 
> > 
> 
> From the example below, I guess it would be "CPU".

Sounds good to me.

Wei.

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

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 3/3] libxl: update vcpus bitmap in retrieved guest config
  2016-06-07 16:22       ` Dario Faggioli
@ 2016-06-07 16:46         ` Wei Liu
  2016-06-07 17:05           ` Dario Faggioli
  0 siblings, 1 reply; 13+ messages in thread
From: Wei Liu @ 2016-06-07 16:46 UTC (permalink / raw)
  To: Dario Faggioli
  Cc: Stefano Stabellini, Wei Liu, Ian Jackson, Jan Beulich,
	Anthony PERARD, Xen-devel

On Tue, Jun 07, 2016 at 06:22:27PM +0200, Dario Faggioli wrote:
> On Tue, 2016-06-07 at 17:03 +0100, Wei Liu wrote:
> > On Tue, Jun 07, 2016 at 03:45:29PM +0100, Anthony PERARD wrote:
> > > 
> > > > --- a/tools/libxl/libxl.c
> > > > +++ b/tools/libxl/libxl.c
> > > > @@ -7222,6 +7222,57 @@ 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)
> > > > +{
> > > > +    unsigned int count, i;
> > > > +    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, &count);
> > > > +    if (rc) {
> > > > +        LOG(ERROR, "fail to get number of cpus for domain %d",
> > > > domid);
> > > > +        goto out;
> > > > +    }
> > > > +
> > > > +    for (i = 0; i < count; i++)
> > > > +        libxl_bitmap_set(map, i);
> > > What if I have cpu 1, 7 and 42 online, but all the other offline?
> > > 
> > I have more or less the same question when I wrote this patch. At
> > that
> > time I thought the avail_vcpus was only used for generating -smp
> > option
> > to QEMU.
> > 
> > In your example, you will have -smp 3,maxvcpus=$Y. I think the
> > migration
> > should still succeed. Furthermore, the cpu-add operation doesn't
> > care,
> > so it probably won't have visible effect.
> > 
> > I agree it would be good to set the exact bits though -- if you can
> > tell
> > me which field to test. 
> > 
> Perhaps at least mention something about all this either in a comment
> or in the changelog?
> 

What would you like to see in a comment? I guess this is now moot
because the exact bits will be set.

Wei.

> Regards,
> Dario
> -- 
> <<This happens because I choose it to happen!>> (Raistlin Majere)
> -----------------------------------------------------------------
> Dario Faggioli, Ph.D, http://about.me/dario.faggioli
> Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)
> 



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

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 3/3] libxl: update vcpus bitmap in retrieved guest config
  2016-06-07 16:46         ` Wei Liu
@ 2016-06-07 17:05           ` Dario Faggioli
  0 siblings, 0 replies; 13+ messages in thread
From: Dario Faggioli @ 2016-06-07 17:05 UTC (permalink / raw)
  To: Wei Liu
  Cc: Anthony PERARD, Xen-devel, Stefano Stabellini, Ian Jackson, Jan Beulich


[-- Attachment #1.1: Type: text/plain, Size: 1020 bytes --]

On Tue, 2016-06-07 at 17:46 +0100, Wei Liu wrote:
> > > I agree it would be good to set the exact bits though -- if you
> > > can
> > > tell
> > > me which field to test. 
> > > 
> > Perhaps at least mention something about all this either in a
> > comment
> > or in the changelog?
> > 
> What would you like to see in a comment? I guess this is now moot
> because the exact bits will be set.
> 
Well, if the code ends up looking like:

"the most correct thing would be to set the proper bits, but it's
hard/cumbersome/unknown how to do so, and setting all up until count it
enough for making things work"

Then, exactly that. :-)

If the code does the most correct thing already, as you seem to say,
then nothing.

Regards,
Dario
-- 
<<This happens because I choose it to happen!>> (Raistlin Majere)
-----------------------------------------------------------------
Dario Faggioli, Ph.D, http://about.me/dario.faggioli
Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)


[-- Attachment #1.2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

[-- Attachment #2: Type: text/plain, Size: 126 bytes --]

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

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 3/3] libxl: update vcpus bitmap in retrieved guest config
  2016-06-07 11:24 ` [PATCH 3/3] libxl: update vcpus bitmap in retrieved guest config Wei Liu
  2016-06-07 14:45   ` Anthony PERARD
@ 2016-06-14 16:31   ` Ian Jackson
  2016-06-14 16:39     ` Wei Liu
  1 sibling, 1 reply; 13+ messages in thread
From: Ian Jackson @ 2016-06-14 16:31 UTC (permalink / raw)
  To: Wei Liu; +Cc: Anthony PERARD, Xen-devel, Stefano Stabellini, Jan Beulich

Wei Liu writes ("[PATCH 3/3] 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.

Is this cpu hotplug something that the guest can cause, or are we just
talking about toolstack changes ?

Ian.

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

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 3/3] libxl: update vcpus bitmap in retrieved guest config
  2016-06-14 16:31   ` Ian Jackson
@ 2016-06-14 16:39     ` Wei Liu
  0 siblings, 0 replies; 13+ messages in thread
From: Wei Liu @ 2016-06-14 16:39 UTC (permalink / raw)
  To: Ian Jackson
  Cc: Anthony PERARD, Xen-devel, Stefano Stabellini, Wei Liu, Jan Beulich

On Tue, Jun 14, 2016 at 05:31:56PM +0100, Ian Jackson wrote:
> Wei Liu writes ("[PATCH 3/3] 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.
> 
> Is this cpu hotplug something that the guest can cause, or are we just
> talking about toolstack changes ?
> 

We're only talking about toolstack side here.

Wei.

> Ian.

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

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2016-06-14 16:39 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-07 11:23 [PATCH 0/3] libxl: update available vcpus map in retrieve configuration function Wei Liu
2016-06-07 11:24 ` [PATCH 1/3] libxl: introduce libxl__json_array_count Wei Liu
2016-06-07 11:24 ` [PATCH 2/3] libxl: introduce libxl__qmp_query_cpus Wei Liu
2016-06-07 11:24 ` [PATCH 3/3] libxl: update vcpus bitmap in retrieved guest config Wei Liu
2016-06-07 14:45   ` Anthony PERARD
2016-06-07 16:03     ` Wei Liu
2016-06-07 16:22       ` Dario Faggioli
2016-06-07 16:46         ` Wei Liu
2016-06-07 17:05           ` Dario Faggioli
2016-06-07 16:36       ` Anthony PERARD
2016-06-07 16:39         ` Wei Liu
2016-06-14 16:31   ` Ian Jackson
2016-06-14 16:39     ` Wei Liu

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).