[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL v2 29/38] s390x: get rid of cpu_states and use possib
From: |
Cornelia Huck |
Subject: |
[Qemu-devel] [PULL v2 29/38] s390x: get rid of cpu_states and use possible_cpus instead |
Date: |
Tue, 19 Sep 2017 18:43:28 +0200 |
From: David Hildenbrand <address@hidden>
Now that we have possible_cpus, we can get rid of the global variable
and rewrite s390_cpu_addr2state() to use it.
Signed-off-by: David Hildenbrand <address@hidden>
Message-Id: <address@hidden>
Reviewed-by: Igor Mammedov <address@hidden>
Signed-off-by: Cornelia Huck <address@hidden>
---
hw/s390x/s390-virtio-ccw.c | 36 ++++++++++--------------------------
1 file changed, 10 insertions(+), 26 deletions(-)
diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
index b7b2b7ebcd..0caf20b719 100644
--- a/hw/s390x/s390-virtio-ccw.c
+++ b/hw/s390x/s390-virtio-ccw.c
@@ -36,23 +36,26 @@
#include "qapi/qmp/qerror.h"
#include "hw/nmi.h"
-static S390CPU **cpu_states;
-
S390CPU *s390_cpu_addr2state(uint16_t cpu_addr)
{
- if (cpu_addr >= max_cpus) {
- return NULL;
+ static MachineState *ms;
+
+ if (!ms) {
+ ms = MACHINE(qdev_get_machine());
+ g_assert(ms->possible_cpus);
}
- /* Fast lookup via CPU ID */
- return cpu_states[cpu_addr];
+ /* CPU address corresponds to the core_id and the index */
+ if (cpu_addr >= ms->possible_cpus->len) {
+ return NULL;
+ }
+ return S390_CPU(ms->possible_cpus->cpus[cpu_addr].cpu);
}
static void s390_init_cpus(MachineState *machine)
{
MachineClass *mc = MACHINE_GET_CLASS(machine);
int i;
- gchar *name;
if (machine->cpu_model == NULL) {
machine->cpu_model = s390_default_cpu_model_name();
@@ -63,18 +66,6 @@ static void s390_init_cpus(MachineState *machine)
exit(1);
}
- cpu_states = g_new0(S390CPU *, max_cpus);
-
- 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);
- }
-
/* initialize possible_cpus */
mc->possible_cpu_arch_ids(machine);
@@ -312,15 +303,8 @@ static void ccw_init(MachineState *machine)
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);
-
- name = g_strdup_printf("cpu[%i]", cpu->env.core_id);
- 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);
--
2.13.5
- [Qemu-devel] [PULL v2 19/38] target/s390x: use trigger_pgm_exception() in s390_cpu_handle_mmu_fault(), (continued)
- [Qemu-devel] [PULL v2 19/38] target/s390x: use trigger_pgm_exception() in s390_cpu_handle_mmu_fault(), Cornelia Huck, 2017/09/19
- [Qemu-devel] [PULL v2 20/38] target/s390x: use program_interrupt() in per_check_exception(), Cornelia Huck, 2017/09/19
- [Qemu-devel] [PULL v2 21/38] s390x: allow only 1 CPU with TCG, Cornelia Huck, 2017/09/19
- [Qemu-devel] [PULL v2 22/38] target/s390x: set cpu->id for linux user when realizing, Cornelia Huck, 2017/09/19
- [Qemu-devel] [PULL v2 23/38] target/s390x: use "core-id" for cpu number/address/id handling, Cornelia Huck, 2017/09/19
- [Qemu-devel] [PULL v2 24/38] target/s390x: rename next_cpu_id to next_core_id, Cornelia Huck, 2017/09/19
- [Qemu-devel] [PULL v2 25/38] s390x: print CPU definitions in sorted order, Cornelia Huck, 2017/09/19
- [Qemu-devel] [PULL v2 26/38] s390x: allow cpu hotplug via device_add, Cornelia Huck, 2017/09/19
- [Qemu-devel] [PULL v2 27/38] s390x: CPU hot unplug via device_del cannot work for now, Cornelia Huck, 2017/09/19
- [Qemu-devel] [PULL v2 28/38] s390x: implement query-hotpluggable-cpus, Cornelia Huck, 2017/09/19
- [Qemu-devel] [PULL v2 29/38] s390x: get rid of cpu_states and use possible_cpus instead,
Cornelia Huck <=
- [Qemu-devel] [PULL v2 31/38] s390x: generate sclp cpu information from possible_cpus, Cornelia Huck, 2017/09/19
- [Qemu-devel] [PULL v2 30/38] s390x: get rid of cpu_s390x_create(), Cornelia Huck, 2017/09/19
- [Qemu-devel] [PULL v2 32/38] s390x: allow CPU hotplug in random core-id order, Cornelia Huck, 2017/09/19
- [Qemu-devel] [PULL v2 33/38] virtio-ccw: remove stale comments on endianness, Cornelia Huck, 2017/09/19
- [Qemu-devel] [PULL v2 35/38] s390x/ccw: create s390 phb for compat reasons as well, Cornelia Huck, 2017/09/19
- [Qemu-devel] [PULL v2 34/38] configure: Allow --enable-seccomp on s390x, too, Cornelia Huck, 2017/09/19
- [Qemu-devel] [PULL v2 36/38] virtio-gpu: Handle endian conversion, Cornelia Huck, 2017/09/19
- [Qemu-devel] [PULL v2 37/38] virtio-ccw: Create a virtio gpu device for the ccw bus, Cornelia Huck, 2017/09/19
- [Qemu-devel] [PULL v2 38/38] MAINTAINERS/s390x: add terminal3270.c, Cornelia Huck, 2017/09/19
- Re: [Qemu-devel] [PULL v2 00/38] various s390x patches (+some fixes), Christian Borntraeger, 2017/09/19