qemu: Adapt to changed ppc64 CPU model names

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@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Jiri Denemark 2018-05-17 17:08:42 +02:00
parent b979ec355d
commit db873ab3bc
8 changed files with 56 additions and 29 deletions

View File

@ -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))

View File

@ -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. */

View File

@ -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;

View File

@ -29,7 +29,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'>

View File

@ -163,12 +163,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'/>
@ -601,12 +601,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'/>

View File

@ -164,12 +164,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'/>
@ -602,12 +602,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'/>

View File

@ -166,12 +166,12 @@
<cpu type='kvm' name='ppc'/>
<cpu type='kvm' name='ppc32'/>
<cpu type='kvm' name='ppc64'/>
<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='970mp'/>
@ -604,12 +604,12 @@
<cpu type='tcg' name='ppc'/>
<cpu type='tcg' name='ppc32'/>
<cpu type='tcg' name='ppc64'/>
<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='970mp'/>

View File

@ -179,12 +179,12 @@
<cpu type='kvm' name='ppc'/>
<cpu type='kvm' name='ppc32'/>
<cpu type='kvm' name='ppc64'/>
<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='970mp'/>
@ -617,12 +617,12 @@
<cpu type='tcg' name='ppc'/>
<cpu type='tcg' name='ppc32'/>
<cpu type='tcg' name='ppc64'/>
<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='970mp'/>