aboutsummaryrefslogtreecommitdiff
path: root/hw/s390x
diff options
context:
space:
mode:
authorDavid Hildenbrand <david@redhat.com>2017-09-13 15:24:13 +0200
committerCornelia Huck <cohuck@redhat.com>2017-09-19 18:31:32 +0200
commit4dc3b151882fe56f2917a3533d1bceb9fa9ded60 (patch)
tree8a47c1103f56d9671c435caa81a763cf8fc10e59 /hw/s390x
parentf2f3beb0040cbdad1b4098cbb11ecc102044bf6e (diff)
downloadqemu-4dc3b151882fe56f2917a3533d1bceb9fa9ded60.zip
qemu-4dc3b151882fe56f2917a3533d1bceb9fa9ded60.tar.gz
qemu-4dc3b151882fe56f2917a3533d1bceb9fa9ded60.tar.bz2
s390x: implement query-hotpluggable-cpus
CPU hotplug is only possible on a per core basis on s390x. So let's add possible_cpus and wire everything up properly. Signed-off-by: David Hildenbrand <david@redhat.com> Message-Id: <20170913132417.24384-19-david@redhat.com> Acked-by: Igor Mammedov <imammedo@redhat.com> Signed-off-by: Cornelia Huck <cohuck@redhat.com>
Diffstat (limited to 'hw/s390x')
-rw-r--r--hw/s390x/s390-virtio-ccw.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
index acdd535..b7b2b7e 100644
--- a/hw/s390x/s390-virtio-ccw.c
+++ b/hw/s390x/s390-virtio-ccw.c
@@ -50,6 +50,7 @@ S390CPU *s390_cpu_addr2state(uint16_t cpu_addr)
static void s390_init_cpus(MachineState *machine)
{
+ MachineClass *mc = MACHINE_GET_CLASS(machine);
int i;
gchar *name;
@@ -74,6 +75,9 @@ static void s390_init_cpus(MachineState *machine)
g_free(name);
}
+ /* initialize possible_cpus */
+ mc->possible_cpu_arch_ids(machine);
+
for (i = 0; i < smp_cpus; i++) {
s390x_new_cpu(machine->cpu_model, i, &error_fatal);
}
@@ -309,6 +313,7 @@ static void s390_cpu_plug(HotplugHandler *hotplug_dev,
DeviceState *dev, Error **errp)
{
gchar *name;
+ MachineState *ms = MACHINE(hotplug_dev);
S390CPU *cpu = S390_CPU(dev);
CPUState *cs = CPU(dev);
@@ -316,6 +321,9 @@ static void s390_cpu_plug(HotplugHandler *hotplug_dev,
object_property_set_link(OBJECT(hotplug_dev), OBJECT(cs), name,
errp);
g_free(name);
+
+ g_assert(!ms->possible_cpus->cpus[cpu->env.core_id].cpu);
+ ms->possible_cpus->cpus[cpu->env.core_id].cpu = OBJECT(dev);
}
static void s390_machine_reset(void)
@@ -348,6 +356,36 @@ static void s390_machine_device_unplug_request(HotplugHandler *hotplug_dev,
}
}
+static CpuInstanceProperties s390_cpu_index_to_props(MachineState *machine,
+ unsigned cpu_index)
+{
+ g_assert(machine->possible_cpus && cpu_index < machine->possible_cpus->len);
+
+ return machine->possible_cpus->cpus[cpu_index].props;
+}
+
+static const CPUArchIdList *s390_possible_cpu_arch_ids(MachineState *ms)
+{
+ int i;
+
+ if (ms->possible_cpus) {
+ g_assert(ms->possible_cpus && ms->possible_cpus->len == max_cpus);
+ return ms->possible_cpus;
+ }
+
+ ms->possible_cpus = g_malloc0(sizeof(CPUArchIdList) +
+ sizeof(CPUArchId) * max_cpus);
+ ms->possible_cpus->len = max_cpus;
+ for (i = 0; i < ms->possible_cpus->len; i++) {
+ ms->possible_cpus->cpus[i].vcpus_count = 1;
+ ms->possible_cpus->cpus[i].arch_id = i;
+ ms->possible_cpus->cpus[i].props.has_core_id = true;
+ ms->possible_cpus->cpus[i].props.core_id = i;
+ }
+
+ return ms->possible_cpus;
+}
+
static HotplugHandler *s390_get_hotplug_handler(MachineState *machine,
DeviceState *dev)
{
@@ -395,7 +433,10 @@ static void ccw_machine_class_init(ObjectClass *oc, void *data)
mc->no_sdcard = 1;
mc->use_sclp = 1;
mc->max_cpus = 248;
+ mc->has_hotpluggable_cpus = true;
mc->get_hotplug_handler = s390_get_hotplug_handler;
+ mc->cpu_index_to_instance_props = s390_cpu_index_to_props;
+ mc->possible_cpu_arch_ids = s390_possible_cpu_arch_ids;
hc->plug = s390_machine_device_plug;
hc->unplug_request = s390_machine_device_unplug_request;
nc->nmi_monitor_handler = s390_nmi;