qemu: Pass machine type to virQEMUCapsIsCPUModeSupported

The usability of a specific CPU mode may depend on machine type, let's
prepare for this by passing it to virQEMUCapsIsCPUModeSupported.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Jiri Denemark 2020-02-05 15:51:09 +01:00
parent 23be4887af
commit 80791859ac
4 changed files with 13 additions and 7 deletions

View File

@ -2279,7 +2279,8 @@ bool
virQEMUCapsIsCPUModeSupported(virQEMUCapsPtr qemuCaps,
virArch hostarch,
virDomainVirtType type,
virCPUMode mode)
virCPUMode mode,
const char *machineType G_GNUC_UNUSED)
{
qemuMonitorCPUDefsPtr cpus;
@ -5644,18 +5645,21 @@ virQEMUCapsFillDomainCPUCaps(virQEMUCapsPtr qemuCaps,
virDomainCapsPtr domCaps)
{
if (virQEMUCapsIsCPUModeSupported(qemuCaps, hostarch, domCaps->virttype,
VIR_CPU_MODE_HOST_PASSTHROUGH))
VIR_CPU_MODE_HOST_PASSTHROUGH,
domCaps->machine))
domCaps->cpu.hostPassthrough = true;
if (virQEMUCapsIsCPUModeSupported(qemuCaps, hostarch, domCaps->virttype,
VIR_CPU_MODE_HOST_MODEL)) {
VIR_CPU_MODE_HOST_MODEL,
domCaps->machine)) {
virCPUDefPtr cpu = virQEMUCapsGetHostModel(qemuCaps, domCaps->virttype,
VIR_QEMU_CAPS_HOST_CPU_REPORTED);
domCaps->cpu.hostModel = virCPUDefCopy(cpu);
}
if (virQEMUCapsIsCPUModeSupported(qemuCaps, hostarch, domCaps->virttype,
VIR_CPU_MODE_CUSTOM)) {
VIR_CPU_MODE_CUSTOM,
domCaps->machine)) {
const char *blacklist[] = { "host", NULL };
VIR_AUTOSTRINGLIST models = NULL;

View File

@ -629,7 +629,8 @@ bool virQEMUCapsIsVirtTypeSupported(virQEMUCapsPtr qemuCaps,
bool virQEMUCapsIsCPUModeSupported(virQEMUCapsPtr qemuCaps,
virArch hostarch,
virDomainVirtType type,
virCPUMode mode);
virCPUMode mode,
const char *machineType);
const char *virQEMUCapsGetCanonicalMachine(virQEMUCapsPtr qemuCaps,
virDomainVirtType virtType,
const char *name);

View File

@ -4600,7 +4600,8 @@ qemuDomainDefSetDefaultCPU(virDomainDefPtr def,
if (STREQ(model, "host")) {
if (ARCH_IS_S390(def->os.arch) &&
virQEMUCapsIsCPUModeSupported(qemuCaps, hostarch, def->virtType,
VIR_CPU_MODE_HOST_MODEL)) {
VIR_CPU_MODE_HOST_MODEL,
def->os.machine)) {
def->cpu->mode = VIR_CPU_MODE_HOST_MODEL;
} else {
def->cpu->mode = VIR_CPU_MODE_HOST_PASSTHROUGH;

View File

@ -6022,7 +6022,7 @@ qemuProcessUpdateGuestCPU(virDomainDefPtr def,
}
if (!virQEMUCapsIsCPUModeSupported(qemuCaps, hostarch, def->virtType,
def->cpu->mode)) {
def->cpu->mode, def->os.machine)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("CPU mode '%s' for %s %s domain on %s host is not "
"supported by hypervisor"),