* [Qemu-devel] [PATCH] hw/ppc/spapr_cpu_core: Add a proper check for spapr machine
@ 2017-08-12 8:38 Thomas Huth
2017-08-12 10:16 ` [Qemu-devel] [Qemu-ppc] " Greg Kurz
2017-08-12 13:02 ` [Qemu-devel] " Eduardo Habkost
0 siblings, 2 replies; 6+ messages in thread
From: Thomas Huth @ 2017-08-12 8:38 UTC (permalink / raw)
To: qemu-devel, David Gibson; +Cc: qemu-ppc, Eduardo Habkost, Bharata B Rao
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;
+ }
+
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},
--
1.8.3.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [Qemu-ppc] [PATCH] hw/ppc/spapr_cpu_core: Add a proper check for spapr machine
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 ` Greg Kurz
2017-08-13 19:35 ` Greg Kurz
2017-08-14 3:24 ` David Gibson
2017-08-12 13:02 ` [Qemu-devel] " Eduardo Habkost
1 sibling, 2 replies; 6+ messages in thread
From: Greg Kurz @ 2017-08-12 10:16 UTC (permalink / raw)
To: Thomas Huth
Cc: qemu-devel, David Gibson, qemu-ppc, Eduardo Habkost, Bharata B Rao
[-- Attachment #1: Type: text/plain, Size: 2723 bytes --]
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() ?
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},
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] hw/ppc/spapr_cpu_core: Add a proper check for spapr machine
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-12 13:02 ` Eduardo Habkost
1 sibling, 0 replies; 6+ messages in thread
From: Eduardo Habkost @ 2017-08-12 13:02 UTC (permalink / raw)
To: Thomas Huth; +Cc: qemu-devel, David Gibson, qemu-ppc, Bharata B Rao
On Sat, Aug 12, 2017 at 10:38:10AM +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>
> ---
> 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;
> + }
> +
> 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"},
device/machine whitelist entries are preferred, if possible.
This way, we can set expected=True and device-crash-test will
avoid testing a device/machine combination known to be
incompatible (when running in quick mode), or print a warning if
it doesn't fail as expected (when running in full mode).
I suggest the following (untested):
# "spapr-cpu-core needs a pseries machine"
{'machine':'(?!pseries.*)', 'device':'.*-spapr-cpu-core', 'expected':True},
--
Eduardo
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [Qemu-ppc] [PATCH] hw/ppc/spapr_cpu_core: Add a proper check for spapr machine
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
1 sibling, 0 replies; 6+ messages in thread
From: Greg Kurz @ 2017-08-13 19:35 UTC (permalink / raw)
To: Thomas Huth
Cc: Bharata B Rao, qemu-ppc, qemu-devel, Eduardo Habkost, David Gibson
[-- Attachment #1: Type: text/plain, Size: 3389 bytes --]
On Sat, 12 Aug 2017 12:16:51 +0200
Greg Kurz <groug@kaod.org> 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() ?
>
> 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.
>
And spapr_cpu_init() doesn't even need the spapr machine object itself: it
only needs the TYPE_PPC_VIRTUAL_HYPERVISOR object. I guess the right fix
would be for spapr cpu core to have a "ppc-virtual-hypervisor property set
in spapr_cpu_init() and tested in spapr_cpu_core_realize(). If the change
is considered to be too invasive during hard freeze, I guess a sanity check
in spapr_cpu_core_realize() is enough for now as a temporary bug fix.
> > 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},
>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [Qemu-ppc] [PATCH] hw/ppc/spapr_cpu_core: Add a proper check for spapr machine
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
2017-08-14 5:34 ` Thomas Huth
1 sibling, 1 reply; 6+ messages in thread
From: David Gibson @ 2017-08-14 3:24 UTC (permalink / raw)
To: Greg Kurz
Cc: Thomas Huth, qemu-devel, qemu-ppc, Eduardo Habkost, Bharata B Rao
[-- 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 --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [Qemu-ppc] [PATCH] hw/ppc/spapr_cpu_core: Add a proper check for spapr machine
2017-08-14 3:24 ` David Gibson
@ 2017-08-14 5:34 ` Thomas Huth
0 siblings, 0 replies; 6+ messages in thread
From: Thomas Huth @ 2017-08-14 5:34 UTC (permalink / raw)
To: David Gibson, Greg Kurz
Cc: qemu-devel, qemu-ppc, Eduardo Habkost, Bharata B Rao
[-- Attachment #1: Type: text/plain, Size: 2350 bytes --]
On 14.08.2017 05:24, David Gibson wrote:
> 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.
I was not sure, either ;-) Anyway, it's not a bug that blocks normal
usage of QEMU, and apparently there's a better but more extensive way to
fix this, so let's postpone this to 2.11.
Thomas
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2017-08-14 5:34 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2017-08-14 5:34 ` Thomas Huth
2017-08-12 13:02 ` [Qemu-devel] " Eduardo Habkost
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.