qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH for-2.6 00/10] s390x patches for 2.6
@ 2016-03-09 17:27 Cornelia Huck
  2016-03-09 17:27 ` [Qemu-devel] [PATCH for-2.6 01/10] s390x/cpu: Cleanup init in preparation for hotplug Cornelia Huck
                   ` (9 more replies)
  0 siblings, 10 replies; 14+ messages in thread
From: Cornelia Huck @ 2016-03-09 17:27 UTC (permalink / raw)
  To: qemu-devel; +Cc: Cornelia Huck, borntraeger, jfrei, agraf

In my queue for 2.6 are the cpu hotplug patches already posted,
a fix for the s390-ccw bios (that actually does not make any
difference today unless debugging is enabled, so no rebuild needed)
and a bit of cleanup in the machine code that will make changes
easier in the future.

I plan to send a pull request this friday or so.

Eugene (jno) Dvurechenski (1):
  pc-bios/s390-ccw: fix old bug in ptr increment

Janosch Frank (2):
  s390x: Introduce machine definition macros
  s390x: Introduce S390MachineClass

Matthew Rosato (7):
  s390x/cpu: Cleanup init in preparation for hotplug
  s390x/cpu: Set initial CPU state in common routine
  s390x/cpu: Get rid of side effects when creating a vcpu
  s390x/cpu: Tolerate max_cpus
  s390x/cpu: Add CPU property links
  s390x/cpu: Add error handling to cpu creation
  s390x/cpu: Allow hotplug of CPUs

 hw/s390x/s390-virtio-ccw.c         | 150 +++++++++++++++++++++++--------------
 hw/s390x/s390-virtio.c             |  36 +++++----
 hw/s390x/s390-virtio.h             |   2 +-
 include/hw/s390x/s390-virtio-ccw.h |  40 ++++++++++
 pc-bios/s390-ccw/bootmap.c         |   2 +-
 target-s390x/cpu-qom.h             |   3 +
 target-s390x/cpu.c                 |  96 ++++++++++++++++++++++--
 target-s390x/cpu.h                 |   2 +
 target-s390x/helper.c              |  41 +++++++++-
 9 files changed, 289 insertions(+), 83 deletions(-)
 create mode 100644 include/hw/s390x/s390-virtio-ccw.h

-- 
2.3.9

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Qemu-devel] [PATCH for-2.6 01/10] s390x/cpu: Cleanup init in preparation for hotplug
  2016-03-09 17:27 [Qemu-devel] [PATCH for-2.6 00/10] s390x patches for 2.6 Cornelia Huck
@ 2016-03-09 17:27 ` Cornelia Huck
  2016-03-09 17:28 ` [Qemu-devel] [PATCH for-2.6 02/10] s390x/cpu: Set initial CPU state in common routine Cornelia Huck
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 14+ messages in thread
From: Cornelia Huck @ 2016-03-09 17:27 UTC (permalink / raw)
  To: qemu-devel; +Cc: Matthew Rosato, borntraeger, jfrei, Cornelia Huck, agraf

From: Matthew Rosato <mjrosato@linux.vnet.ibm.com>

Ensure a valid cpu_model is set upfront by setting the
default value directly into the MachineState when none is
specified.  This is needed to ensure hotplugged CPUs share
the same cpu_model.

Signed-off-by: Matthew Rosato <mjrosato@linux.vnet.ibm.com>
Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Message-Id: <1457112875-5209-2-git-send-email-mjrosato@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
---
 hw/s390x/s390-virtio-ccw.c | 2 +-
 hw/s390x/s390-virtio.c     | 8 ++++----
 hw/s390x/s390-virtio.h     | 2 +-
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
index 89f5d0d..b05ed8b 100644
--- a/hw/s390x/s390-virtio-ccw.c
+++ b/hw/s390x/s390-virtio-ccw.c
@@ -136,7 +136,7 @@ static void ccw_init(MachineState *machine)
     virtio_ccw_register_hcalls();
 
     /* init CPUs */
-    s390_init_cpus(machine->cpu_model);
+    s390_init_cpus(machine);
 
     if (kvm_enabled()) {
         kvm_s390_enable_css_support(s390_cpu_addr2state(0));
diff --git a/hw/s390x/s390-virtio.c b/hw/s390x/s390-virtio.c
index 8e533ae..d40d0dc 100644
--- a/hw/s390x/s390-virtio.c
+++ b/hw/s390x/s390-virtio.c
@@ -93,12 +93,12 @@ void s390_init_ipl_dev(const char *kernel_filename,
     qdev_init_nofail(dev);
 }
 
-void s390_init_cpus(const char *cpu_model)
+void s390_init_cpus(MachineState *machine)
 {
     int i;
 
-    if (cpu_model == NULL) {
-        cpu_model = "host";
+    if (machine->cpu_model == NULL) {
+        machine->cpu_model = "host";
     }
 
     ipi_states = g_malloc(sizeof(S390CPU *) * smp_cpus);
@@ -107,7 +107,7 @@ void s390_init_cpus(const char *cpu_model)
         S390CPU *cpu;
         CPUState *cs;
 
-        cpu = cpu_s390x_init(cpu_model);
+        cpu = cpu_s390x_init(machine->cpu_model);
         cs = CPU(cpu);
 
         ipi_states[i] = cpu;
diff --git a/hw/s390x/s390-virtio.h b/hw/s390x/s390-virtio.h
index eebce8e..ffd014c 100644
--- a/hw/s390x/s390-virtio.h
+++ b/hw/s390x/s390-virtio.h
@@ -19,7 +19,7 @@
 typedef int (*s390_virtio_fn)(const uint64_t *args);
 void s390_register_virtio_hypercall(uint64_t code, s390_virtio_fn fn);
 
-void s390_init_cpus(const char *cpu_model);
+void s390_init_cpus(MachineState *machine);
 void s390_init_ipl_dev(const char *kernel_filename,
                        const char *kernel_cmdline,
                        const char *initrd_filename,
-- 
2.3.9

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [Qemu-devel] [PATCH for-2.6 02/10] s390x/cpu: Set initial CPU state in common routine
  2016-03-09 17:27 [Qemu-devel] [PATCH for-2.6 00/10] s390x patches for 2.6 Cornelia Huck
  2016-03-09 17:27 ` [Qemu-devel] [PATCH for-2.6 01/10] s390x/cpu: Cleanup init in preparation for hotplug Cornelia Huck
@ 2016-03-09 17:28 ` Cornelia Huck
  2016-03-09 17:28 ` [Qemu-devel] [PATCH for-2.6 03/10] s390x/cpu: Get rid of side effects when creating a vcpu Cornelia Huck
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 14+ messages in thread
From: Cornelia Huck @ 2016-03-09 17:28 UTC (permalink / raw)
  To: qemu-devel; +Cc: Matthew Rosato, borntraeger, jfrei, Cornelia Huck, agraf

From: Matthew Rosato <mjrosato@linux.vnet.ibm.com>

Both initial and hotplugged CPUs need to set the same initial
state.

Signed-off-by: Matthew Rosato <mjrosato@linux.vnet.ibm.com>
Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Message-Id: <1457112875-5209-3-git-send-email-mjrosato@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
---
 hw/s390x/s390-virtio.c | 4 ----
 target-s390x/cpu.c     | 2 ++
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/hw/s390x/s390-virtio.c b/hw/s390x/s390-virtio.c
index d40d0dc..c501a48 100644
--- a/hw/s390x/s390-virtio.c
+++ b/hw/s390x/s390-virtio.c
@@ -105,14 +105,10 @@ void s390_init_cpus(MachineState *machine)
 
     for (i = 0; i < smp_cpus; i++) {
         S390CPU *cpu;
-        CPUState *cs;
 
         cpu = cpu_s390x_init(machine->cpu_model);
-        cs = CPU(cpu);
 
         ipi_states[i] = cpu;
-        cs->halted = 1;
-        cs->exception_index = EXCP_HLT;
     }
 }
 
diff --git a/target-s390x/cpu.c b/target-s390x/cpu.c
index 73a910d..603c2a1 100644
--- a/target-s390x/cpu.c
+++ b/target-s390x/cpu.c
@@ -219,6 +219,8 @@ static void s390_cpu_initfn(Object *obj)
 #endif
 
     cs->env_ptr = env;
+    cs->halted = 1;
+    cs->exception_index = EXCP_HLT;
     cpu_exec_init(cs, &error_abort);
 #if !defined(CONFIG_USER_ONLY)
     qemu_register_reset(s390_cpu_machine_reset_cb, cpu);
-- 
2.3.9

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [Qemu-devel] [PATCH for-2.6 03/10] s390x/cpu: Get rid of side effects when creating a vcpu
  2016-03-09 17:27 [Qemu-devel] [PATCH for-2.6 00/10] s390x patches for 2.6 Cornelia Huck
  2016-03-09 17:27 ` [Qemu-devel] [PATCH for-2.6 01/10] s390x/cpu: Cleanup init in preparation for hotplug Cornelia Huck
  2016-03-09 17:28 ` [Qemu-devel] [PATCH for-2.6 02/10] s390x/cpu: Set initial CPU state in common routine Cornelia Huck
@ 2016-03-09 17:28 ` Cornelia Huck
  2016-03-09 17:28 ` [Qemu-devel] [PATCH for-2.6 04/10] s390x/cpu: Tolerate max_cpus Cornelia Huck
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 14+ messages in thread
From: Cornelia Huck @ 2016-03-09 17:28 UTC (permalink / raw)
  To: qemu-devel; +Cc: Matthew Rosato, borntraeger, jfrei, Cornelia Huck, agraf

From: Matthew Rosato <mjrosato@linux.vnet.ibm.com>

In preparation for hotplug, defer some CPU initialization
until the device is actually being realized, including
cpu_exec_init.

Signed-off-by: Matthew Rosato <mjrosato@linux.vnet.ibm.com>
Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Message-Id: <1457112875-5209-4-git-send-email-mjrosato@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
---
 target-s390x/cpu-qom.h |  2 ++
 target-s390x/cpu.c     | 20 +++++++++++++++-----
 2 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/target-s390x/cpu-qom.h b/target-s390x/cpu-qom.h
index 029a44a..56d82f2 100644
--- a/target-s390x/cpu-qom.h
+++ b/target-s390x/cpu-qom.h
@@ -47,6 +47,8 @@ typedef struct S390CPUClass {
     CPUClass parent_class;
     /*< public >*/
 
+    int64_t next_cpu_id;
+
     DeviceRealize parent_realize;
     void (*parent_reset)(CPUState *cpu);
     void (*load_normal)(CPUState *cpu);
diff --git a/target-s390x/cpu.c b/target-s390x/cpu.c
index 603c2a1..76c8eaf 100644
--- a/target-s390x/cpu.c
+++ b/target-s390x/cpu.c
@@ -195,7 +195,20 @@ static void s390_cpu_realizefn(DeviceState *dev, Error **errp)
 {
     CPUState *cs = CPU(dev);
     S390CPUClass *scc = S390_CPU_GET_CLASS(dev);
+    S390CPU *cpu = S390_CPU(dev);
+    CPUS390XState *env = &cpu->env;
+    Error *err = NULL;
+
+    cpu_exec_init(cs, &err);
+    if (err != NULL) {
+        error_propagate(errp, err);
+        return;
+    }
 
+#if !defined(CONFIG_USER_ONLY)
+    qemu_register_reset(s390_cpu_machine_reset_cb, cpu);
+#endif
+    env->cpu_num = scc->next_cpu_id++;
     s390_cpu_gdb_init(cs);
     qemu_init_vcpu(cs);
 #if !defined(CONFIG_USER_ONLY)
@@ -213,7 +226,6 @@ static void s390_cpu_initfn(Object *obj)
     S390CPU *cpu = S390_CPU(obj);
     CPUS390XState *env = &cpu->env;
     static bool inited;
-    static int cpu_num = 0;
 #if !defined(CONFIG_USER_ONLY)
     struct tm tm;
 #endif
@@ -221,9 +233,7 @@ static void s390_cpu_initfn(Object *obj)
     cs->env_ptr = env;
     cs->halted = 1;
     cs->exception_index = EXCP_HLT;
-    cpu_exec_init(cs, &error_abort);
 #if !defined(CONFIG_USER_ONLY)
-    qemu_register_reset(s390_cpu_machine_reset_cb, cpu);
     qemu_get_timedate(&tm, 0);
     env->tod_offset = TOD_UNIX_EPOCH +
                       (time2tod(mktimegm(&tm)) * 1000000000ULL);
@@ -232,7 +242,6 @@ static void s390_cpu_initfn(Object *obj)
     env->cpu_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, s390x_cpu_timer, cpu);
     s390_cpu_set_state(CPU_STATE_STOPPED, cpu);
 #endif
-    env->cpu_num = cpu_num++;
 
     if (tcg_enabled() && !inited) {
         inited = true;
@@ -339,6 +348,7 @@ static void s390_cpu_class_init(ObjectClass *oc, void *data)
     CPUClass *cc = CPU_CLASS(scc);
     DeviceClass *dc = DEVICE_CLASS(oc);
 
+    scc->next_cpu_id = 0;
     scc->parent_realize = dc->realize;
     dc->realize = s390_cpu_realizefn;
 
@@ -371,7 +381,7 @@ static void s390_cpu_class_init(ObjectClass *oc, void *data)
     cc->gdb_arch_name = s390_gdb_arch_name;
 
     /*
-     * Reason: s390_cpu_initfn() calls cpu_exec_init(), which saves
+     * Reason: s390_cpu_realizefn() calls cpu_exec_init(), which saves
      * the object in cpus -> dangling pointer after final
      * object_unref().
      */
-- 
2.3.9

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [Qemu-devel] [PATCH for-2.6 04/10] s390x/cpu: Tolerate max_cpus
  2016-03-09 17:27 [Qemu-devel] [PATCH for-2.6 00/10] s390x patches for 2.6 Cornelia Huck
                   ` (2 preceding siblings ...)
  2016-03-09 17:28 ` [Qemu-devel] [PATCH for-2.6 03/10] s390x/cpu: Get rid of side effects when creating a vcpu Cornelia Huck
@ 2016-03-09 17:28 ` Cornelia Huck
  2016-03-09 21:55   ` Thomas Huth
  2016-03-09 17:28 ` [Qemu-devel] [PATCH for-2.6 05/10] s390x/cpu: Add CPU property links Cornelia Huck
                   ` (5 subsequent siblings)
  9 siblings, 1 reply; 14+ messages in thread
From: Cornelia Huck @ 2016-03-09 17:28 UTC (permalink / raw)
  To: qemu-devel; +Cc: Matthew Rosato, borntraeger, jfrei, Cornelia Huck, agraf

From: Matthew Rosato <mjrosato@linux.vnet.ibm.com>

Once hotplug is enabled, interrupts may come in for CPUs
with an address > smp_cpus.  Allocate for this and allow
search routines to look beyond smp_cpus.

Signed-off-by: Matthew Rosato <mjrosato@linux.vnet.ibm.com>
Message-Id: <1457112875-5209-5-git-send-email-mjrosato@linux.vnet.ibm.com>
Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
---
 hw/s390x/s390-virtio.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/hw/s390x/s390-virtio.c b/hw/s390x/s390-virtio.c
index c501a48..57c3c88 100644
--- a/hw/s390x/s390-virtio.c
+++ b/hw/s390x/s390-virtio.c
@@ -58,15 +58,16 @@
 #define S390_TOD_CLOCK_VALUE_MISSING    0x00
 #define S390_TOD_CLOCK_VALUE_PRESENT    0x01
 
-static S390CPU **ipi_states;
+static S390CPU **cpu_states;
 
 S390CPU *s390_cpu_addr2state(uint16_t cpu_addr)
 {
-    if (cpu_addr >= smp_cpus) {
+    if (cpu_addr >= max_cpus) {
         return NULL;
     }
 
-    return ipi_states[cpu_addr];
+    /* Fast lookup via CPU ID */
+    return cpu_states[cpu_addr];
 }
 
 void s390_init_ipl_dev(const char *kernel_filename,
@@ -101,14 +102,14 @@ void s390_init_cpus(MachineState *machine)
         machine->cpu_model = "host";
     }
 
-    ipi_states = g_malloc(sizeof(S390CPU *) * smp_cpus);
+    cpu_states = g_malloc0(sizeof(S390CPU *) * max_cpus);
 
     for (i = 0; i < smp_cpus; i++) {
         S390CPU *cpu;
 
         cpu = cpu_s390x_init(machine->cpu_model);
 
-        ipi_states[i] = cpu;
+        cpu_states[i] = cpu;
     }
 }
 
-- 
2.3.9

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [Qemu-devel] [PATCH for-2.6 05/10] s390x/cpu: Add CPU property links
  2016-03-09 17:27 [Qemu-devel] [PATCH for-2.6 00/10] s390x patches for 2.6 Cornelia Huck
                   ` (3 preceding siblings ...)
  2016-03-09 17:28 ` [Qemu-devel] [PATCH for-2.6 04/10] s390x/cpu: Tolerate max_cpus Cornelia Huck
@ 2016-03-09 17:28 ` Cornelia Huck
  2016-03-09 17:28 ` [Qemu-devel] [PATCH for-2.6 06/10] s390x/cpu: Add error handling to cpu creation Cornelia Huck
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 14+ messages in thread
From: Cornelia Huck @ 2016-03-09 17:28 UTC (permalink / raw)
  To: qemu-devel; +Cc: Matthew Rosato, borntraeger, jfrei, Cornelia Huck, agraf

From: Matthew Rosato <mjrosato@linux.vnet.ibm.com>

Link each CPUState as property machine/cpu[n] during initialization.
Add a hotplug handler to s390-virtio-ccw machine and set the
state during plug.

Signed-off-by: Matthew Rosato <mjrosato@linux.vnet.ibm.com>
Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Message-Id: <1457112875-5209-6-git-send-email-mjrosato@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
---
 hw/s390x/s390-virtio-ccw.c | 34 ++++++++++++++++++++++++++++++++++
 hw/s390x/s390-virtio.c     | 17 ++++++++++++-----
 2 files changed, 46 insertions(+), 5 deletions(-)

diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
index b05ed8b..7fc1879 100644
--- a/hw/s390x/s390-virtio-ccw.c
+++ b/hw/s390x/s390-virtio-ccw.c
@@ -156,10 +156,41 @@ static void ccw_init(MachineState *machine)
                     gtod_save, gtod_load, kvm_state);
 }
 
+static void s390_cpu_plug(HotplugHandler *hotplug_dev,
+                        DeviceState *dev, Error **errp)
+{
+    gchar *name;
+    S390CPU *cpu = S390_CPU(dev);
+    CPUState *cs = CPU(dev);
+
+    name = g_strdup_printf("cpu[%i]", cpu->env.cpu_num);
+    object_property_set_link(OBJECT(hotplug_dev), OBJECT(cs), name,
+                             errp);
+    g_free(name);
+}
+
+static void s390_machine_device_plug(HotplugHandler *hotplug_dev,
+                                     DeviceState *dev, Error **errp)
+{
+    if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) {
+        s390_cpu_plug(hotplug_dev, dev, errp);
+    }
+}
+
+static HotplugHandler *s390_get_hotplug_handler(MachineState *machine,
+                                                DeviceState *dev)
+{
+    if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) {
+        return HOTPLUG_HANDLER(machine);
+    }
+    return NULL;
+}
+
 static void ccw_machine_class_init(ObjectClass *oc, void *data)
 {
     MachineClass *mc = MACHINE_CLASS(oc);
     NMIClass *nc = NMI_CLASS(oc);
+    HotplugHandlerClass *hc = HOTPLUG_HANDLER_CLASS(oc);
 
     mc->init = ccw_init;
     mc->reset = s390_machine_reset;
@@ -171,6 +202,8 @@ static void ccw_machine_class_init(ObjectClass *oc, void *data)
     mc->no_sdcard = 1;
     mc->use_sclp = 1;
     mc->max_cpus = 255;
+    mc->get_hotplug_handler = s390_get_hotplug_handler;
+    hc->plug = s390_machine_device_plug;
     nc->nmi_monitor_handler = s390_nmi;
 }
 
@@ -232,6 +265,7 @@ static const TypeInfo ccw_machine_info = {
     .class_init    = ccw_machine_class_init,
     .interfaces = (InterfaceInfo[]) {
         { TYPE_NMI },
+        { TYPE_HOTPLUG_HANDLER},
         { }
     },
 };
diff --git a/hw/s390x/s390-virtio.c b/hw/s390x/s390-virtio.c
index 57c3c88..f00d6b4 100644
--- a/hw/s390x/s390-virtio.c
+++ b/hw/s390x/s390-virtio.c
@@ -97,6 +97,7 @@ void s390_init_ipl_dev(const char *kernel_filename,
 void s390_init_cpus(MachineState *machine)
 {
     int i;
+    gchar *name;
 
     if (machine->cpu_model == NULL) {
         machine->cpu_model = "host";
@@ -104,12 +105,18 @@ void s390_init_cpus(MachineState *machine)
 
     cpu_states = g_malloc0(sizeof(S390CPU *) * max_cpus);
 
-    for (i = 0; i < smp_cpus; i++) {
-        S390CPU *cpu;
-
-        cpu = cpu_s390x_init(machine->cpu_model);
+    for (i = 0; i < max_cpus; i++) {
+        name = g_strdup_printf("cpu[%i]", i);
+        object_property_add_link(OBJECT(machine), name, TYPE_S390_CPU,
+                                 (Object **) &cpu_states[i],
+                                 object_property_allow_set_link,
+                                 OBJ_PROP_LINK_UNREF_ON_RELEASE,
+                                 &error_abort);
+        g_free(name);
+    }
 
-        cpu_states[i] = cpu;
+    for (i = 0; i < smp_cpus; i++) {
+        cpu_s390x_init(machine->cpu_model);
     }
 }
 
-- 
2.3.9

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [Qemu-devel] [PATCH for-2.6 06/10] s390x/cpu: Add error handling to cpu creation
  2016-03-09 17:27 [Qemu-devel] [PATCH for-2.6 00/10] s390x patches for 2.6 Cornelia Huck
                   ` (4 preceding siblings ...)
  2016-03-09 17:28 ` [Qemu-devel] [PATCH for-2.6 05/10] s390x/cpu: Add CPU property links Cornelia Huck
@ 2016-03-09 17:28 ` Cornelia Huck
  2016-03-09 17:28 ` [Qemu-devel] [PATCH for-2.6 07/10] s390x/cpu: Allow hotplug of CPUs Cornelia Huck
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 14+ messages in thread
From: Cornelia Huck @ 2016-03-09 17:28 UTC (permalink / raw)
  To: qemu-devel; +Cc: Matthew Rosato, borntraeger, jfrei, Cornelia Huck, agraf

From: Matthew Rosato <mjrosato@linux.vnet.ibm.com>

Check for and propogate errors during s390 cpu creation.

Signed-off-by: Matthew Rosato <mjrosato@linux.vnet.ibm.com>
Message-Id: <1457112875-5209-7-git-send-email-mjrosato@linux.vnet.ibm.com>
Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
---
 hw/s390x/s390-virtio.c |  2 +-
 target-s390x/cpu-qom.h |  1 +
 target-s390x/cpu.c     | 73 +++++++++++++++++++++++++++++++++++++++++++++++---
 target-s390x/cpu.h     |  2 ++
 target-s390x/helper.c  | 41 ++++++++++++++++++++++++++--
 5 files changed, 112 insertions(+), 7 deletions(-)

diff --git a/hw/s390x/s390-virtio.c b/hw/s390x/s390-virtio.c
index f00d6b4..4ea9040 100644
--- a/hw/s390x/s390-virtio.c
+++ b/hw/s390x/s390-virtio.c
@@ -116,7 +116,7 @@ void s390_init_cpus(MachineState *machine)
     }
 
     for (i = 0; i < smp_cpus; i++) {
-        cpu_s390x_init(machine->cpu_model);
+        s390x_new_cpu(machine->cpu_model, i, &error_fatal);
     }
 }
 
diff --git a/target-s390x/cpu-qom.h b/target-s390x/cpu-qom.h
index 56d82f2..1c90933 100644
--- a/target-s390x/cpu-qom.h
+++ b/target-s390x/cpu-qom.h
@@ -68,6 +68,7 @@ typedef struct S390CPU {
     /*< public >*/
 
     CPUS390XState env;
+    int64_t id;
     /* needed for live migration */
     void *irqstate;
     uint32_t irqstate_saved_size;
diff --git a/target-s390x/cpu.c b/target-s390x/cpu.c
index 76c8eaf..3ae38fa 100644
--- a/target-s390x/cpu.c
+++ b/target-s390x/cpu.c
@@ -30,8 +30,10 @@
 #include "qemu/error-report.h"
 #include "hw/hw.h"
 #include "trace.h"
+#include "qapi/visitor.h"
 #ifndef CONFIG_USER_ONLY
 #include "sysemu/arch_init.h"
+#include "sysemu/sysemu.h"
 #endif
 
 #define CR0_RESET       0xE0UL
@@ -199,16 +201,35 @@ static void s390_cpu_realizefn(DeviceState *dev, Error **errp)
     CPUS390XState *env = &cpu->env;
     Error *err = NULL;
 
+#if !defined(CONFIG_USER_ONLY)
+    if (cpu->id >= max_cpus) {
+        error_setg(&err, "Unable to add CPU: %" PRIi64
+                   ", max allowed: %d", cpu->id, max_cpus - 1);
+        goto out;
+    }
+#endif
+    if (cpu_exists(cpu->id)) {
+        error_setg(&err, "Unable to add CPU: %" PRIi64
+                   ", it already exists", cpu->id);
+        goto out;
+    }
+    if (cpu->id != scc->next_cpu_id) {
+        error_setg(&err, "Unable to add CPU: %" PRIi64
+                   ", The next available id is %" PRIi64, cpu->id,
+                   scc->next_cpu_id);
+        goto out;
+    }
+
     cpu_exec_init(cs, &err);
     if (err != NULL) {
-        error_propagate(errp, err);
-        return;
+        goto out;
     }
+    scc->next_cpu_id++;
 
 #if !defined(CONFIG_USER_ONLY)
     qemu_register_reset(s390_cpu_machine_reset_cb, cpu);
 #endif
-    env->cpu_num = scc->next_cpu_id++;
+    env->cpu_num = cpu->id;
     s390_cpu_gdb_init(cs);
     qemu_init_vcpu(cs);
 #if !defined(CONFIG_USER_ONLY)
@@ -217,7 +238,49 @@ static void s390_cpu_realizefn(DeviceState *dev, Error **errp)
     cpu_reset(cs);
 #endif
 
-    scc->parent_realize(dev, errp);
+    scc->parent_realize(dev, &err);
+
+out:
+    error_propagate(errp, err);
+}
+
+static void s390x_cpu_get_id(Object *obj, Visitor *v, const char *name,
+                             void *opaque, Error **errp)
+{
+    S390CPU *cpu = S390_CPU(obj);
+    int64_t value = cpu->id;
+
+    visit_type_int(v, name, &value, errp);
+}
+
+static void s390x_cpu_set_id(Object *obj, Visitor *v, const char *name,
+                             void *opaque, Error **errp)
+{
+    S390CPU *cpu = S390_CPU(obj);
+    DeviceState *dev = DEVICE(obj);
+    const int64_t min = 0;
+    const int64_t max = UINT32_MAX;
+    Error *err = NULL;
+    int64_t value;
+
+    if (dev->realized) {
+        error_setg(errp, "Attempt to set property '%s' on '%s' after "
+                   "it was realized", name, object_get_typename(obj));
+        return;
+    }
+
+    visit_type_int(v, name, &value, &err);
+    if (err) {
+        error_propagate(errp, err);
+        return;
+    }
+    if (value < min || value > max) {
+        error_setg(errp, "Property %s.%s doesn't take value %" PRId64
+                   " (minimum: %" PRId64 ", maximum: %" PRId64 ")" ,
+                   object_get_typename(obj), name, value, min, max);
+        return;
+    }
+    cpu->id = value;
 }
 
 static void s390_cpu_initfn(Object *obj)
@@ -233,6 +296,8 @@ static void s390_cpu_initfn(Object *obj)
     cs->env_ptr = env;
     cs->halted = 1;
     cs->exception_index = EXCP_HLT;
+    object_property_add(OBJECT(cpu), "id", "int64_t", s390x_cpu_get_id,
+                        s390x_cpu_set_id, NULL, NULL, NULL);
 #if !defined(CONFIG_USER_ONLY)
     qemu_get_timedate(&tm, 0);
     env->tod_offset = TOD_UNIX_EPOCH +
diff --git a/target-s390x/cpu.h b/target-s390x/cpu.h
index 49c8415..6d97c08 100644
--- a/target-s390x/cpu.h
+++ b/target-s390x/cpu.h
@@ -413,6 +413,8 @@ void trigger_pgm_exception(CPUS390XState *env, uint32_t code, uint32_t ilen);
 #endif
 
 S390CPU *cpu_s390x_init(const char *cpu_model);
+S390CPU *s390x_new_cpu(const char *cpu_model, int64_t id, Error **errp);
+S390CPU *cpu_s390x_create(const char *cpu_model, Error **errp);
 void s390x_translate_init(void);
 int cpu_s390x_exec(CPUState *cpu);
 
diff --git a/target-s390x/helper.c b/target-s390x/helper.c
index 838bdd9..76d5fbe 100644
--- a/target-s390x/helper.c
+++ b/target-s390x/helper.c
@@ -65,14 +65,51 @@ void s390x_cpu_timer(void *opaque)
 }
 #endif
 
-S390CPU *cpu_s390x_init(const char *cpu_model)
+S390CPU *cpu_s390x_create(const char *cpu_model, Error **errp)
 {
     S390CPU *cpu;
 
     cpu = S390_CPU(object_new(TYPE_S390_CPU));
 
-    object_property_set_bool(OBJECT(cpu), true, "realized", NULL);
+    return cpu;
+}
+
+S390CPU *s390x_new_cpu(const char *cpu_model, int64_t id, Error **errp)
+{
+    S390CPU *cpu;
+    Error *err = NULL;
+
+    cpu = cpu_s390x_create(cpu_model, &err);
+    if (err != NULL) {
+        goto out;
+    }
+
+    object_property_set_int(OBJECT(cpu), id, "id", &err);
+    if (err != NULL) {
+        goto out;
+    }
+    object_property_set_bool(OBJECT(cpu), true, "realized", &err);
 
+out:
+    if (err) {
+        error_propagate(errp, err);
+        object_unref(OBJECT(cpu));
+        cpu = NULL;
+    }
+    return cpu;
+}
+
+S390CPU *cpu_s390x_init(const char *cpu_model)
+{
+    Error *err = NULL;
+    S390CPU *cpu;
+    /* Use to track CPU ID for linux-user only */
+    static int64_t next_cpu_id;
+
+    cpu = s390x_new_cpu(cpu_model, next_cpu_id++, &err);
+    if (err) {
+        error_report_err(err);
+    }
     return cpu;
 }
 
-- 
2.3.9

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [Qemu-devel] [PATCH for-2.6 07/10] s390x/cpu: Allow hotplug of CPUs
  2016-03-09 17:27 [Qemu-devel] [PATCH for-2.6 00/10] s390x patches for 2.6 Cornelia Huck
                   ` (5 preceding siblings ...)
  2016-03-09 17:28 ` [Qemu-devel] [PATCH for-2.6 06/10] s390x/cpu: Add error handling to cpu creation Cornelia Huck
@ 2016-03-09 17:28 ` Cornelia Huck
  2016-03-09 17:28 ` [Qemu-devel] [PATCH for-2.6 08/10] pc-bios/s390-ccw: fix old bug in ptr increment Cornelia Huck
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 14+ messages in thread
From: Cornelia Huck @ 2016-03-09 17:28 UTC (permalink / raw)
  To: qemu-devel; +Cc: Matthew Rosato, borntraeger, jfrei, Cornelia Huck, agraf

From: Matthew Rosato <mjrosato@linux.vnet.ibm.com>

Implement cpu hotplug routine and add the machine hook.

Signed-off-by: Matthew Rosato <mjrosato@linux.vnet.ibm.com>
Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Message-Id: <1457112875-5209-8-git-send-email-mjrosato@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
---
 hw/s390x/s390-virtio-ccw.c | 10 ++++++++++
 target-s390x/cpu.c         |  7 +++++++
 2 files changed, 17 insertions(+)

diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
index 7fc1879..a84375b 100644
--- a/hw/s390x/s390-virtio-ccw.c
+++ b/hw/s390x/s390-virtio-ccw.c
@@ -186,6 +186,15 @@ static HotplugHandler *s390_get_hotplug_handler(MachineState *machine,
     return NULL;
 }
 
+static void s390_hot_add_cpu(const int64_t id, Error **errp)
+{
+    MachineState *machine = MACHINE(qdev_get_machine());
+    Error *err = NULL;
+
+    s390x_new_cpu(machine->cpu_model, id, &err);
+    error_propagate(errp, err);
+}
+
 static void ccw_machine_class_init(ObjectClass *oc, void *data)
 {
     MachineClass *mc = MACHINE_CLASS(oc);
@@ -194,6 +203,7 @@ static void ccw_machine_class_init(ObjectClass *oc, void *data)
 
     mc->init = ccw_init;
     mc->reset = s390_machine_reset;
+    mc->hot_add_cpu = s390_hot_add_cpu;
     mc->block_default_type = IF_VIRTIO;
     mc->no_cdrom = 1;
     mc->no_floppy = 1;
diff --git a/target-s390x/cpu.c b/target-s390x/cpu.c
index 3ae38fa..1cbf703 100644
--- a/target-s390x/cpu.c
+++ b/target-s390x/cpu.c
@@ -34,6 +34,7 @@
 #ifndef CONFIG_USER_ONLY
 #include "sysemu/arch_init.h"
 #include "sysemu/sysemu.h"
+#include "hw/s390x/sclp.h"
 #endif
 
 #define CR0_RESET       0xE0UL
@@ -240,6 +241,12 @@ static void s390_cpu_realizefn(DeviceState *dev, Error **errp)
 
     scc->parent_realize(dev, &err);
 
+#if !defined(CONFIG_USER_ONLY)
+    if (dev->hotplugged) {
+        raise_irq_cpu_hotplug();
+    }
+#endif
+
 out:
     error_propagate(errp, err);
 }
-- 
2.3.9

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [Qemu-devel] [PATCH for-2.6 08/10] pc-bios/s390-ccw: fix old bug in ptr increment
  2016-03-09 17:27 [Qemu-devel] [PATCH for-2.6 00/10] s390x patches for 2.6 Cornelia Huck
                   ` (6 preceding siblings ...)
  2016-03-09 17:28 ` [Qemu-devel] [PATCH for-2.6 07/10] s390x/cpu: Allow hotplug of CPUs Cornelia Huck
@ 2016-03-09 17:28 ` Cornelia Huck
  2016-03-09 17:28 ` [Qemu-devel] [PATCH for-2.6 09/10] s390x: Introduce machine definition macros Cornelia Huck
  2016-03-09 17:28 ` [Qemu-devel] [PATCH for-2.6 10/10] s390x: Introduce S390MachineClass Cornelia Huck
  9 siblings, 0 replies; 14+ messages in thread
From: Cornelia Huck @ 2016-03-09 17:28 UTC (permalink / raw)
  To: qemu-devel
  Cc: Cornelia Huck, borntraeger, jfrei, agraf,
	Eugene (jno) Dvurechenski

From: "Eugene (jno) Dvurechenski" <jno@linux.vnet.ibm.com>

We need to increment by the size of the structure, whereas 'ns' is 'uint8_t *'.

Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>
Acked-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Eugene (jno) Dvurechenski <jno@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
---
 pc-bios/s390-ccw/bootmap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pc-bios/s390-ccw/bootmap.c b/pc-bios/s390-ccw/bootmap.c
index 415508b..4925302 100644
--- a/pc-bios/s390-ccw/bootmap.c
+++ b/pc-bios/s390-ccw/bootmap.c
@@ -424,7 +424,7 @@ static void ipl_scsi(void)
     IPL_assert(magic_match(sec, ZIPL_MAGIC), "No zIPL magic");
 
     ns_end = sec + virtio_get_block_size();
-    for (ns = (sec + pte_len); (ns + pte_len) < ns_end; ns++) {
+    for (ns = (sec + pte_len); (ns + pte_len) < ns_end; ns += pte_len) {
         prog_table_entry = (ScsiBlockPtr *)ns;
         if (!prog_table_entry->blockno) {
             break;
-- 
2.3.9

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [Qemu-devel] [PATCH for-2.6 09/10] s390x: Introduce machine definition macros
  2016-03-09 17:27 [Qemu-devel] [PATCH for-2.6 00/10] s390x patches for 2.6 Cornelia Huck
                   ` (7 preceding siblings ...)
  2016-03-09 17:28 ` [Qemu-devel] [PATCH for-2.6 08/10] pc-bios/s390-ccw: fix old bug in ptr increment Cornelia Huck
@ 2016-03-09 17:28 ` Cornelia Huck
  2016-03-09 17:28 ` [Qemu-devel] [PATCH for-2.6 10/10] s390x: Introduce S390MachineClass Cornelia Huck
  9 siblings, 0 replies; 14+ messages in thread
From: Cornelia Huck @ 2016-03-09 17:28 UTC (permalink / raw)
  To: qemu-devel; +Cc: Cornelia Huck, borntraeger, jfrei, agraf, Janosch Frank

From: Janosch Frank <frankja@linux.vnet.ibm.com>

Most of the machine definition code looks the same between different
machine versions. The new DEFINE_CCW_MACHINE macro makes defining a
new machine easier by inserting standard machine version
definitions. This also makes it possible to propagate values between
machine versions.

The patch is inspired by code from hw/ppc/spapr.c

Signed-off-by: Janosch Frank <frankja@linux.vnet.ibm.com>
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
---
 hw/s390x/s390-virtio-ccw.c | 89 ++++++++++++++++++++++++----------------------
 1 file changed, 47 insertions(+), 42 deletions(-)

diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
index a84375b..16de63f 100644
--- a/hw/s390x/s390-virtio-ccw.c
+++ b/hw/s390x/s390-virtio-ccw.c
@@ -280,6 +280,35 @@ static const TypeInfo ccw_machine_info = {
     },
 };
 
+#define DEFINE_CCW_MACHINE(suffix, verstr, latest)                            \
+    static void ccw_machine_##suffix##_class_init(ObjectClass *oc,            \
+                                                  void *data)                 \
+    {                                                                         \
+        MachineClass *mc = MACHINE_CLASS(oc);                                 \
+        ccw_machine_##suffix##_class_options(mc);                             \
+        mc->desc = "VirtIO-ccw based S390 machine v" verstr;                  \
+        if (latest) {                                                         \
+            mc->alias = "s390-ccw-virtio";                                    \
+            mc->is_default = 1;                                               \
+        }                                                                     \
+    }                                                                         \
+    static void ccw_machine_##suffix##_instance_init(Object *obj)             \
+    {                                                                         \
+        MachineState *machine = MACHINE(obj);                                 \
+        ccw_machine_##suffix##_instance_options(machine);                     \
+    }                                                                         \
+    static const TypeInfo ccw_machine_##suffix##_info = {                     \
+        .name = MACHINE_TYPE_NAME("s390-ccw-virtio-" verstr),                 \
+        .parent = TYPE_S390_CCW_MACHINE,                                      \
+        .class_init = ccw_machine_##suffix##_class_init,                      \
+        .instance_init = ccw_machine_##suffix##_instance_init,                \
+    };                                                                        \
+    static void ccw_machine_register_##suffix(void)                           \
+    {                                                                         \
+        type_register_static(&ccw_machine_##suffix##_info);                   \
+    }                                                                         \
+    machine_init(ccw_machine_register_##suffix)
+
 #define CCW_COMPAT_2_5 \
         HW_COMPAT_2_5
 
@@ -324,63 +353,39 @@ static const TypeInfo ccw_machine_info = {
             .value    = "0",\
         },
 
-static void ccw_machine_2_4_class_init(ObjectClass *oc, void *data)
+static void ccw_machine_2_6_instance_options(MachineState *machine)
 {
-    MachineClass *mc = MACHINE_CLASS(oc);
-    static GlobalProperty compat_props[] = {
-        CCW_COMPAT_2_4
-        { /* end of list */ }
-    };
-
-    mc->desc = "VirtIO-ccw based S390 machine v2.4";
-    mc->compat_props = compat_props;
 }
 
-static const TypeInfo ccw_machine_2_4_info = {
-    .name          = MACHINE_TYPE_NAME("s390-ccw-virtio-2.4"),
-    .parent        = TYPE_S390_CCW_MACHINE,
-    .class_init    = ccw_machine_2_4_class_init,
-};
-
-static void ccw_machine_2_5_class_init(ObjectClass *oc, void *data)
+static void ccw_machine_2_6_class_options(MachineClass *mc)
 {
-    MachineClass *mc = MACHINE_CLASS(oc);
-    static GlobalProperty compat_props[] = {
-        CCW_COMPAT_2_5
-        { /* end of list */ }
-    };
-
-    mc->desc = "VirtIO-ccw based S390 machine v2.5";
-    mc->compat_props = compat_props;
 }
+DEFINE_CCW_MACHINE(2_6, "2.6", true);
 
-static const TypeInfo ccw_machine_2_5_info = {
-    .name          = MACHINE_TYPE_NAME("s390-ccw-virtio-2.5"),
-    .parent        = TYPE_S390_CCW_MACHINE,
-    .class_init    = ccw_machine_2_5_class_init,
-};
+static void ccw_machine_2_5_instance_options(MachineState *machine)
+{
+}
 
-static void ccw_machine_2_6_class_init(ObjectClass *oc, void *data)
+static void ccw_machine_2_5_class_options(MachineClass *mc)
 {
-    MachineClass *mc = MACHINE_CLASS(oc);
+    SET_MACHINE_COMPAT(mc, CCW_COMPAT_2_5);
+}
+DEFINE_CCW_MACHINE(2_5, "2.5", false);
 
-    mc->alias = "s390-ccw-virtio";
-    mc->desc = "VirtIO-ccw based S390 machine v2.6";
-    mc->is_default = 1;
+static void ccw_machine_2_4_instance_options(MachineState *machine)
+{
+    ccw_machine_2_5_instance_options(machine);
 }
 
-static const TypeInfo ccw_machine_2_6_info = {
-    .name          = MACHINE_TYPE_NAME("s390-ccw-virtio-2.6"),
-    .parent        = TYPE_S390_CCW_MACHINE,
-    .class_init    = ccw_machine_2_6_class_init,
-};
+static void ccw_machine_2_4_class_options(MachineClass *mc)
+{
+    SET_MACHINE_COMPAT(mc, CCW_COMPAT_2_4);
+}
+DEFINE_CCW_MACHINE(2_4, "2.4", false);
 
 static void ccw_machine_register_types(void)
 {
     type_register_static(&ccw_machine_info);
-    type_register_static(&ccw_machine_2_4_info);
-    type_register_static(&ccw_machine_2_5_info);
-    type_register_static(&ccw_machine_2_6_info);
 }
 
 type_init(ccw_machine_register_types)
-- 
2.3.9

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [Qemu-devel] [PATCH for-2.6 10/10] s390x: Introduce S390MachineClass
  2016-03-09 17:27 [Qemu-devel] [PATCH for-2.6 00/10] s390x patches for 2.6 Cornelia Huck
                   ` (8 preceding siblings ...)
  2016-03-09 17:28 ` [Qemu-devel] [PATCH for-2.6 09/10] s390x: Introduce machine definition macros Cornelia Huck
@ 2016-03-09 17:28 ` Cornelia Huck
  9 siblings, 0 replies; 14+ messages in thread
From: Cornelia Huck @ 2016-03-09 17:28 UTC (permalink / raw)
  To: qemu-devel; +Cc: Cornelia Huck, borntraeger, jfrei, agraf, Janosch Frank

From: Janosch Frank <frankja@linux.vnet.ibm.com>

As we now have the new machine definitions, that let us disable/enable
machine options more easily, we need a way to save them and make them
publicly available.

The new s390-virtio-ccw.h header exports the s390 ccw machine state
and class, so they can be easily used in other C files.

Signed-off-by: Janosch Frank <frankja@linux.vnet.ibm.com>
Acked-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
---
 hw/s390x/s390-virtio-ccw.c         | 15 +-------------
 include/hw/s390x/s390-virtio-ccw.h | 40 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 41 insertions(+), 14 deletions(-)
 create mode 100644 include/hw/s390x/s390-virtio-ccw.h

diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
index 16de63f..3d8c3c4 100644
--- a/hw/s390x/s390-virtio-ccw.c
+++ b/hw/s390x/s390-virtio-ccw.c
@@ -22,20 +22,7 @@
 #include "s390-pci-bus.h"
 #include "hw/s390x/storage-keys.h"
 #include "hw/compat.h"
-
-#define TYPE_S390_CCW_MACHINE               "s390-ccw-machine"
-
-#define S390_CCW_MACHINE(obj) \
-    OBJECT_CHECK(S390CcwMachineState, (obj), TYPE_S390_CCW_MACHINE)
-
-typedef struct S390CcwMachineState {
-    /*< private >*/
-    MachineState parent_obj;
-
-    /*< public >*/
-    bool aes_key_wrap;
-    bool dea_key_wrap;
-} S390CcwMachineState;
+#include "hw/s390x/s390-virtio-ccw.h"
 
 static const char *const reset_dev_types[] = {
     "virtual-css-bridge",
diff --git a/include/hw/s390x/s390-virtio-ccw.h b/include/hw/s390x/s390-virtio-ccw.h
new file mode 100644
index 0000000..ab08332
--- /dev/null
+++ b/include/hw/s390x/s390-virtio-ccw.h
@@ -0,0 +1,40 @@
+/*
+ * virtio ccw machine definitions
+ *
+ * Copyright 2012, 2016 IBM Corp.
+ * Author(s): Cornelia Huck <cornelia.huck@de.ibm.com>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or (at
+ * your option) any later version. See the COPYING file in the top-level
+ * directory.
+ */
+#ifndef HW_S390X_S390_VIRTIO_CCW_H
+#define HW_S390X_S390_VIRTIO_CCW_H
+
+#include "hw/boards.h"
+
+#define TYPE_S390_CCW_MACHINE               "s390-ccw-machine"
+
+#define S390_CCW_MACHINE(obj) \
+    OBJECT_CHECK(S390CcwMachineState, (obj), TYPE_S390_CCW_MACHINE)
+
+#define S390_MACHINE_CLASS(klass) \
+    OBJECT_CLASS_CHECK(S390CcwMachineClass, (klass), TYPE_S390_CCW_MACHINE)
+
+typedef struct S390CcwMachineState {
+    /*< private >*/
+    MachineState parent_obj;
+
+    /*< public >*/
+    bool aes_key_wrap;
+    bool dea_key_wrap;
+} S390CcwMachineState;
+
+typedef struct S390CcwMachineClass {
+    /*< private >*/
+    MachineClass parent_class;
+
+    /*< public >*/
+} S390CcwMachineClass;
+
+#endif
-- 
2.3.9

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [Qemu-devel] [PATCH for-2.6 04/10] s390x/cpu: Tolerate max_cpus
  2016-03-09 17:28 ` [Qemu-devel] [PATCH for-2.6 04/10] s390x/cpu: Tolerate max_cpus Cornelia Huck
@ 2016-03-09 21:55   ` Thomas Huth
  2016-03-10  9:52     ` Cornelia Huck
  0 siblings, 1 reply; 14+ messages in thread
From: Thomas Huth @ 2016-03-09 21:55 UTC (permalink / raw)
  To: Cornelia Huck, qemu-devel
  Cc: Matthew Rosato, borntraeger, jfrei, agraf, Markus Armbruster

On 09.03.2016 18:28, Cornelia Huck wrote:
> From: Matthew Rosato <mjrosato@linux.vnet.ibm.com>
> 
> Once hotplug is enabled, interrupts may come in for CPUs
> with an address > smp_cpus.  Allocate for this and allow
> search routines to look beyond smp_cpus.
> 
> Signed-off-by: Matthew Rosato <mjrosato@linux.vnet.ibm.com>
> Message-Id: <1457112875-5209-5-git-send-email-mjrosato@linux.vnet.ibm.com>
> Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
> Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
> ---
>  hw/s390x/s390-virtio.c | 11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/hw/s390x/s390-virtio.c b/hw/s390x/s390-virtio.c
> index c501a48..57c3c88 100644
> --- a/hw/s390x/s390-virtio.c
> +++ b/hw/s390x/s390-virtio.c
...
> @@ -101,14 +102,14 @@ void s390_init_cpus(MachineState *machine)
>          machine->cpu_model = "host";
>      }
>  
> -    ipi_states = g_malloc(sizeof(S390CPU *) * smp_cpus);
> +    cpu_states = g_malloc0(sizeof(S390CPU *) * max_cpus);

While you're at it, it might be better to use g_new0 here instead
(see e.g. https://patchwork.ozlabs.org/patch/517377/ for a description
why this is better).

 Thomas

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [Qemu-devel] [PATCH for-2.6 04/10] s390x/cpu: Tolerate max_cpus
  2016-03-09 21:55   ` Thomas Huth
@ 2016-03-10  9:52     ` Cornelia Huck
  2016-03-10 10:37       ` Thomas Huth
  0 siblings, 1 reply; 14+ messages in thread
From: Cornelia Huck @ 2016-03-10  9:52 UTC (permalink / raw)
  To: Thomas Huth
  Cc: Matthew Rosato, agraf, qemu-devel, Markus Armbruster, borntraeger,
	jfrei

On Wed, 9 Mar 2016 22:55:30 +0100
Thomas Huth <thuth@redhat.com> wrote:

> While you're at it, it might be better to use g_new0 here instead
> (see e.g. https://patchwork.ozlabs.org/patch/517377/ for a description
> why this is better).

Using g_new0 sounds sensible; but rather than respinning again, I'll
just put the following on top:

From 0a11840959f61861672858ce961fc34b71efa3be Mon Sep 17 00:00:00 2001
From: Cornelia Huck <cornelia.huck@de.ibm.com>
Date: Thu, 10 Mar 2016 10:19:46 +0100
Subject: [PATCH] s390x/cpu: use g_new0

Let's use g_new0 to allocate cpu_states.

Suggested-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
---
 hw/s390x/s390-virtio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/s390x/s390-virtio.c b/hw/s390x/s390-virtio.c
index 4ea9040..7c6e281 100644
--- a/hw/s390x/s390-virtio.c
+++ b/hw/s390x/s390-virtio.c
@@ -103,7 +103,7 @@ void s390_init_cpus(MachineState *machine)
         machine->cpu_model = "host";
     }
 
-    cpu_states = g_malloc0(sizeof(S390CPU *) * max_cpus);
+    cpu_states = g_new0(S390CPU *, max_cpus);
 
     for (i = 0; i < max_cpus; i++) {
         name = g_strdup_printf("cpu[%i]", i);
-- 
2.7.2

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [Qemu-devel] [PATCH for-2.6 04/10] s390x/cpu: Tolerate max_cpus
  2016-03-10  9:52     ` Cornelia Huck
@ 2016-03-10 10:37       ` Thomas Huth
  0 siblings, 0 replies; 14+ messages in thread
From: Thomas Huth @ 2016-03-10 10:37 UTC (permalink / raw)
  To: Cornelia Huck
  Cc: Matthew Rosato, agraf, qemu-devel, Markus Armbruster, borntraeger,
	jfrei

On 10.03.2016 10:52, Cornelia Huck wrote:
> On Wed, 9 Mar 2016 22:55:30 +0100
> Thomas Huth <thuth@redhat.com> wrote:
> 
>> While you're at it, it might be better to use g_new0 here instead
>> (see e.g. https://patchwork.ozlabs.org/patch/517377/ for a description
>> why this is better).
> 
> Using g_new0 sounds sensible; but rather than respinning again, I'll
> just put the following on top:
> 
> From 0a11840959f61861672858ce961fc34b71efa3be Mon Sep 17 00:00:00 2001
> From: Cornelia Huck <cornelia.huck@de.ibm.com>
> Date: Thu, 10 Mar 2016 10:19:46 +0100
> Subject: [PATCH] s390x/cpu: use g_new0
> 
> Let's use g_new0 to allocate cpu_states.
> 
> Suggested-by: Thomas Huth <thuth@redhat.com>
> Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
> ---
>  hw/s390x/s390-virtio.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/hw/s390x/s390-virtio.c b/hw/s390x/s390-virtio.c
> index 4ea9040..7c6e281 100644
> --- a/hw/s390x/s390-virtio.c
> +++ b/hw/s390x/s390-virtio.c
> @@ -103,7 +103,7 @@ void s390_init_cpus(MachineState *machine)
>          machine->cpu_model = "host";
>      }
>  
> -    cpu_states = g_malloc0(sizeof(S390CPU *) * max_cpus);
> +    cpu_states = g_new0(S390CPU *, max_cpus);
>  
>      for (i = 0; i < max_cpus; i++) {
>          name = g_strdup_printf("cpu[%i]", i);

Reviewed-by: Thomas Huth <thuth@redhat.com>

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2016-03-10 10:38 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-09 17:27 [Qemu-devel] [PATCH for-2.6 00/10] s390x patches for 2.6 Cornelia Huck
2016-03-09 17:27 ` [Qemu-devel] [PATCH for-2.6 01/10] s390x/cpu: Cleanup init in preparation for hotplug Cornelia Huck
2016-03-09 17:28 ` [Qemu-devel] [PATCH for-2.6 02/10] s390x/cpu: Set initial CPU state in common routine Cornelia Huck
2016-03-09 17:28 ` [Qemu-devel] [PATCH for-2.6 03/10] s390x/cpu: Get rid of side effects when creating a vcpu Cornelia Huck
2016-03-09 17:28 ` [Qemu-devel] [PATCH for-2.6 04/10] s390x/cpu: Tolerate max_cpus Cornelia Huck
2016-03-09 21:55   ` Thomas Huth
2016-03-10  9:52     ` Cornelia Huck
2016-03-10 10:37       ` Thomas Huth
2016-03-09 17:28 ` [Qemu-devel] [PATCH for-2.6 05/10] s390x/cpu: Add CPU property links Cornelia Huck
2016-03-09 17:28 ` [Qemu-devel] [PATCH for-2.6 06/10] s390x/cpu: Add error handling to cpu creation Cornelia Huck
2016-03-09 17:28 ` [Qemu-devel] [PATCH for-2.6 07/10] s390x/cpu: Allow hotplug of CPUs Cornelia Huck
2016-03-09 17:28 ` [Qemu-devel] [PATCH for-2.6 08/10] pc-bios/s390-ccw: fix old bug in ptr increment Cornelia Huck
2016-03-09 17:28 ` [Qemu-devel] [PATCH for-2.6 09/10] s390x: Introduce machine definition macros Cornelia Huck
2016-03-09 17:28 ` [Qemu-devel] [PATCH for-2.6 10/10] s390x: Introduce S390MachineClass Cornelia Huck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).