qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: Thomas Huth <thuth@redhat.com>
Cc: 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] [PATCH v2 for-2.11] hw/ppc/spapr_cpu_core: Add a proper check for spapr machine
Date: Thu, 24 Aug 2017 13:57:30 +1000	[thread overview]
Message-ID: <20170824035730.GE5379@umbus.fritz.box> (raw)
In-Reply-To: <1503546752-24569-1-git-send-email-thuth@redhat.com>

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

On Thu, Aug 24, 2017 at 05:52:32AM +0200, Thomas Huth 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>

Applied to ppc-for-2.11, thanks.

> ---
>  v2:
>  - Add the check to spapr_cpu_core_realize() instead of adding it to
>    spapr_cpu_core_realize_child()
>  - Use device/machine whitelist for the device-crash-test instead of
>    adding a log entry there
> 
>  hw/ppc/spapr_cpu_core.c   | 5 +++++
>  scripts/device-crash-test | 3 +++
>  2 files changed, 8 insertions(+)
> 
> diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c
> index ea278ce..dd92326 100644
> --- a/hw/ppc/spapr_cpu_core.c
> +++ b/hw/ppc/spapr_cpu_core.c
> @@ -220,6 +220,11 @@ 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)) {
> +        error_setg(errp, "spapr-cpu-core needs a pseries machine");
> +        return;
> +    }
> +
>      sc->threads = g_malloc0(size * cc->nr_threads);
>      for (i = 0; i < cc->nr_threads; i++) {
>          char id[32];
> diff --git a/scripts/device-crash-test b/scripts/device-crash-test
> index 81d65b9..043b24a 100755
> --- a/scripts/device-crash-test
> +++ b/scripts/device-crash-test
> @@ -160,6 +160,9 @@ ERROR_WHITELIST = [
>      {'machine':'q35|pc.*', 'device':'kvm-ioapic', 'expected':True}, # Only 1 ioapics allowed
>      {'machine':'q35|pc.*', 'device':'ioapic', 'expected':True},     # Only 1 ioapics allowed
>  
> +    # "spapr-cpu-core needs a pseries machine"
> +    {'machine':'(?!pseries).*', 'device':'.*-spapr-cpu-core', 'expected':True},
> +
>      # KVM-specific devices shouldn't be tried without accel=kvm:
>      {'accel':'(?!kvm).*', 'device':'kvmclock', 'expected':True},
>      {'accel':'(?!kvm).*', 'device':'kvm-pci-assign', 'expected':True},

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

      reply	other threads:[~2017-08-24  3:58 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-24  3:52 [Qemu-devel] [PATCH v2 for-2.11] hw/ppc/spapr_cpu_core: Add a proper check for spapr machine Thomas Huth
2017-08-24  3:57 ` David Gibson [this message]

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=20170824035730.GE5379@umbus.fritz.box \
    --to=david@gibson.dropbear.id.au \
    --cc=bharata@linux.vnet.ibm.com \
    --cc=ehabkost@redhat.com \
    --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).