[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 34/34] spapr_cpu_core: rewrite machine type sanity ch
From: |
David Gibson |
Subject: |
[Qemu-devel] [PULL 34/34] spapr_cpu_core: rewrite machine type sanity check |
Date: |
Tue, 17 Oct 2017 15:21:52 +1100 |
From: Greg Kurz <address@hidden>
This makes the code easier to understand and it is consistent with what
we already do for PHBs.
Signed-off-by: Greg Kurz <address@hidden>
Signed-off-by: David Gibson <address@hidden>
---
hw/ppc/spapr_cpu_core.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c
index 195762d8d2..3a4c174012 100644
--- a/hw/ppc/spapr_cpu_core.c
+++ b/hw/ppc/spapr_cpu_core.c
@@ -137,7 +137,12 @@ error:
static void spapr_cpu_core_realize(DeviceState *dev, Error **errp)
{
- sPAPRMachineState *spapr;
+ /* We don't use SPAPR_MACHINE() in order to exit gracefully if the user
+ * tries to add a sPAPR CPU core to a non-pseries machine.
+ */
+ sPAPRMachineState *spapr =
+ (sPAPRMachineState *) object_dynamic_cast(qdev_get_machine(),
+ TYPE_SPAPR_MACHINE);
sPAPRCPUCore *sc = SPAPR_CPU_CORE(OBJECT(dev));
sPAPRCPUCoreClass *scc = SPAPR_CPU_CORE_GET_CLASS(OBJECT(dev));
CPUCore *cc = CPU_CORE(OBJECT(dev));
@@ -146,9 +151,8 @@ static void spapr_cpu_core_realize(DeviceState *dev, Error
**errp)
void *obj;
int i, j;
- spapr = (sPAPRMachineState *) qdev_get_machine();
- if (!object_dynamic_cast((Object *) spapr, TYPE_SPAPR_MACHINE)) {
- error_setg(errp, "spapr-cpu-core needs a pseries machine");
+ if (!spapr) {
+ error_setg(errp, TYPE_SPAPR_CPU_CORE " needs a pseries machine");
return;
}
--
2.13.6
- [Qemu-devel] [PULL 16/34] ppc: virtex-ml507: replace cpu_model with cpu_type, (continued)
- [Qemu-devel] [PULL 16/34] ppc: virtex-ml507: replace cpu_model with cpu_type, David Gibson, 2017/10/17
- [Qemu-devel] [PULL 09/34] qom: introduce type_register_static_array(), David Gibson, 2017/10/17
- [Qemu-devel] [PULL 22/34] ppc: spapr: register 'host' core type along with the rest of core types, David Gibson, 2017/10/17
- [Qemu-devel] [PULL 24/34] ppc: move ppc_cpu_lookup_alias() before its first user, David Gibson, 2017/10/17
- [Qemu-devel] [PULL 07/34] target/ppc: Fix carry flag setting for shift algebraic instructions, David Gibson, 2017/10/17
- [Qemu-devel] [PULL 10/34] qom: add helper macro DEFINE_TYPES(), David Gibson, 2017/10/17
- [Qemu-devel] [PULL 15/34] ppc: replace cpu_model with cpu_type on ref405ep, taihu boards, David Gibson, 2017/10/17
- [Qemu-devel] [PULL 23/34] ppc: spapr: use cpu model names as tcg defaults instead of aliases, David Gibson, 2017/10/17
- [Qemu-devel] [PULL 08/34] hw/ppc/spapr.c: abort unplug_request if previous unplug isn't done, David Gibson, 2017/10/17
- [Qemu-devel] [PULL 06/34] target/ppc: Add POWER9 DD2.0 model information, David Gibson, 2017/10/17
- [Qemu-devel] [PULL 34/34] spapr_cpu_core: rewrite machine type sanity check,
David Gibson <=
- [Qemu-devel] [PULL 18/34] ppc: spapr: replace ppc_cpu_parse_features() with cpu_parse_cpu_model(), David Gibson, 2017/10/17
- [Qemu-devel] [PULL 20/34] ppc: spapr: define core types statically, David Gibson, 2017/10/17
- [Qemu-devel] [PULL 28/34] ppc: pnv: drop PnvCoreClass::cpu_oc field, David Gibson, 2017/10/17
- [Qemu-devel] [PULL 21/34] ppc: spapr: use cpu type name directly, David Gibson, 2017/10/17
- [Qemu-devel] [PULL 19/34] ppc: move '-cpu foo, compat=xxx' parsing into ppc_cpu_parse_featurestr(), David Gibson, 2017/10/17
- [Qemu-devel] [PULL 27/34] ppc: pnv: normalize core/chip type names, David Gibson, 2017/10/17
- [Qemu-devel] [PULL 31/34] ppc: pnv: consolidate type definitions and batch register them, David Gibson, 2017/10/17
- [Qemu-devel] [PULL 29/34] ppc: pnv: define core types statically, David Gibson, 2017/10/17
- [Qemu-devel] [PULL 33/34] spapr_pci: fail gracefully with non-pseries machine types, David Gibson, 2017/10/17
- [Qemu-devel] [PULL 17/34] ppc: 40p/prep: replace cpu_model with cpu_type, David Gibson, 2017/10/17