[PATCH 0/2] qemu: Add some cpu hotpluggable infomation when run "virsh setvcpus command"

The optional cpu attribute current can be used to specify whether fewer than the maximum number of virtual CPUs should be enabled. With this patch, when run "virsh setvcpus vm --count <current>" with --live or --config, we can see some cpu information in vm xml. Jidong Xia (1): qemu: Add some cpu hotpluggable inforamtion in vm xml when run "virsh setvcpus vm --count <current> --config;virsh destroy vm; virsh start vm". xiajidong (1): qemu: Add some cpu hotpluggable inforamtion in vm xml when run "virsh setvcpus vm --count <current> --live". src/qemu/qemu_hotplug.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) -- 1.8.3.1

From: xiajidong <xiajidong@cmss.chinamobile.com> The optional cpu attribute current can be used to specify whether fewer than the maximum number of virtual CPUs should be enabled. when run "virsh setvcpus vm --count <current> --live", it can display cpu hotpluggable information when run "virsh dumpxml vm | grep vcpu". so we can know the value of enabled and hotpluggable attributes of the current vcpus. Signed-off-by: Jidong Xia <xiajidong@cmss.chinamobile.com> --- src/qemu/qemu_hotplug.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 14654a1..c574f63 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -6168,6 +6168,10 @@ qemuDomainSelectHotplugVcpuEntities(virDomainDefPtr def, } else { *enable = false; + if (nvcpus == curvcpus) { + def->individualvcpus = true; + } + for (i = maxvcpus - 1; i >= 0 && curvcpus > nvcpus; i--) { vcpu = virDomainDefGetVcpu(def, i); vcpupriv = QEMU_DOMAIN_VCPU_PRIVATE(vcpu); -- 1.8.3.1

On Thu, Apr 09, 2020 at 20:38:47 +0800, Jidong Xia wrote:
From: xiajidong <xiajidong@cmss.chinamobile.com>
The optional cpu attribute current can be used to specify whether fewer than the maximum number of virtual CPUs should be enabled. when run "virsh setvcpus vm --count <current> --live", it can display cpu hotpluggable information when run "virsh dumpxml vm | grep vcpu". so we can know the value of enabled and hotpluggable attributes of the current vcpus.
Signed-off-by: Jidong Xia <xiajidong@cmss.chinamobile.com> --- src/qemu/qemu_hotplug.c | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 14654a1..c574f63 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -6168,6 +6168,10 @@ qemuDomainSelectHotplugVcpuEntities(virDomainDefPtr def, } else { *enable = false;
+ if (nvcpus == curvcpus) { + def->individualvcpus = true; + }
The 'individualvcpus' flag here is deliberately not asserted in this API so that if only old/legacy vcpu hotplug APIs are used (qemuDomainSetVcpusFlags, note the plural Vcpus) we don't change the behaviour or XML. With new APIs used (qemuDomainSetVcpu, virsh setvcpu - note singular vcpu) the flag is asserted always and the output now displays everything. The commit message plainly states the facts when the extended cpu state is displayed, but does not justify why you want to change it, so please add a justification. Additionally if you justify the change enough, the correct fix will be to remove individualvcpus completely from 'def' and always display the information in the XML rather than adding these hacks.

On 4/9/20 9:23 AM, Peter Krempa wrote:
On Thu, Apr 09, 2020 at 20:38:47 +0800, Jidong Xia wrote:
From: xiajidong <xiajidong@cmss.chinamobile.com>
The optional cpu attribute current can be used to specify whether fewer than the maximum number of virtual CPUs should be enabled. when run "virsh setvcpus vm --count <current> --live", it can display cpu hotpluggable information when run "virsh dumpxml vm | grep vcpu". so we can know the value of enabled and hotpluggable attributes of the current vcpus.
Signed-off-by: Jidong Xia <xiajidong@cmss.chinamobile.com> --- src/qemu/qemu_hotplug.c | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 14654a1..c574f63 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -6168,6 +6168,10 @@ qemuDomainSelectHotplugVcpuEntities(virDomainDefPtr def, } else { *enable = false;
+ if (nvcpus == curvcpus) { + def->individualvcpus = true; + }
The 'individualvcpus' flag here is deliberately not asserted in this API so that if only old/legacy vcpu hotplug APIs are used (qemuDomainSetVcpusFlags, note the plural Vcpus) we don't change the behaviour or XML.
With new APIs used (qemuDomainSetVcpu, virsh setvcpu - note singular vcpu) the flag is asserted always and the output now displays everything.
The commit message plainly states the facts when the extended cpu state is displayed, but does not justify why you want to change it, so please add a justification.
Additionally if you justify the change enough, the correct fix will be to remove individualvcpus completely from 'def' and always display the information in the XML rather than adding these hacks.I think you are right, I am considering and studying this area. Thanks & Best Regards Jidong Xia

when run "virsh setvcpus vm --count <current> --config", and destroy vm, then start vm, it can display cpu hotpluggable information when run "virsh dumpxml vm | grep vcpu". so we can know the value of enabled and hotpluggable attributes of the current vcpus. Signed-off-by: Jidong Xia <xiajidong@cmss.chinamobile.com> --- src/qemu/qemu_hotplug.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index c574f63..312f257 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -6274,8 +6274,10 @@ qemuDomainSetVcpusConfig(virDomainDefPtr def, /* ordering information may become invalid, thus clear it */ virDomainDefVcpuOrderClear(def); - if (curvcpus == nvcpus) + if (curvcpus == nvcpus) { + def->individualvcpus = true; return; + } if (curvcpus < nvcpus) { for (i = 0; i < maxvcpus; i++) { -- 1.8.3.1
participants (3)
-
Jidong Xia
-
Peter Krempa
-
xiajidong