[PATCH 1/2] qemu: Add some cpu hotpluggable inforamtion in vm xml when run "virsh setvcpus vm --count <current> --live".

Jidong Xia posted 2 patches 5 years, 10 months ago
[PATCH 1/2] qemu: Add some cpu hotpluggable inforamtion in vm xml when run "virsh setvcpus vm --count <current> --live".
Posted by Jidong Xia 5 years, 10 months ago
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




Re: [PATCH 1/2] qemu: Add some cpu hotpluggable inforamtion in vm xml when run "virsh setvcpus vm --count <current> --live".
Posted by Peter Krempa 5 years, 10 months ago
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.


Re: [PATCH 1/2] qemu: Add some cpu hotpluggable inforamtion in vm xml when run "virsh setvcpus vm --count <current> --live".
Posted by xiajidong 5 years, 9 months ago

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