From: Bharata B Rao <bharata@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org
Cc: qemu-ppc@nongnu.org, david@gibson.dropbear.id.au,
imammedo@redhat.com, thuth@redhat.com, ehabkost@redhat.com,
Bharata B Rao <bharata@linux.vnet.ibm.com>
Subject: [Qemu-devel] [PATCH v2 1/1] spapr: Set compat type for CPUs of a core
Date: Mon, 27 Jun 2016 11:49:46 +0530 [thread overview]
Message-ID: <1467008386-21995-1-git-send-email-bharata@linux.vnet.ibm.com> (raw)
Compat CPU type is typically specified on -cpu cmdline option like:
-cpu host,compat=power7 or -cpu POWER8E,compat=power7 etc. When
compat is specified on -cpu cmdline, apply the same to all the
CPUs that get created as part of CPU core devices.
This patch takes care of compat property that is specified with
-cpu cmdline option only. The other way to specify this property
is via -global cmdline option and that usage isn't addressed by
this patch because -global is already broken for some CPU class
in PowerPC. There are two issues with using -global on CPU class.
- We specify alias names for CPUs commonly and use of alias names
won't work with -global seamlessly. For eg, When "-cpu host" is
specified, the actual CPU type that gets created
is host-powerpc64-cpu. Hence specifying -global host.compat=power7
will not work, so it has to be -global host-powerpc64-cpu.compat=power7.
- PowerPC class names have . (dot) and opts parsing doesn't like it.
Specifying -global POWER8E_v2.1-powerpc64-cpu.compat=power7 will not
work as the driver name gets extracted as POWER8E_v2 and hence setting
of global property fails.
The above two aspects could be considered/fixed separately from this
patch as this patch allows existing uses of -cpu cpuname,compat= to
work correctly after the introducton of sPAPR CPU cores.
Signed-off-by: Bharata B Rao <bharata@linux.vnet.ibm.com>
---
Changes in v2:
- No need for a separate property named compat for cores.
- Simplified spapr_get_cpu_compat_type() based on David's review.
v1: https://lists.gnu.org/archive/html/qemu-devel/2016-06/msg06279.html
hw/ppc/spapr_cpu_core.c | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c
index 3a5da09..e8873fd 100644
--- a/hw/ppc/spapr_cpu_core.c
+++ b/hw/ppc/spapr_cpu_core.c
@@ -96,6 +96,28 @@ char *spapr_get_cpu_core_type(const char *model)
return core_type;
}
+/*
+ * Returns the CPU compat type specified in -cpu @model.
+ */
+static char *spapr_get_cpu_compat_type(const char *model)
+{
+ char *model_str = g_strdup(model);
+ char *featurestr, *compat = NULL;
+
+ featurestr = model_str ? strtok(model_str, ",") : NULL;
+ while (featurestr) {
+ if (!strncmp(featurestr, "compat=", 7)) {
+ compat = g_strdup(featurestr + 7);
+ goto out;
+ }
+ featurestr = strtok(NULL, ",");
+ }
+
+out:
+ g_free(model_str);
+ return compat;
+}
+
static void spapr_core_release(DeviceState *dev, void *opaque)
{
sPAPRCPUCore *sc = SPAPR_CPU_CORE(OBJECT(dev));
@@ -285,6 +307,8 @@ static void spapr_cpu_core_realize(DeviceState *dev, Error **errp)
CPUCore *cc = CPU_CORE(OBJECT(dev));
const char *typename = object_class_get_name(sc->cpu_class);
size_t size = object_type_get_instance_size(typename);
+ MachineState *machine = MACHINE(qdev_get_machine());
+ char *compat = spapr_get_cpu_compat_type(machine->cpu_model);
Error *local_err = NULL;
Object *obj;
int i;
@@ -300,11 +324,18 @@ static void spapr_cpu_core_realize(DeviceState *dev, Error **errp)
if (local_err) {
goto err;
}
+ if (compat) {
+ object_property_set_str(obj, compat, "compat", &local_err);
+ if (local_err) {
+ goto err;
+ }
+ }
}
object_child_foreach(OBJECT(dev), spapr_cpu_core_realize_child, &local_err);
if (local_err) {
goto err;
} else {
+ g_free(compat);
return;
}
@@ -315,6 +346,7 @@ err:
i--;
}
g_free(sc->threads);
+ g_free(compat);
error_propagate(errp, local_err);
}
--
2.1.0
next reply other threads:[~2016-06-27 6:20 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-27 6:19 Bharata B Rao [this message]
2016-06-27 6:51 ` [Qemu-devel] [PATCH v2 1/1] spapr: Set compat type for CPUs of a core David Gibson
2016-06-27 8:40 ` Bharata B Rao
2016-06-27 18:12 ` 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=1467008386-21995-1-git-send-email-bharata@linux.vnet.ibm.com \
--to=bharata@linux.vnet.ibm.com \
--cc=david@gibson.dropbear.id.au \
--cc=ehabkost@redhat.com \
--cc=imammedo@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).