All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] spapr_cpu_core: fail gracefully with non-pseries machine types
@ 2017-09-11 20:52 Greg Kurz
  2017-09-12  4:10 ` David Gibson
  0 siblings, 1 reply; 2+ messages in thread
From: Greg Kurz @ 2017-09-11 20:52 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-ppc, David Gibson, Sam Bobroff

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>
---
 hw/ppc/spapr_cpu_core.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c
index d04d1e0d8164..dc9df0d393d1 100644
--- a/hw/ppc/spapr_cpu_core.c
+++ b/hw/ppc/spapr_cpu_core.c
@@ -201,7 +201,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));
@@ -211,7 +211,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;
     }

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

* Re: [Qemu-devel] [PATCH] spapr_cpu_core: fail gracefully with non-pseries machine types
  2017-09-11 20:52 [Qemu-devel] [PATCH] spapr_cpu_core: fail gracefully with non-pseries machine types Greg Kurz
@ 2017-09-12  4:10 ` David Gibson
  0 siblings, 0 replies; 2+ messages in thread
From: David Gibson @ 2017-09-12  4:10 UTC (permalink / raw)
  To: Greg Kurz; +Cc: qemu-devel, qemu-ppc, Sam Bobroff

[-- Attachment #1: Type: text/plain, Size: 1739 bytes --]

On Mon, Sep 11, 2017 at 10:52:06PM +0200, Greg Kurz wrote:
> 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>

Applied to ppc-for-2.11.

> ---
>  hw/ppc/spapr_cpu_core.c |    5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c
> index d04d1e0d8164..dc9df0d393d1 100644
> --- a/hw/ppc/spapr_cpu_core.c
> +++ b/hw/ppc/spapr_cpu_core.c
> @@ -201,7 +201,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));
> @@ -211,7 +211,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;
>      }
> 

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

end of thread, other threads:[~2017-09-12  4:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-11 20:52 [Qemu-devel] [PATCH] spapr_cpu_core: fail gracefully with non-pseries machine types Greg Kurz
2017-09-12  4:10 ` David Gibson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.