diff options
author | Greg Kurz <groug@kaod.org> | 2017-09-11 22:52:06 +0200 |
---|---|---|
committer | David Gibson <david@gibson.dropbear.id.au> | 2017-09-15 10:29:48 +1000 |
commit | 1bbadc759e23ef8629ef955a4b78f06da2e5a381 (patch) | |
tree | 69f9533de5cb9b12f763ba30295f9c68813be201 /hw | |
parent | a1a6bbde4f6a29368f8f605cea2e73630ec1bc7c (diff) |
spapr_cpu_core: fail gracefully with non-pseries machine types
Since commit 7cca3e466eb0 ("ppc: spapr: Move VCPU ID calculation into
sPAPR"), QEMU aborts when started with a *-spapr-cpu-core device and
a non-pseries machine.
Let's rely on the already existing call to object_dynamic_cast() instead
of using the SPAPR_MACHINE() macro.
Signed-off-by: Greg Kurz <groug@kaod.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'hw')
-rw-r--r-- | hw/ppc/spapr_cpu_core.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c index 85037ef71e..3f7ef20910 100644 --- a/hw/ppc/spapr_cpu_core.c +++ b/hw/ppc/spapr_cpu_core.c @@ -213,7 +213,7 @@ error: static void spapr_cpu_core_realize(DeviceState *dev, Error **errp) { - sPAPRMachineState *spapr = SPAPR_MACHINE(qdev_get_machine()); + sPAPRMachineState *spapr; sPAPRCPUCore *sc = SPAPR_CPU_CORE(OBJECT(dev)); sPAPRCPUCoreClass *scc = SPAPR_CPU_CORE_GET_CLASS(OBJECT(dev)); CPUCore *cc = CPU_CORE(OBJECT(dev)); @@ -223,7 +223,8 @@ static void spapr_cpu_core_realize(DeviceState *dev, Error **errp) void *obj; int i, j; - if (!object_dynamic_cast(qdev_get_machine(), TYPE_SPAPR_MACHINE)) { + spapr = (sPAPRMachineState *) qdev_get_machine(); + if (!object_dynamic_cast((Object *) spapr, TYPE_SPAPR_MACHINE)) { error_setg(errp, "spapr-cpu-core needs a pseries machine"); return; } |