[Qemu-devel] [PATCH 0/3] arm/virt: refine virt.c code and implement hot_add_cpu interface

Li Zhang posted 3 patches 6 years, 10 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/1495790468-23862-1-git-send-email-zhlcindy@gmail.com
Test checkpatch passed
Test docker passed
Test s390x passed
hw/arm/virt.c | 344 ++++++++++++++++++++++++++++++++++------------------------
1 file changed, 202 insertions(+), 142 deletions(-)
[Qemu-devel] [PATCH 0/3] arm/virt: refine virt.c code and implement hot_add_cpu interface
Posted by Li Zhang 6 years, 10 months ago
From: Li Zhang <li.zhang@hxt-semitech.com>

virt machine doesn't support hot_add_cpu interface. This patchset is to implement
hot_add_cpu interface. A CPU can be added by QMP command with QEMU monitor.

Here is command to add a CPU with QMP command.

* qemu-system-aarch64 -machine virt -cpu cortex-a15 -smp 1,maxcpus=4 \
    -monitor telnet:127.0.0.1:4444,server,nowait -nographic
* connect monitor:      telnet 127.0.0.1 4444
* execute qmp command:  cpu-add 1

Currently, when KVM is enabled and add a CPU with QMP command, QEMU 
reports error "kvm_init_vcpu failed: Device or resourc busy". KVM can't
create a new CPU when vgic has been initialized and irqchip_in_kernel in
function kvm_arch_vcpu_create. It needs to change KVM code in the future.

Li Zhang (3):
  arm/virt: Refine fdt_add_cpu_nodes code
  arm/virt: Refine code of machvirt_init
  arm/virt: Implement hot_add_cpu interface

 hw/arm/virt.c | 344 ++++++++++++++++++++++++++++++++++------------------------
 1 file changed, 202 insertions(+), 142 deletions(-)

-- 
2.7.4


Re: [Qemu-devel] [PATCH 0/3] arm/virt: refine virt.c code and implement hot_add_cpu interface
Posted by Igor Mammedov 6 years, 10 months ago
On Fri, 26 May 2017 17:21:05 +0800
Li Zhang <zhlcindy@gmail.com> wrote:

> From: Li Zhang <li.zhang@hxt-semitech.com>
> 
> virt machine doesn't support hot_add_cpu interface. This patchset is to implement
> hot_add_cpu interface. A CPU can be added by QMP command with QEMU monitor.
> 
> Here is command to add a CPU with QMP command.
> 
> * qemu-system-aarch64 -machine virt -cpu cortex-a15 -smp 1,maxcpus=4 \
>     -monitor telnet:127.0.0.1:4444,server,nowait -nographic
> * connect monitor:      telnet 127.0.0.1 4444
> * execute qmp command:  cpu-add 1
cpu-add command shouldn't be used for new cpu hotplug,
pls use generic device_add for that.

The last time I looked at it, virt machine needed quite a bit of
re-factoring of the way it creates/wires up CPUs.

Pls see usage of following callbacks for example on how to implement
device_add based cpu hotplug:

  get_hotplug_handler
  pc_cpu_pre_plug
  pc_cpu_plug
  pc_possible_cpu_arch_ids

and pc_cpus_init() for initial cpu creation with above callbacks in use

> 
> Currently, when KVM is enabled and add a CPU with QMP command, QEMU 
> reports error "kvm_init_vcpu failed: Device or resourc busy". KVM can't
> create a new CPU when vgic has been initialized and irqchip_in_kernel in
> function kvm_arch_vcpu_create. It needs to change KVM code in the future.
if KVM isn't capable do it yet, then qemu should refuse cpu hotplug if running
with KVM accelarator and allow it only in TCG mode.

> 
> Li Zhang (3):
>   arm/virt: Refine fdt_add_cpu_nodes code
>   arm/virt: Refine code of machvirt_init
>   arm/virt: Implement hot_add_cpu interface
> 
>  hw/arm/virt.c | 344 ++++++++++++++++++++++++++++++++++------------------------
>  1 file changed, 202 insertions(+), 142 deletions(-)
> 


Re: [Qemu-devel] [PATCH 0/3] arm/virt: refine virt.c code and implement hot_add_cpu interface
Posted by Li Zhang 6 years, 10 months ago
On Fri, May 26, 2017 at 7:21 PM, Igor Mammedov <imammedo@redhat.com> wrote:
> On Fri, 26 May 2017 17:21:05 +0800
> Li Zhang <zhlcindy@gmail.com> wrote:
>
>> From: Li Zhang <li.zhang@hxt-semitech.com>
>>
>> virt machine doesn't support hot_add_cpu interface. This patchset is to implement
>> hot_add_cpu interface. A CPU can be added by QMP command with QEMU monitor.
>>
>> Here is command to add a CPU with QMP command.
>>
>> * qemu-system-aarch64 -machine virt -cpu cortex-a15 -smp 1,maxcpus=4 \
>>     -monitor telnet:127.0.0.1:4444,server,nowait -nographic
>> * connect monitor:      telnet 127.0.0.1 4444
>> * execute qmp command:  cpu-add 1
> cpu-add command shouldn't be used for new cpu hotplug,
> pls use generic device_add for that.

Ok,  I will drop this command and look at device_add.

>
> The last time I looked at it, virt machine needed quite a bit of
> re-factoring of the way it creates/wires up CPUs.

 Yes, I am looking into it and see if I can do something:)

>
> Pls see usage of following callbacks for example on how to implement
> device_add based cpu hotplug:
>
>   get_hotplug_handler
>   pc_cpu_pre_plug
>   pc_cpu_plug
>   pc_possible_cpu_arch_ids
>
> and pc_cpus_init() for initial cpu creation with above callbacks in use
>
Thanks, I will see it. :)

>>
>> Currently, when KVM is enabled and add a CPU with QMP command, QEMU
>> reports error "kvm_init_vcpu failed: Device or resourc busy". KVM can't
>> create a new CPU when vgic has been initialized and irqchip_in_kernel in
>> function kvm_arch_vcpu_create. It needs to change KVM code in the future.
> if KVM isn't capable do it yet, then qemu should refuse cpu hotplug if running
> with KVM accelarator and allow it only in TCG mode.

OK, I will add an assertion to allow hotplug only in TCG mode.

>
>>
>> Li Zhang (3):
>>   arm/virt: Refine fdt_add_cpu_nodes code
>>   arm/virt: Refine code of machvirt_init
>>   arm/virt: Implement hot_add_cpu interface
>>
>>  hw/arm/virt.c | 344 ++++++++++++++++++++++++++++++++++------------------------
>>  1 file changed, 202 insertions(+), 142 deletions(-)
>>
>



-- 

Best Regards
-Li

Re: [Qemu-devel] [PATCH 0/3] arm/virt: refine virt.c code and implement hot_add_cpu interface
Posted by Igor Mammedov 6 years, 10 months ago
On Sat, 27 May 2017 10:32:33 +0800
Li Zhang <zhlcindy@gmail.com> wrote:

> On Fri, May 26, 2017 at 7:21 PM, Igor Mammedov <imammedo@redhat.com> wrote:
> > On Fri, 26 May 2017 17:21:05 +0800
> > Li Zhang <zhlcindy@gmail.com> wrote:
> >  
> >> From: Li Zhang <li.zhang@hxt-semitech.com>
> >>
> >> virt machine doesn't support hot_add_cpu interface. This patchset is to implement
> >> hot_add_cpu interface. A CPU can be added by QMP command with QEMU monitor.
> >>
> >> Here is command to add a CPU with QMP command.
> >>
> >> * qemu-system-aarch64 -machine virt -cpu cortex-a15 -smp 1,maxcpus=4 \
> >>     -monitor telnet:127.0.0.1:4444,server,nowait -nographic
> >> * connect monitor:      telnet 127.0.0.1 4444
> >> * execute qmp command:  cpu-add 1  
> > cpu-add command shouldn't be used for new cpu hotplug,
> > pls use generic device_add for that.  
> 
> Ok,  I will drop this command and look at device_add.
> 
> >
> > The last time I looked at it, virt machine needed quite a bit of
> > re-factoring of the way it creates/wires up CPUs.  
> 
>  Yes, I am looking into it and see if I can do something:)
> 
> >
> > Pls see usage of following callbacks for example on how to implement
> > device_add based cpu hotplug:
> >
> >   get_hotplug_handler
> >   pc_cpu_pre_plug
> >   pc_cpu_plug
> >   pc_possible_cpu_arch_ids
> >
> > and pc_cpus_init() for initial cpu creation with above callbacks in use
> >  
> Thanks, I will see it. :)
> 
> >>
> >> Currently, when KVM is enabled and add a CPU with QMP command, QEMU
> >> reports error "kvm_init_vcpu failed: Device or resourc busy". KVM can't
> >> create a new CPU when vgic has been initialized and irqchip_in_kernel in
> >> function kvm_arch_vcpu_create. It needs to change KVM code in the future.  
> > if KVM isn't capable do it yet, then qemu should refuse cpu hotplug if running
> > with KVM accelarator and allow it only in TCG mode.  
> 
> OK, I will add an assertion to allow hotplug only in TCG mode.
instead of assert which will crash guest on hotplug,
just disable hotplug gracefully (for example set error in pre_plug handler)

> 
> >  
> >>
> >> Li Zhang (3):
> >>   arm/virt: Refine fdt_add_cpu_nodes code
> >>   arm/virt: Refine code of machvirt_init
> >>   arm/virt: Implement hot_add_cpu interface
> >>
> >>  hw/arm/virt.c | 344 ++++++++++++++++++++++++++++++++++------------------------
> >>  1 file changed, 202 insertions(+), 142 deletions(-)
> >>  
> >  
> 
> 
> 


Re: [Qemu-devel] [PATCH 0/3] arm/virt: refine virt.c code and implement hot_add_cpu interface
Posted by Li Zhang 6 years, 10 months ago

> 在 2017年5月29日,下午6:43,Igor Mammedov <imammedo@redhat.com> 写道:
> 
> On Sat, 27 May 2017 10:32:33 +0800
> Li Zhang <zhlcindy@gmail.com> wrote:
> 
>>> On Fri, May 26, 2017 at 7:21 PM, Igor Mammedov <imammedo@redhat.com> wrote:
>>> On Fri, 26 May 2017 17:21:05 +0800
>>> Li Zhang <zhlcindy@gmail.com> wrote:
>>> 
>>>> From: Li Zhang <li.zhang@hxt-semitech.com>
>>>> 
>>>> virt machine doesn't support hot_add_cpu interface. This patchset is to implement
>>>> hot_add_cpu interface. A CPU can be added by QMP command with QEMU monitor.
>>>> 
>>>> Here is command to add a CPU with QMP command.
>>>> 
>>>> * qemu-system-aarch64 -machine virt -cpu cortex-a15 -smp 1,maxcpus=4 \
>>>>    -monitor telnet:127.0.0.1:4444,server,nowait -nographic
>>>> * connect monitor:      telnet 127.0.0.1 4444
>>>> * execute qmp command:  cpu-add 1  
>>> cpu-add command shouldn't be used for new cpu hotplug,
>>> pls use generic device_add for that.  
>> 
>> Ok,  I will drop this command and look at device_add.
>> 
>>> 
>>> The last time I looked at it, virt machine needed quite a bit of
>>> re-factoring of the way it creates/wires up CPUs.  
>> 
>> Yes, I am looking into it and see if I can do something:)
>> 
>>> 
>>> Pls see usage of following callbacks for example on how to implement
>>> device_add based cpu hotplug:
>>> 
>>>  get_hotplug_handler
>>>  pc_cpu_pre_plug
>>>  pc_cpu_plug
>>>  pc_possible_cpu_arch_ids
>>> 
>>> and pc_cpus_init() for initial cpu creation with above callbacks in use
>>> 
>> Thanks, I will see it. :)
>> 
>>>> 
>>>> Currently, when KVM is enabled and add a CPU with QMP command, QEMU
>>>> reports error "kvm_init_vcpu failed: Device or resourc busy". KVM can't
>>>> create a new CPU when vgic has been initialized and irqchip_in_kernel in
>>>> function kvm_arch_vcpu_create. It needs to change KVM code in the future.  
>>> if KVM isn't capable do it yet, then qemu should refuse cpu hotplug if running
>>> with KVM accelarator and allow it only in TCG mode.  
>> 
>> OK, I will add an assertion to allow hotplug only in TCG mode.
> instead of assert which will crash guest on hotplug,
> just disable hotplug gracefully (for example set error in pre_plug handler)

OK, got it.

> 
>> 
>>> 
>>>> 
>>>> Li Zhang (3):
>>>>  arm/virt: Refine fdt_add_cpu_nodes code
>>>>  arm/virt: Refine code of machvirt_init
>>>>  arm/virt: Implement hot_add_cpu interface
>>>> 
>>>> hw/arm/virt.c | 344 ++++++++++++++++++++++++++++++++++------------------------
>>>> 1 file changed, 202 insertions(+), 142 deletions(-)
>>>> 
>>> 
>> 
>> 
>> 
>