QEMU 2.11 for ppc64 changed all CPU model names to lower case. Since
libvirt can't change the model names for compatibility reasons, we need
to translate the matching lower case models to the names known by
libvirt.
Signed-off-by: Jiri Denemark <jdenemar(a)redhat.com>
---
src/qemu/qemu_capabilities.c | 28 +++++++++++++++++--
src/qemu/qemu_capabilities.h | 3 +-
src/qemu/qemu_process.c | 2 +-
.../qemu_2.12.0.ppc64.xml | 6 +++-
.../caps_2.12.0.ppc64.xml | 12 ++++----
5 files changed, 40 insertions(+), 11 deletions(-)
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index a5cb24fec6..9fee5dcd8a 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -2217,16 +2217,39 @@ virQEMUCapsProbeQMPMachineTypes(virQEMUCapsPtr qemuCaps,
virDomainCapsCPUModelsPtr
-virQEMUCapsFetchCPUDefinitions(qemuMonitorPtr mon)
+virQEMUCapsFetchCPUDefinitions(qemuMonitorPtr mon,
+ virArch arch)
{
virDomainCapsCPUModelsPtr models = NULL;
qemuMonitorCPUDefInfoPtr *cpus = NULL;
+ char **libvirtModels = NULL;
int ncpus = 0;
size_t i;
if ((ncpus = qemuMonitorGetCPUDefinitions(mon, &cpus)) < 0)
return NULL;
+ if (ARCH_IS_PPC(arch)) {
+ /* QEMU 2.11 for Power renamed all CPU models to lower case, we need
+ * to translate them back to libvirt's upper case model names. */
+ if (virCPUGetModels(arch, &libvirtModels) < 0)
+ goto error;
+
+ if (virStringListLength((const char **)libvirtModels) > 0) {
+ for (i = 0; i < ncpus; i++) {
+ const char *name;
+
+ if (!(name = virStringListSearch((const char **)libvirtModels,
+ cpus[i]->name)))
+ continue;
+
+ VIR_FREE(cpus[i]->name);
+ if (VIR_STRDUP(cpus[i]->name, name) < 0)
+ goto error;
+ }
+ }
+ }
+
if (!(models = virDomainCapsCPUModelsNew(ncpus)))
goto error;
@@ -2247,6 +2270,7 @@ virQEMUCapsFetchCPUDefinitions(qemuMonitorPtr mon)
for (i = 0; i < ncpus; i++)
qemuMonitorCPUDefInfoFree(cpus[i]);
VIR_FREE(cpus);
+ virStringListFree(libvirtModels);
return models;
error:
@@ -2266,7 +2290,7 @@ virQEMUCapsProbeQMPCPUDefinitions(virQEMUCapsPtr qemuCaps,
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_CPU_DEFINITIONS))
return 0;
- if (!(models = virQEMUCapsFetchCPUDefinitions(mon)))
+ if (!(models = virQEMUCapsFetchCPUDefinitions(mon, qemuCaps->arch)))
return -1;
if (tcg || !virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM))
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index d23c34c24d..3ab108a667 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -513,7 +513,8 @@ int virQEMUCapsAddCPUDefinitions(virQEMUCapsPtr qemuCaps,
virDomainCapsCPUUsable usable);
virDomainCapsCPUModelsPtr virQEMUCapsGetCPUDefinitions(virQEMUCapsPtr qemuCaps,
virDomainVirtType type);
-virDomainCapsCPUModelsPtr virQEMUCapsFetchCPUDefinitions(qemuMonitorPtr mon);
+virDomainCapsCPUModelsPtr virQEMUCapsFetchCPUDefinitions(qemuMonitorPtr mon,
+ virArch arch);
typedef enum {
/* Host CPU definition reported in domain capabilities. */
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 5b73a61962..d09ff7fb87 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -4127,7 +4127,7 @@ qemuProcessFetchCPUDefinitions(virQEMUDriverPtr driver,
if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0)
goto error;
- models = virQEMUCapsFetchCPUDefinitions(priv->mon);
+ models = virQEMUCapsFetchCPUDefinitions(priv->mon, vm->def->os.arch);
if (qemuDomainObjExitMonitor(driver, vm) < 0)
goto error;
diff --git a/tests/domaincapsschemadata/qemu_2.12.0.ppc64.xml
b/tests/domaincapsschemadata/qemu_2.12.0.ppc64.xml
index 5fac2ed772..1762417ee2 100644
--- a/tests/domaincapsschemadata/qemu_2.12.0.ppc64.xml
+++ b/tests/domaincapsschemadata/qemu_2.12.0.ppc64.xml
@@ -25,7 +25,11 @@
<mode name='host-model' supported='yes'>
<model fallback='allow'>POWER8</model>
</mode>
- <mode name='custom' supported='no'/>
+ <mode name='custom' supported='yes'>
+ <model usable='unknown'>POWER9</model>
+ <model usable='unknown'>POWER8</model>
+ <model usable='unknown'>POWER7</model>
+ </mode>
</cpu>
<devices>
<disk supported='yes'>
diff --git a/tests/qemucapabilitiesdata/caps_2.12.0.ppc64.xml
b/tests/qemucapabilitiesdata/caps_2.12.0.ppc64.xml
index bffe3b3b97..144b8883a2 100644
--- a/tests/qemucapabilitiesdata/caps_2.12.0.ppc64.xml
+++ b/tests/qemucapabilitiesdata/caps_2.12.0.ppc64.xml
@@ -171,12 +171,12 @@
<cpu type='kvm' name='970mp'/>
<cpu type='kvm' name='970fx'/>
<cpu type='kvm' name='970'/>
- <cpu type='kvm' name='power9'/>
+ <cpu type='kvm' name='POWER9'/>
<cpu type='kvm' name='power8nvl'/>
- <cpu type='kvm' name='power8'/>
+ <cpu type='kvm' name='POWER8'/>
<cpu type='kvm' name='power8e'/>
<cpu type='kvm' name='power7+'/>
- <cpu type='kvm' name='power7'/>
+ <cpu type='kvm' name='POWER7'/>
<cpu type='kvm' name='power5gs'/>
<cpu type='kvm' name='power5+'/>
<cpu type='kvm' name='apollo7pm'/>
@@ -609,12 +609,12 @@
<cpu type='tcg' name='970mp'/>
<cpu type='tcg' name='970fx'/>
<cpu type='tcg' name='970'/>
- <cpu type='tcg' name='power9'/>
+ <cpu type='tcg' name='POWER9'/>
<cpu type='tcg' name='power8nvl'/>
- <cpu type='tcg' name='power8'/>
+ <cpu type='tcg' name='POWER8'/>
<cpu type='tcg' name='power8e'/>
<cpu type='tcg' name='power7+'/>
- <cpu type='tcg' name='power7'/>
+ <cpu type='tcg' name='POWER7'/>
<cpu type='tcg' name='power5gs'/>
<cpu type='tcg' name='power5+'/>
<cpu type='tcg' name='apollo7pm'/>
--
2.17.0