* [Qemu-devel] [PATCH] spapr: fix check of cpu alias name in spapr_get_cpu_core_type()
@ 2016-10-03 12:13 Greg Kurz
2016-10-03 15:14 ` Bharata B Rao
0 siblings, 1 reply; 3+ messages in thread
From: Greg Kurz @ 2016-10-03 12:13 UTC (permalink / raw)
To: David Gibson; +Cc: qemu-ppc, qemu-devel, Bharata B Rao
If the user passes an alias name and a property to -cpu, QEMU fails to
find the CPU definition and exits.
$ qemu-system-ppc64 -cpu POWER8E,compat=power7
qemu-system-ppc64: Unable to find sPAPR CPU Core definition
This happens because spapr_get_cpu_core_type() passes the full string from
the command line (i.e. "POWER8E,compat=power7") to ppc_cpu_lookup_alias(),
instead of the alias name piece only (i.e. "POWER8E").
The fix is to pass model_pieces[0] to ppc_cpu_lookup_alias().
Signed-off-by: Greg Kurz <groug@kaod.org>
---
hw/ppc/spapr_cpu_core.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c
index 6f0533c34259..35d1873b9ff3 100644
--- a/hw/ppc/spapr_cpu_core.c
+++ b/hw/ppc/spapr_cpu_core.c
@@ -92,20 +92,20 @@ char *spapr_get_cpu_core_type(const char *model)
gchar **model_pieces = g_strsplit(model, ",", 2);
core_type = g_strdup_printf("%s-%s", model_pieces[0], TYPE_SPAPR_CPU_CORE);
- g_strfreev(model_pieces);
/* Check whether it exists or whether we have to look up an alias name */
if (!object_class_by_name(core_type)) {
const char *realmodel;
g_free(core_type);
- realmodel = ppc_cpu_lookup_alias(model);
+ core_type = NULL;
+ realmodel = ppc_cpu_lookup_alias(model_pieces[0]);
if (realmodel) {
- return spapr_get_cpu_core_type(realmodel);
+ core_type = spapr_get_cpu_core_type(realmodel);
}
- return NULL;
}
+ g_strfreev(model_pieces);
return core_type;
}
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] spapr: fix check of cpu alias name in spapr_get_cpu_core_type()
2016-10-03 12:13 [Qemu-devel] [PATCH] spapr: fix check of cpu alias name in spapr_get_cpu_core_type() Greg Kurz
@ 2016-10-03 15:14 ` Bharata B Rao
2016-10-04 0:20 ` David Gibson
0 siblings, 1 reply; 3+ messages in thread
From: Bharata B Rao @ 2016-10-03 15:14 UTC (permalink / raw)
To: Greg Kurz; +Cc: David Gibson, qemu-ppc, qemu-devel
On Mon, Oct 03, 2016 at 02:13:20PM +0200, Greg Kurz wrote:
> If the user passes an alias name and a property to -cpu, QEMU fails to
> find the CPU definition and exits.
>
> $ qemu-system-ppc64 -cpu POWER8E,compat=power7
> qemu-system-ppc64: Unable to find sPAPR CPU Core definition
>
> This happens because spapr_get_cpu_core_type() passes the full string from
> the command line (i.e. "POWER8E,compat=power7") to ppc_cpu_lookup_alias(),
> instead of the alias name piece only (i.e. "POWER8E").
>
> The fix is to pass model_pieces[0] to ppc_cpu_lookup_alias().
>
> Signed-off-by: Greg Kurz <groug@kaod.org>
Reviewed-by: Bharata B Rao <bharata@linux.vnet.ibm.com>
> ---
> hw/ppc/spapr_cpu_core.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c
> index 6f0533c34259..35d1873b9ff3 100644
> --- a/hw/ppc/spapr_cpu_core.c
> +++ b/hw/ppc/spapr_cpu_core.c
> @@ -92,20 +92,20 @@ char *spapr_get_cpu_core_type(const char *model)
> gchar **model_pieces = g_strsplit(model, ",", 2);
>
> core_type = g_strdup_printf("%s-%s", model_pieces[0], TYPE_SPAPR_CPU_CORE);
> - g_strfreev(model_pieces);
>
> /* Check whether it exists or whether we have to look up an alias name */
> if (!object_class_by_name(core_type)) {
> const char *realmodel;
>
> g_free(core_type);
> - realmodel = ppc_cpu_lookup_alias(model);
> + core_type = NULL;
> + realmodel = ppc_cpu_lookup_alias(model_pieces[0]);
> if (realmodel) {
> - return spapr_get_cpu_core_type(realmodel);
> + core_type = spapr_get_cpu_core_type(realmodel);
> }
> - return NULL;
> }
>
> + g_strfreev(model_pieces);
> return core_type;
> }
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] spapr: fix check of cpu alias name in spapr_get_cpu_core_type()
2016-10-03 15:14 ` Bharata B Rao
@ 2016-10-04 0:20 ` David Gibson
0 siblings, 0 replies; 3+ messages in thread
From: David Gibson @ 2016-10-04 0:20 UTC (permalink / raw)
To: Bharata B Rao; +Cc: Greg Kurz, qemu-ppc, qemu-devel
[-- Attachment #1: Type: text/plain, Size: 2246 bytes --]
On Mon, Oct 03, 2016 at 08:44:22PM +0530, Bharata B Rao wrote:
> On Mon, Oct 03, 2016 at 02:13:20PM +0200, Greg Kurz wrote:
> > If the user passes an alias name and a property to -cpu, QEMU fails to
> > find the CPU definition and exits.
> >
> > $ qemu-system-ppc64 -cpu POWER8E,compat=power7
> > qemu-system-ppc64: Unable to find sPAPR CPU Core definition
> >
> > This happens because spapr_get_cpu_core_type() passes the full string from
> > the command line (i.e. "POWER8E,compat=power7") to ppc_cpu_lookup_alias(),
> > instead of the alias name piece only (i.e. "POWER8E").
> >
> > The fix is to pass model_pieces[0] to ppc_cpu_lookup_alias().
> >
> > Signed-off-by: Greg Kurz <groug@kaod.org>
>
> Reviewed-by: Bharata B Rao <bharata@linux.vnet.ibm.com>
Applied to ppc-for-2.8, thanks.
>
> > ---
> > hw/ppc/spapr_cpu_core.c | 8 ++++----
> > 1 file changed, 4 insertions(+), 4 deletions(-)
> >
> > diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c
> > index 6f0533c34259..35d1873b9ff3 100644
> > --- a/hw/ppc/spapr_cpu_core.c
> > +++ b/hw/ppc/spapr_cpu_core.c
> > @@ -92,20 +92,20 @@ char *spapr_get_cpu_core_type(const char *model)
> > gchar **model_pieces = g_strsplit(model, ",", 2);
> >
> > core_type = g_strdup_printf("%s-%s", model_pieces[0], TYPE_SPAPR_CPU_CORE);
> > - g_strfreev(model_pieces);
> >
> > /* Check whether it exists or whether we have to look up an alias name */
> > if (!object_class_by_name(core_type)) {
> > const char *realmodel;
> >
> > g_free(core_type);
> > - realmodel = ppc_cpu_lookup_alias(model);
> > + core_type = NULL;
> > + realmodel = ppc_cpu_lookup_alias(model_pieces[0]);
> > if (realmodel) {
> > - return spapr_get_cpu_core_type(realmodel);
> > + core_type = spapr_get_cpu_core_type(realmodel);
> > }
> > - return NULL;
> > }
> >
> > + g_strfreev(model_pieces);
> > return core_type;
> > }
> >
>
--
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: 819 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-10-04 1:10 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-03 12:13 [Qemu-devel] [PATCH] spapr: fix check of cpu alias name in spapr_get_cpu_core_type() Greg Kurz
2016-10-03 15:14 ` Bharata B Rao
2016-10-04 0:20 ` David Gibson
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).