[v5,16/22] s390x: allow cpu hotplug via device_add

Message ID 20170913132417.24384-17-david@redhat.com
State New
Headers show
Series
  • s390x cleanups and CPU hotplug via device_add
Related show

Commit Message

David Hildenbrand Sept. 13, 2017, 1:24 p.m.
E.g. the following now works:
    device_add host-s390-cpu,id=cpu1,core-id=1

The system will perform the same checks as when using cpu_add:
- If the core_id is already in use
- If the next sequential core_id isn't used
- If core-id >= max_cpu is specified

In addition, mixed CPU models are checked. E.g. if starting with
-cpu host and trying to hotplug "qemu-s390-cpu":
    "Mixed CPU models are not supported on s390x."

Reviewed-by: Matthew Rosato <mjrosato@linux.vnet.ibm.com>
Signed-off-by: David Hildenbrand <david@redhat.com>
---
 target/s390x/cpu.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Thomas Huth Sept. 28, 2017, 6:01 a.m. | #1
On 13.09.2017 15:24, David Hildenbrand wrote:
> E.g. the following now works:
>     device_add host-s390-cpu,id=cpu1,core-id=1

 Hi David,

FYI, this introduced a possibility to crash QEMU with the none machine:

$ s390x-softmmu/qemu-system-s390x -M none -nographic
QEMU 2.10.50 monitor - type 'help' for more information
(qemu) device_add qemu-s390-cpu
Segmentation fault (core dumped)

 Thomas
David Hildenbrand Sept. 28, 2017, 1 p.m. | #2
On 28.09.2017 08:01, Thomas Huth wrote:
> On 13.09.2017 15:24, David Hildenbrand wrote:
>> E.g. the following now works:
>>     device_add host-s390-cpu,id=cpu1,core-id=1
> 
>  Hi David,
> 
> FYI, this introduced a possibility to crash QEMU with the none machine:
> 
> $ s390x-softmmu/qemu-system-s390x -M none -nographic
> QEMU 2.10.50 monitor - type 'help' for more information
> (qemu) device_add qemu-s390-cpu
> Segmentation fault (core dumped)
> 
>  Thomas
> 

Interesting, x86 shields hotplug for none completely.

t460s: ~/git/qemu s390x_lap $ sudo qemu-system-x86_64 -M none -smp
1,maxcpus=4 -monitor stdio -Sqemu-system-x86_64: Number of SMP CPUs
requested (4) exceeds max CPUs supported by machine 'none' (1)

Will send a patch.
David Hildenbrand Sept. 28, 2017, 1:36 p.m. | #3
On 28.09.2017 08:01, Thomas Huth wrote:
> On 13.09.2017 15:24, David Hildenbrand wrote:
>> E.g. the following now works:
>>     device_add host-s390-cpu,id=cpu1,core-id=1
> 
>  Hi David,
> 
> FYI, this introduced a possibility to crash QEMU with the none machine:
> 
> $ s390x-softmmu/qemu-system-s390x -M none -nographic
> QEMU 2.10.50 monitor - type 'help' for more information
> (qemu) device_add qemu-s390-cpu
> Segmentation fault (core dumped)
> 
>  Thomas
> 

Interestingly, this is already fixed by my patch

s390x: raise CPU hotplug irq after really hotplugged

part of the SMP series.

Patch

diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c
index 8c1c644057..5724dffb88 100644
--- a/target/s390x/cpu.c
+++ b/target/s390x/cpu.c
@@ -467,6 +467,7 @@  static void s390_cpu_class_init(ObjectClass *oc, void *data)
     scc->parent_realize = dc->realize;
     dc->realize = s390_cpu_realizefn;
     dc->props = s390x_cpu_properties;
+    dc->user_creatable = true;
 
     scc->parent_reset = cc->reset;
 #if !defined(CONFIG_USER_ONLY)