|
|
e73cc6 |
From: Prerna Saxena <prerna@linux.vnet.ibm.com>
|
|
|
e73cc6 |
Date: Tue, 4 Nov 2014 22:52:44 +0530
|
|
|
e73cc6 |
Subject: [PATCH] PowerPC : Add support for launching VM in 'compat' mode.
|
|
|
e73cc6 |
|
|
|
e73cc6 |
PowerISA allows processors to run VMs in binary compatibility ("compat")
|
|
|
e73cc6 |
mode supporting an older version of ISA. QEMU has recently added support to
|
|
|
e73cc6 |
explicitly denote a VM running in compatibility mode through commit 6d9412ea
|
|
|
e73cc6 |
& 8dfa3a5e85. Now, a "compat" mode VM can be run by invoking this qemu
|
|
|
e73cc6 |
commandline on a POWER8 host: -cpu host,compat=power7.
|
|
|
e73cc6 |
|
|
|
e73cc6 |
This patch allows libvirt to exploit cpu mode 'host-model' to describe this
|
|
|
e73cc6 |
new mode for PowerKVM guests. For example, when a user wants to request a
|
|
|
e73cc6 |
power7 vm to run in compatibility mode on a Power8 host, this can be
|
|
|
e73cc6 |
described in XML as follows :
|
|
|
e73cc6 |
|
|
|
e73cc6 |
<cpu mode='host-model'>
|
|
|
e73cc6 |
<model>power7</model>
|
|
|
e73cc6 |
</cpu>
|
|
|
e73cc6 |
|
|
|
e73cc6 |
Signed-off-by: Prerna Saxena <prerna@linux.vnet.ibm.com>
|
|
|
e73cc6 |
Signed-off-by: Li Zhang <zhlcindy@linux.vnet.ibm.com>
|
|
|
e73cc6 |
Signed-off-by: Pradipta Kr. Banerjee <bpradip@in.ibm.com>
|
|
|
e73cc6 |
Acked-by: Michal Privoznik <mprivozn@redhat.com>
|
|
|
e73cc6 |
(cherry picked from commit addce06c9221f948072cd222b56ea9c3f70ec066)
|
|
|
e73cc6 |
---
|
|
|
e73cc6 |
src/conf/cpu_conf.c | 1 +
|
|
|
e73cc6 |
src/cpu/cpu_powerpc.c | 11 ++---------
|
|
|
e73cc6 |
src/qemu/qemu_command.c | 10 +++++++++-
|
|
|
e73cc6 |
3 files changed, 12 insertions(+), 10 deletions(-)
|
|
|
e73cc6 |
|
|
|
e73cc6 |
diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c
|
|
|
e73cc6 |
index 9b7fbb0..0e7a979 100644
|
|
|
e73cc6 |
--- a/src/conf/cpu_conf.c
|
|
|
e73cc6 |
+++ b/src/conf/cpu_conf.c
|
|
|
e73cc6 |
@@ -619,6 +619,7 @@ virCPUDefFormatBuf(virBufferPtr buf,
|
|
|
e73cc6 |
return 0;
|
|
|
e73cc6 |
|
|
|
e73cc6 |
formatModel = (def->mode == VIR_CPU_MODE_CUSTOM ||
|
|
|
e73cc6 |
+ def->mode == VIR_CPU_MODE_HOST_MODEL ||
|
|
|
e73cc6 |
(flags & VIR_DOMAIN_XML_UPDATE_CPU));
|
|
|
e73cc6 |
formatFallback = (def->type == VIR_CPU_TYPE_GUEST &&
|
|
|
e73cc6 |
(def->mode == VIR_CPU_MODE_HOST_MODEL ||
|
|
|
e73cc6 |
diff --git a/src/cpu/cpu_powerpc.c b/src/cpu/cpu_powerpc.c
|
|
|
e73cc6 |
index d591c18..4ea1835 100644
|
|
|
e73cc6 |
--- a/src/cpu/cpu_powerpc.c
|
|
|
e73cc6 |
+++ b/src/cpu/cpu_powerpc.c
|
|
|
e73cc6 |
@@ -562,8 +562,8 @@ ppcUpdate(virCPUDefPtr guest,
|
|
|
e73cc6 |
static virCPUDefPtr
|
|
|
e73cc6 |
ppcBaseline(virCPUDefPtr *cpus,
|
|
|
e73cc6 |
unsigned int ncpus,
|
|
|
e73cc6 |
- const char **models,
|
|
|
e73cc6 |
- unsigned int nmodels,
|
|
|
e73cc6 |
+ const char **models ATTRIBUTE_UNUSED,
|
|
|
e73cc6 |
+ unsigned int nmodels ATTRIBUTE_UNUSED,
|
|
|
e73cc6 |
unsigned int flags)
|
|
|
e73cc6 |
{
|
|
|
e73cc6 |
struct ppc_map *map = NULL;
|
|
|
e73cc6 |
@@ -583,13 +583,6 @@ ppcBaseline(virCPUDefPtr *cpus,
|
|
|
e73cc6 |
goto error;
|
|
|
e73cc6 |
}
|
|
|
e73cc6 |
|
|
|
e73cc6 |
- if (!cpuModelIsAllowed(model->name, models, nmodels)) {
|
|
|
e73cc6 |
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
|
|
e73cc6 |
- _("CPU model %s is not supported by hypervisor"),
|
|
|
e73cc6 |
- model->name);
|
|
|
e73cc6 |
- goto error;
|
|
|
e73cc6 |
- }
|
|
|
e73cc6 |
-
|
|
|
e73cc6 |
for (i = 0; i < ncpus; i++) {
|
|
|
e73cc6 |
const struct ppc_vendor *vnd;
|
|
|
e73cc6 |
|
|
|
e73cc6 |
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
|
|
|
e73cc6 |
index d60f274..34f6535 100644
|
|
|
e73cc6 |
--- a/src/qemu/qemu_command.c
|
|
|
e73cc6 |
+++ b/src/qemu/qemu_command.c
|
|
|
e73cc6 |
@@ -6221,7 +6221,9 @@ qemuBuildCpuModelArgStr(virQEMUDriverPtr driver,
|
|
|
e73cc6 |
*hasHwVirt = hasSVM > 0 ? true : false;
|
|
|
e73cc6 |
}
|
|
|
e73cc6 |
|
|
|
e73cc6 |
- if (cpu->mode == VIR_CPU_MODE_HOST_PASSTHROUGH) {
|
|
|
e73cc6 |
+ if ((cpu->mode == VIR_CPU_MODE_HOST_PASSTHROUGH) ||
|
|
|
e73cc6 |
+ ((cpu->mode == VIR_CPU_MODE_HOST_MODEL) &&
|
|
|
e73cc6 |
+ ARCH_IS_PPC64(def->os.arch))) {
|
|
|
e73cc6 |
const char *mode = virCPUModeTypeToString(cpu->mode);
|
|
|
e73cc6 |
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_CPU_HOST)) {
|
|
|
e73cc6 |
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
|
|
e73cc6 |
@@ -6236,6 +6238,12 @@ qemuBuildCpuModelArgStr(virQEMUDriverPtr driver,
|
|
|
e73cc6 |
goto cleanup;
|
|
|
e73cc6 |
}
|
|
|
e73cc6 |
virBufferAddLit(buf, "host");
|
|
|
e73cc6 |
+
|
|
|
e73cc6 |
+ if (ARCH_IS_PPC64(def->os.arch) &&
|
|
|
e73cc6 |
+ cpu->mode == VIR_CPU_MODE_HOST_MODEL) {
|
|
|
e73cc6 |
+ virBufferAsprintf(buf, ",compat=%s", def->cpu->model);
|
|
|
e73cc6 |
+ }
|
|
|
e73cc6 |
+
|
|
|
e73cc6 |
} else {
|
|
|
e73cc6 |
if (VIR_ALLOC(guest) < 0)
|
|
|
e73cc6 |
goto cleanup;
|