diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 46a056340b..a340973f14 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -2437,7 +2437,8 @@ virQEMUCapsProbeQMPMachineProps(virQEMUCapsPtr qemuCaps, virDomainCapsCPUModelsPtr -virQEMUCapsFetchCPUDefinitions(qemuMonitorPtr mon) +virQEMUCapsFetchCPUDefinitions(qemuMonitorPtr mon, + virArch arch) { virDomainCapsCPUModelsPtr models = NULL; qemuMonitorCPUDefInfoPtr *cpus = NULL; @@ -2447,6 +2448,27 @@ virQEMUCapsFetchCPUDefinitions(qemuMonitorPtr mon) if ((ncpus = qemuMonitorGetCPUDefinitions(mon, &cpus)) < 0) return NULL; + /* 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 (ARCH_IS_PPC(arch)) { + VIR_AUTOSTRINGLIST libvirtModels = NULL; + char **name; + + if (virCPUGetModels(arch, &libvirtModels) < 0) + goto error; + + for (name = libvirtModels; name && *name; name++) { + for (i = 0; i < ncpus; i++) { + if (STRCASENEQ(cpus[i]->name, *name)) + continue; + + VIR_FREE(cpus[i]->name); + if (VIR_STRDUP(cpus[i]->name, *name) < 0) + goto error; + } + } + } + if (!(models = virDomainCapsCPUModelsNew(ncpus))) goto error; @@ -2486,7 +2508,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 72da3691f2..6c77b9d943 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -567,7 +567,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 a50cd54393..7774a82972 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -4379,7 +4379,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 99de2b0a8e..e8d3c22337 100644 --- a/tests/domaincapsschemadata/qemu_2.12.0.ppc64.xml +++ b/tests/domaincapsschemadata/qemu_2.12.0.ppc64.xml @@ -29,7 +29,11 @@ POWER8 - + + POWER9 + POWER8 + POWER7 + diff --git a/tests/qemucapabilitiesdata/caps_2.12.0.ppc64.xml b/tests/qemucapabilitiesdata/caps_2.12.0.ppc64.xml index fd9ae0bcb8..ede28439cd 100644 --- a/tests/qemucapabilitiesdata/caps_2.12.0.ppc64.xml +++ b/tests/qemucapabilitiesdata/caps_2.12.0.ppc64.xml @@ -163,12 +163,12 @@ - + - + - + @@ -601,12 +601,12 @@ - + - + - + diff --git a/tests/qemucapabilitiesdata/caps_3.0.0.ppc64.xml b/tests/qemucapabilitiesdata/caps_3.0.0.ppc64.xml index 61be1df782..221e0d1756 100644 --- a/tests/qemucapabilitiesdata/caps_3.0.0.ppc64.xml +++ b/tests/qemucapabilitiesdata/caps_3.0.0.ppc64.xml @@ -164,12 +164,12 @@ - + - + - + @@ -602,12 +602,12 @@ - + - + - + diff --git a/tests/qemucapabilitiesdata/caps_3.1.0.ppc64.xml b/tests/qemucapabilitiesdata/caps_3.1.0.ppc64.xml index 400dc45be4..4685081945 100644 --- a/tests/qemucapabilitiesdata/caps_3.1.0.ppc64.xml +++ b/tests/qemucapabilitiesdata/caps_3.1.0.ppc64.xml @@ -166,12 +166,12 @@ - + - + - + @@ -604,12 +604,12 @@ - + - + - + diff --git a/tests/qemucapabilitiesdata/caps_4.0.0.ppc64.xml b/tests/qemucapabilitiesdata/caps_4.0.0.ppc64.xml index 9ea6f4d046..86e146effc 100644 --- a/tests/qemucapabilitiesdata/caps_4.0.0.ppc64.xml +++ b/tests/qemucapabilitiesdata/caps_4.0.0.ppc64.xml @@ -179,12 +179,12 @@ - + - + - + @@ -617,12 +617,12 @@ - + - + - +