libxl: update available vcpus map in retrieved configuration
v4 cover libxl: update available vcpus map in retrieved configuration
See individual patch for detailed changelog.
Wei Liu (5):
libxl: constify copy and length calculation functions
libxl: libxl_domain_need_memory shouldn't modify b_info
libxl: introduce libxl__qmp_query_cpus
libxl: update vcpus bitmap in retrieved guest config
libxl: only issue cpu-add call to QEMU for not present CPU
tools/libxl/gentypes.py | 4 +- tools/libxl/libxl.c | 147 ++++++++++++++++++++++++++++++++++++++----- tools/libxl/libxl.h | 33 +++++++--- tools/libxl/libxl_cpuid.c | 4 +- tools/libxl/libxl_genid.c | 2 +- tools/libxl/libxl_internal.h | 5 +- tools/libxl/libxl_qmp.c | 38 +++++++++++ tools/libxl/libxl_utils.c | 2 +- tools/libxl/libxl_utils.h | 2 +- 9 files changed, 204 insertions(+), 33 deletions(-)
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH v4 1/5 libxl: constify copy and length calculation functions
These functions are not supposed to modify the passed in parameters. Reflect that in function declarations.
Mark the change in APIs in libxl.h
---
Cc: Ian Jackson <[email protected]>
--- tools/libxl/gentypes.py | 4 ++-- tools/libxl/libxl.c | 10 +++++----- tools/libxl/libxl.h | 23 +++++++++++++++-------- tools/libxl/libxl_cpuid.c | 4 ++-- tools/libxl/libxl_genid.c | 2 +- tools/libxl/libxl_internal.h | 2 +- tools/libxl/libxl_utils.c | 2 +- tools/libxl/libxl_utils.h | 2 +- 8 files changed, 28 insertions(+), 21 deletions(-)
tools/libxl/gentypes.py +2 -2
@@ -544,7 +544,7 @@ if __name__ == '__main__': if ty.dispose_fn is not None: f.write("%svoid %s(%s);\n" % (ty.hidden(), ty.dispose_fn, ty.make_arg("p"))) if ty.copy_fn is not None: - f.write("%svoid %s(libxl_ctx *ctx, %s, %s);\n" % (ty.hidden(), ty.copy_fn, + f.write("%svoid %s(libxl_ctx *ctx, %s, const %s);\n" % (ty.hidden(), ty.copy_fn, ty.make_arg("dst"), ty.make_arg("src"))) if ty.init_fn is not None: f.write("%svoid %s(%s);\n" % (ty.hidden(), ty.init_fn, ty.make_arg("p")))
@@ -649,7 +649,7 @@ if __name__ == '__main__': f.write("\n") for ty in [t for t in types if t.copy_fn and t.autogenerate_copy_fn]: - f.write("void %s(libxl_ctx *ctx, %s, %s)\n" % (ty.copy_fn, + f.write("void %s(libxl_ctx *ctx, %s, const %s)\n" % (ty.copy_fn, ty.make_arg("dst", passby=idl.PASS_BY_REFERENCE), ty.make_arg("src", passby=idl.PASS_BY_REFERENCE))) f.write("{\n")
tools/libxl/libxl.c +5 -5
@@ -234,7 +234,7 @@ void libxl_string_list_dispose(libxl_string_list *psl)void libxl_string_list_copy (libxl_ctx *ctx,libxl_string_list *dst, -libxl_string_list *src) +const libxl_string_list *src) {GC_INIT (ctx);int i, len;
@@ -266,7 +266,7 @@ int libxl_string_list_length(const libxl_string_list *psl)return i; } -int libxl_key_value_list_length (libxl_key_value_list *pkvl) +int libxl_key_value_list_length (const libxl_key_value_list *pkvl) {int i =0 ;libxl_key_value_list kvl = *pkvl;
@@ -301,7 +301,7 @@ void libxl_key_value_list_dispose(libxl_key_value_list *pkvl)void libxl_key_value_list_copy (libxl_ctx *ctx,libxl_key_value_list *dst, -libxl_key_value_list *src) +const libxl_key_value_list *src) {GC_INIT (ctx);int i, len;
@@ -7227,7 +7227,7 @@ out_err: } -void libxl_hwcap_copy (libxl_ctx *ctx,libxl_hwcap *dst,libxl_hwcap *src) +void libxl_hwcap_copy (libxl_ctx *ctx,libxl_hwcap *dst,const libxl_hwcap *src) {int i;
@@ -7235,7 +7235,7 @@ void libxl_hwcap_copy(libxl_ctx *ctx,libxl_hwcap *dst, libxl_hwcap *src) (*dst)[i] = (*src)[i]; } -void libxl_mac_copy (libxl_ctx *ctx,libxl_mac *dst,libxl_mac *src) +void libxl_mac_copy (libxl_ctx *ctx,libxl_mac *dst,const libxl_mac *src) {int i;
tools/libxl/libxl.h +15 -8
@@ -67,6 +67,13 @@* the same $(XEN_VERSION) (e.g. throughout a major release). */ +/* LIBXL_HAVE_CONST_COPY_AND_LENGTH_FUNCTIONS +* +* If this is defined, the copy functions have constified src parameter and the +* length functions accept constified parameter. +*/ +#define LIBXL_HAVE_CONST_COPY_AND_LENGTH_FUNCTIONS 1 +/* LIBXL_HAVE_VNUMA * * If this is defined the type libxl_vnode_info exists, and a
@@ -839,7 +846,7 @@ typedef uint8_t libxl_mac[6];#define LIBXL_MAC_FMT "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx"#define LIBXL_MAC_FMTLEN ((2*6)+5)/* 6 hex bytes plus 5 colons */ #define LIBXL_MAC_BYTES (mac) mac[0], mac[1], mac[2], mac[3], mac[4], mac[5] -void libxl_mac_copy (libxl_ctx *ctx,libxl_mac *dst,libxl_mac *src); +void libxl_mac_copy (libxl_ctx *ctx,libxl_mac *dst,const libxl_mac *src);#if defined(__i386__) || defined(__x86_64__)/*
@@ -962,17 +969,17 @@ typedef char **libxl_string_list;void libxl_string_list_dispose (libxl_string_list *sl);int libxl_string_list_length (const libxl_string_list *sl);void libxl_string_list_copy (libxl_ctx *ctx,libxl_string_list *dst, -libxl_string_list *src); +const libxl_string_list *src);typedef char **libxl_key_value_list ;void libxl_key_value_list_dispose (libxl_key_value_list *kvl); -int libxl_key_value_list_length (libxl_key_value_list *kvl); +int libxl_key_value_list_length (const libxl_key_value_list *kvl);void libxl_key_value_list_copy (libxl_ctx *ctx,libxl_key_value_list *dst, -libxl_key_value_list *src); +const libxl_key_value_list *src);typedef uint32_t libxl_hwcap [8 ]; -void libxl_hwcap_copy (libxl_ctx *ctx,libxl_hwcap *dst,libxl_hwcap *src); +void libxl_hwcap_copy (libxl_ctx *ctx,libxl_hwcap *dst,const libxl_hwcap *src);typedef uint64_t libxl_ev_user ;
@@ -990,10 +997,10 @@ void libxl_bitmap_dispose(libxl_bitmap *map);typedef struct libxl__cpuid_policy libxl_cpuid_policy ;typedef libxl_cpuid_policy *libxl_cpuid_policy_list ;void libxl_cpuid_dispose (libxl_cpuid_policy_list *cpuid_list); -int libxl_cpuid_policy_list_length (libxl_cpuid_policy_list *l); +int libxl_cpuid_policy_list_length (const libxl_cpuid_policy_list *l);void libxl_cpuid_policy_list_copy (libxl_ctx *ctx,libxl_cpuid_policy_list *dst, -libxl_cpuid_policy_list *src); +const libxl_cpuid_policy_list *src);#define LIBXL_PCI_FUNC_ALL (~0U)
@@ -2004,7 +2011,7 @@ int libxl_flask_loadpolicy(libxl_ctx *ctx, void *policy, uint32_t size);int libxl_ms_vm_genid_generate (libxl_ctx *ctx,libxl_ms_vm_genid *id);bool libxl_ms_vm_genid_is_zero (const libxl_ms_vm_genid *id);void libxl_ms_vm_genid_copy (libxl_ctx *ctx,libxl_ms_vm_genid *dst, -libxl_ms_vm_genid *src); +const libxl_ms_vm_genid *src);#ifdef LIBXL_HAVE_PSR_CMT int libxl_psr_cmt_attach (libxl_ctx *ctx,uint32_t domid);
tools/libxl/libxl_cpuid.c +2 -2
@@ -465,7 +465,7 @@ int libxl__cpuid_policy_list_parse_json(libxl__gc *gc,return 0 ; } -int libxl_cpuid_policy_list_length (libxl_cpuid_policy_list *pl) +int libxl_cpuid_policy_list_length (const libxl_cpuid_policy_list *pl) {int i =0 ;libxl_cpuid_policy_list l = *pl;
@@ -480,7 +480,7 @@ int libxl_cpuid_policy_list_length(libxl_cpuid_policy_list *pl)void libxl_cpuid_policy_list_copy (libxl_ctx *ctx,libxl_cpuid_policy_list *dst, -libxl_cpuid_policy_list *src) +const libxl_cpuid_policy_list *src) {GC_INIT (ctx);int i, j, len;
tools/libxl/libxl_genid.c +1 -1
@@ -52,7 +52,7 @@ bool libxl_ms_vm_genid_is_zero(const libxl_ms_vm_genid *id) }void libxl_ms_vm_genid_copy (libxl_ctx *ctx,libxl_ms_vm_genid *dst, -libxl_ms_vm_genid *src) +const libxl_ms_vm_genid *src) {memcpy (dst, src,LIBXL_MS_VM_GENID_LEN ); }
tools/libxl/libxl_internal.h +1 -1
@@ -4095,7 +4095,7 @@ void libxl__update_domain_configuration(libxl__gc *gc, const libxl_domain_config *src);static inline void libxl__update_config_nic (libxl__gc *gc,libxl_device_nic *dst, -libxl_device_nic *src) +const libxl_device_nic *src) { dst->devid = src->devid; dst->nictype = src->nictype;
tools/libxl/libxl_utils.c +1 -1
@@ -1271,7 +1271,7 @@ int libxl_domid_valid_guest(uint32_t domid)return domid >0 && domid <DOMID_FIRST_RESERVED ; } -void libxl_string_copy (libxl_ctx *ctx,char **dst,char **src) +void libxl_string_copy (libxl_ctx *ctx,char **dst,char *const *src) {GC_INIT (ctx);
tools/libxl/libxl_utils.h +1 -1
@@ -167,7 +167,7 @@ int libxl_cpumap_to_nodemap(libxl_ctx *ctx,return (s +1023 ) /1024 ; } -void libxl_string_copy (libxl_ctx *ctx,char **dst,char **src); +void libxl_string_copy (libxl_ctx *ctx,char **dst,char *const *src);#define LIBXL_FILLZERO (object) (memset(&(object), 0, sizeof((object))))
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH v4 1/5] libxl: constify copy and length calculation functions
Wei Liu writes ("[PATCH v4 1/5] libxl: constify copy and length calculation functions"):
Quoted 2 lines
These functions are not supposed to modify the passed in parameters. Reflect that in function declarations.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH v4 2/5 libxl: libxl_domain_need_memory shouldn't modify b_info
In reply to Wei LiuThis function is used to return the memory needed for a guest. It's not in a position to modify the b_info passed in (note the _setdefault function).
Constify the passed in b_info, use a copy to do the calculation. Mark the change in API in libxl.h.
---
Cc: Ian Jackson <[email protected]>
v4: constify b_info and use LIBXL_HAVE_NEED_MEMORY_CONST_B_INFO
v3: new
--- tools/libxl/libxl.c | 8 +++++++- tools/libxl/libxl.h | 10 +++++++++- 2 files changed, 16 insertions(+), 2 deletions(-)
tools/libxl/libxl.c +7 -1
@@ -5121,12 +5121,17 @@ int libxl_get_memory_target(libxl_ctx *ctx, uint32_t domid,return rc; } -int libxl_domain_need_memory (libxl_ctx *ctx,libxl_domain_build_info *b_info, +int libxl_domain_need_memory (libxl_ctx *ctx, +const libxl_domain_build_info *b_info_in,uint32_t *need_memkb) {GC_INIT (ctx); +libxl_domain_build_info b_info[1 ];int rc; +libxl_domain_build_info_init (b_info); +libxl_domain_build_info_copy (ctx, b_info, b_info_in); + rc =libxl__domain_build_info_setdefault (gc, b_info);if (rc) goto out;
@@ -5149,6 +5154,7 @@ int libxl_domain_need_memory(libxl_ctx *ctx, libxl_domain_build_info *b_info, rc =0 ; out:GC_FREE ; +libxl_domain_build_info_dispose (b_info);return rc; }
tools/libxl/libxl.h +9 -1
@@ -74,6 +74,13 @@*/ #define LIBXL_HAVE_CONST_COPY_AND_LENGTH_FUNCTIONS 1 +/* LIBXL_HAVE_DOMAIN_NEED_MEMORY_CONST_B_INFO +* +* If this is defined, libxl_domain_need_memory no longer modifies +* the b_info paseed in. +*/ +#define LIBXL_HAVE_DOMAIN_NEED_MEMORY_CONST_B_INFO 1 +/* LIBXL_HAVE_VNUMA * * If this is defined the type libxl_vnode_info exists, and a
@@ -1383,7 +1390,8 @@ int libxl_get_memory_target(libxl_ctx *ctx, uint32_t domid, uint32_t *out_target* existing programs which use them in roughly the same way as libxl. */ /* how much free memory in the system a domain needs to be built */ -int libxl_domain_need_memory (libxl_ctx *ctx,libxl_domain_build_info *b_info, +int libxl_domain_need_memory (libxl_ctx *ctx, +const libxl_domain_build_info *b_info_in,uint32_t *need_memkb);/* how much free memory is available in the system */ int libxl_get_free_memory (libxl_ctx *ctx,uint32_t *memkb);
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH v4 2/5] libxl: libxl_domain_need_memory shouldn't modify b_info
Wei Liu writes ("[PATCH v4 2/5] libxl: libxl_domain_need_memory shouldn't modify b_info"):
Quoted 6 lines
This function is used to return the memory needed for a guest. It's not in a position to modify the
b_infopassed in (note the_setdefaultfunction).Constify the passed in
b_info, use a copy to do the calculation. Mark the change in API inlibxl.h.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH v4 3/5 libxl: introduce libxl__qmp_query_cpus
In reply to Wei LiuIt interrogates QEMU for CPUs and update the bitmap accordingly.
---
Cc: Ian Jackson <[email protected]>
Cc: Anthony PERARD <[email protected]>
v3:
1. Initialise rc in error path.
2. Fix comment in header and a typo in log message.
--- tools/libxl/libxl_internal.h | 3 +++ tools/libxl/libxl_qmp.c | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+)
tools/libxl/libxl_internal.h +3 -0
@@ -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 bitmap of CPUs */ +_hidden int libxl__qmp_query_cpus(libxl__gc *gc, int domid, +libxl_bitmap *map);/* Start NBD server */ _hidden int libxl__qmp_nbd_server_start(libxl__gc *gc, int domid,const char *host,const char *port);
tools/libxl/libxl_qmp.c +38 -0
@@ -979,6 +979,44 @@ 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) +{ +libxl_bitmap *map = opaque; +unsigned int i; +const libxl__json_object *cpu =NULL ; +int rc; +GC_INIT (qmp->ctx); + +libxl_bitmap_set_none (map); +for (i =0 ; (cpu =libxl__json_array_get (response, i)); i++) { +unsigned int idx; +const libxl__json_object *o; + + o =libxl__json_map_get ("CPU" , cpu,JSON_INTEGER ); +if (!o) { +LOG (ERROR ,"Failed to retrieve CPU index." ); + rc =ERROR_FAIL ; + goto out; + } + + idx =libxl__json_object_get_integer (o); +libxl_bitmap_set (map, idx); + } + + rc =0 ; +out: +GC_FREE ; +return rc; +} + +int libxl__qmp_query_cpus (libxl__gc *gc,int domid,libxl_bitmap *map) +{ +return qmp_run_command (gc, domid,"query-cpus" ,NULL , + query_cpus_callback, map); +} +int libxl__qmp_nbd_server_start (libxl__gc *gc,int domid,const char *host,const char *port) {
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH v4 4/5 libxl: update vcpus bitmap in retrieved guest config
In reply to Wei Liu... 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.
---
Cc: Ian Jackson <[email protected]>
Cc: Anthony PERARD <[email protected]>
v4:
1. Use libxl__device_model_version_running
2. Move comment
v3:
1. Fix indentation of abort.
2. Use strcmp instead of strncmp.
--- tools/libxl/libxl.c | 90 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+)
tools/libxl/libxl.c +90 -0
@@ -7249,6 +7249,53 @@ void libxl_mac_copy(libxl_ctx *ctx, libxl_mac *dst, const libxl_mac *src) (*dst)[i] = (*src)[i]; } +/* For QEMU upstream we always need to provide the number of cpus present to +* QEMU whether they are online or not; otherwise QEMU won't accept the saved +* state. See implementation of libxl__qmp_query_cpus. +*/ +static int libxl__update_avail_vcpus_qmp (libxl__gc *gc,uint32_t domid, +unsigned int max_vcpus, +libxl_bitmap *map) +{ +int rc; + + 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 ; +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 (!strcmp (content,"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) {
@@ -7297,6 +7344,49 @@ 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); + +switch (d_config->b_info.type) { +case LIBXL_DOMAIN_TYPE_HVM : + version =libxl__device_model_version_running (gc, domid); +assert (version !=LIBXL_DEVICE_MODEL_VERSION_UNKNOWN ); +switch (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:
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH v4 4/5] libxl: update vcpus bitmap in retrieved guest config
Wei Liu writes ("[PATCH v4 4/5] libxl: update vcpus bitmap in retrieved guest config"):
Quoted 8 lines
... 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 <[email protected]>Signed-off-by Wei Liu <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v4 4/5] libxl: update vcpus bitmap in retrieved guest config
Quoted 11 lines · Ian Jackson
Wei Liu writes ("[PATCH v4 4/5] libxl: update vcpus bitmap in retrieved guest config"):
Quoted 8 lines
... 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 <[email protected]>Signed-off-by Wei Liu <[email protected]>Acked-by Ian Jackson <[email protected]>
Sorry I just realise there is one hunk I forgot to commit.
The hunk is (on top of this patch) to use libxl__xs_read_checked
tools/libxl/libxl.c +4 -2
@@ -7305,8 +7305,10 @@ static int libxl__update_avail_vcpus_xenstore(libxl__gc *gc, uint32_t domid,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" )) +const char *content; + rc =libxl__xs_read_checked (gc,XBT_NULL , path, &content); +if (rc) goto out; +if (content && !strcmp (content,"online" ))libxl_bitmap_set (map, i); }
Is it ok to keep your ack?
Wei.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v4 4/5] libxl: update vcpus bitmap in retrieved guest config
Wei Liu writes ("Re: [PATCH v4 4/5] libxl: update vcpus bitmap in retrieved guest config"):
Quoted 1 line
The hunk is (on top of this patch) to use
libxl__xs_read_checked
Errr. Sorry for not spotting that in my review.
Quoted 1 line
Is it ok to keep your ack?
Yes, thanks.
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH v4 5/5 libxl: only issue cpu-add call to QEMU for not present CPU
In reply to Wei LiuCalculate the final bitmap for CPUs to add to avoid having annoying error messages complaining those CPUs are already present. Example message is like (wrapped):
libxl: error: libxl_qmp.c:287:qmp_handle_error_response: received an error message from QMP server: Unable to add CPU: 0, it already exists
We can also properly handle error from QMP now.
---
Cc: Ian Jackson <[email protected]>
Cc: Anthony PERARD <[email protected]>
v4:
1. update commit log to contain example error message.
v3:
1. Add Anthony's Reviewed-by tag.
--- tools/libxl/libxl.c | 39 +++++++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 10 deletions(-)
tools/libxl/libxl.c +29 -10
@@ -5756,19 +5756,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)
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH v4 5/5] libxl: only issue cpu-add call to QEMU for not present CPU
Wei Liu writes ("[PATCH v4 5/5] libxl: only issue cpu-add call to QEMU for not present CPU"):
Quoted 8 lines
Calculate the final bitmap for CPUs to add to avoid having annoying error messages complaining those CPUs are already present. Example message is like (wrapped):
libxl: error: libxl_qmp.c:287:qmp_handle_error_response: received an error message from QMP server: Unable to add CPU: 0, it already exists
We can also properly handle error from QMP now.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 1 line · Wei Liu
See individual patch for detailed changelog.
Series pushed.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel