mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-07 01:33:56 -06:00
pseries: Move CPU compatibility property to machine
Server class POWER CPUs have a "compat" property, which is used to set the backwards compatibility mode for the processor. However, this only makes sense for machine types which don't give the guest access to hypervisor privilege - otherwise the compatibility level is under the guest's control. To reflect this, this removes the CPU 'compat' property and instead creates a 'max-cpu-compat' property on the pseries machine. Strictly speaking this breaks compatibility, but AFAIK the 'compat' option was never (directly) used with -device or device_add. The option was used with -cpu. So, to maintain compatibility, this patch adds a hack to the cpu option parsing to strip out any compat options supplied with -cpu and set them on the machine property instead of the now deprecated cpu property. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Tested-by: Suraj Jitindar Singh <sjitindarsingh@gmail.com> Reviewed-by: Greg Kurz <groug@kaod.org> Tested-by: Greg Kurz <groug@kaod.org> Tested-by: Andrea Bolognani <abologna@redhat.com>
This commit is contained in:
parent
a733371214
commit
7843c0d60d
7 changed files with 201 additions and 73 deletions
|
@ -20,6 +20,57 @@
|
|||
#include "sysemu/numa.h"
|
||||
#include "qemu/error-report.h"
|
||||
|
||||
void spapr_cpu_parse_features(sPAPRMachineState *spapr)
|
||||
{
|
||||
/*
|
||||
* Backwards compatibility hack:
|
||||
*
|
||||
* CPUs had a "compat=" property which didn't make sense for
|
||||
* anything except pseries. It was replaced by "max-cpu-compat"
|
||||
* machine option. This supports old command lines like
|
||||
* -cpu POWER8,compat=power7
|
||||
* By stripping the compat option and applying it to the machine
|
||||
* before passing it on to the cpu level parser.
|
||||
*/
|
||||
gchar **inpieces;
|
||||
int i, j;
|
||||
gchar *compat_str = NULL;
|
||||
|
||||
inpieces = g_strsplit(MACHINE(spapr)->cpu_model, ",", 0);
|
||||
|
||||
/* inpieces[0] is the actual model string */
|
||||
i = 1;
|
||||
j = 1;
|
||||
while (inpieces[i]) {
|
||||
if (g_str_has_prefix(inpieces[i], "compat=")) {
|
||||
/* in case of multiple compat= options */
|
||||
g_free(compat_str);
|
||||
compat_str = inpieces[i];
|
||||
} else {
|
||||
j++;
|
||||
}
|
||||
|
||||
i++;
|
||||
/* Excise compat options from list */
|
||||
inpieces[j] = inpieces[i];
|
||||
}
|
||||
|
||||
if (compat_str) {
|
||||
char *val = compat_str + strlen("compat=");
|
||||
gchar *newprops = g_strjoinv(",", inpieces);
|
||||
|
||||
object_property_set_str(OBJECT(spapr), val, "max-cpu-compat",
|
||||
&error_fatal);
|
||||
|
||||
ppc_cpu_parse_features(newprops);
|
||||
g_free(newprops);
|
||||
} else {
|
||||
ppc_cpu_parse_features(MACHINE(spapr)->cpu_model);
|
||||
}
|
||||
|
||||
g_strfreev(inpieces);
|
||||
}
|
||||
|
||||
static void spapr_cpu_reset(void *opaque)
|
||||
{
|
||||
sPAPRMachineState *spapr = SPAPR_MACHINE(qdev_get_machine());
|
||||
|
@ -67,10 +118,10 @@ static void spapr_cpu_init(sPAPRMachineState *spapr, PowerPCCPU *cpu,
|
|||
/* Enable PAPR mode in TCG or KVM */
|
||||
cpu_ppc_set_papr(cpu, PPC_VIRTUAL_HYPERVISOR(spapr));
|
||||
|
||||
if (cpu->max_compat) {
|
||||
if (spapr->max_compat_pvr) {
|
||||
Error *local_err = NULL;
|
||||
|
||||
ppc_set_compat(cpu, cpu->max_compat, &local_err);
|
||||
ppc_set_compat(cpu, spapr->max_compat_pvr, &local_err);
|
||||
if (local_err) {
|
||||
error_propagate(errp, local_err);
|
||||
return;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue