qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: Greg Kurz <groug@kaod.org>
Cc: Thomas Huth <thuth@redhat.com>,
	qemu-devel@nongnu.org, qemu-ppc@nongnu.org,
	Eduardo Habkost <ehabkost@redhat.com>,
	Bharata B Rao <bharata@linux.vnet.ibm.com>
Subject: Re: [Qemu-devel] [Qemu-ppc] [PATCH] hw/ppc/spapr_cpu_core: Add a proper check for spapr machine
Date: Mon, 14 Aug 2017 13:24:56 +1000	[thread overview]
Message-ID: <20170814032456.GA3452@umbus.fritz.box> (raw)
In-Reply-To: <20170812121651.497c6e39@bahia.lan>

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

On Sat, Aug 12, 2017 at 12:16:51PM +0200, Greg Kurz wrote:
> On Sat, 12 Aug 2017 10:38:10 +0200
> Thomas Huth <thuth@redhat.com> wrote:
> 
> > QEMU currently crashes when the user tries to add a spapr-cpu-core
> > on a non-pseries machine:
> > 
> > $ qemu-system-ppc64 -S -machine ppce500,accel=tcg \
> >                     -device POWER5+_v2.1-spapr-cpu-core
> > hw/ppc/spapr_cpu_core.c:178:spapr_cpu_core_realize_child:
> > Object 0x55cee1f55160 is not an instance of type spapr-machine
> > Aborted (core dumped)
> > 
> > So let's add a proper check for the correct machine time with
> > a more friendly error message here.
> > 
> > Reported-by: Eduardo Habkost <ehabkost@redhat.com>
> > Signed-off-by: Thomas Huth <thuth@redhat.com>
> > ---
> >  hw/ppc/spapr_cpu_core.c   | 9 ++++++++-
> >  scripts/device-crash-test | 1 +
> >  2 files changed, 9 insertions(+), 1 deletion(-)
> > 
> > diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c
> > index ea278ce..0f3d653 100644
> > --- a/hw/ppc/spapr_cpu_core.c
> > +++ b/hw/ppc/spapr_cpu_core.c
> > @@ -175,11 +175,18 @@ static void spapr_cpu_core_unrealizefn(DeviceState *dev, Error **errp)
> >  static void spapr_cpu_core_realize_child(Object *child, Error **errp)
> >  {
> >      Error *local_err = NULL;
> > -    sPAPRMachineState *spapr = SPAPR_MACHINE(qdev_get_machine());
> > +    sPAPRMachineState *spapr;
> >      CPUState *cs = CPU(child);
> >      PowerPCCPU *cpu = POWERPC_CPU(cs);
> >      Object *obj;
> >  
> > +    spapr = (sPAPRMachineState *)object_dynamic_cast(qdev_get_machine(),
> > +                                                     TYPE_SPAPR_MACHINE);
> > +    if (!spapr) {
> > +        error_setg(errp, "spapr-cpu-core needs a pseries machine");
> > +        return;
> > +    }
> > +
> 
> This is the realize function for individual threads. Maybe this sanity check
> should be performed earlier at the core level in spapr_cpu_core_realize() ?

Ah, yes, that would be a better way of doing it.

I'm also not clear if you're proposing this for 2.10 or 2.11.

> Also, spapr_cpu_core_realize_child() seem to only have spapr to pass it down
> to spapr_cpu_init()... ie, not even sure spapr_cpu_core_realize_child()
> actually needs a spapr variable.



> 
> >      object_property_set_bool(child, true, "realized", &local_err);
> >      if (local_err) {
> >          goto error;
> > diff --git a/scripts/device-crash-test b/scripts/device-crash-test
> > index e77b693..8eb2d02 100755
> > --- a/scripts/device-crash-test
> > +++ b/scripts/device-crash-test
> > @@ -200,6 +200,7 @@ ERROR_WHITELIST = [
> >      {'log':r"Multiple VT220 operator consoles are not supported"},
> >      {'log':r"core 0 already populated"},
> >      {'log':r"could not find stage1 bootloader"},
> > +    {'log':r"spapr-cpu-core needs a pseries machine"},
> >  
> >      # other exitcode=1 failures not listed above will just generate INFO messages:
> >      {'exitcode':1, 'loglevel':logging.INFO},
> 



-- 
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 --]

  parent reply	other threads:[~2017-08-14  4:38 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-12  8:38 [Qemu-devel] [PATCH] hw/ppc/spapr_cpu_core: Add a proper check for spapr machine Thomas Huth
2017-08-12 10:16 ` [Qemu-devel] [Qemu-ppc] " Greg Kurz
2017-08-13 19:35   ` Greg Kurz
2017-08-14  3:24   ` David Gibson [this message]
2017-08-14  5:34     ` Thomas Huth
2017-08-12 13:02 ` [Qemu-devel] " Eduardo Habkost

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170814032456.GA3452@umbus.fritz.box \
    --to=david@gibson.dropbear.id.au \
    --cc=bharata@linux.vnet.ibm.com \
    --cc=ehabkost@redhat.com \
    --cc=groug@kaod.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    --cc=thuth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).