qemu: Move checks for SMM from command-line creation into validation phase

We are still hoping all of such checks will be moved there and this is one small
step in that direction.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Martin Kletzander 2018-05-10 23:28:24 +02:00
parent e546785dce
commit 343894b74b
4 changed files with 15 additions and 27 deletions

View File

@ -4773,17 +4773,6 @@ virQEMUCapsSupportsVmport(virQEMUCapsPtr qemuCaps,
}
bool
virQEMUCapsSupportsSMM(virQEMUCapsPtr qemuCaps,
const virDomainDef *def)
{
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_MACHINE_SMM_OPT))
return false;
return qemuDomainIsQ35(def);
}
bool
virQEMUCapsIsMachineSupported(virQEMUCapsPtr qemuCaps,
const char *canonical_machine)

View File

@ -505,9 +505,6 @@ bool virQEMUCapsHasPCIMultiBus(virQEMUCapsPtr qemuCaps,
bool virQEMUCapsSupportsVmport(virQEMUCapsPtr qemuCaps,
const virDomainDef *def);
bool virQEMUCapsSupportsSMM(virQEMUCapsPtr qemuCaps,
const virDomainDef *def);
char *virQEMUCapsFlagsString(virQEMUCapsPtr qemuCaps);
const char *virQEMUCapsGetBinary(virQEMUCapsPtr qemuCaps);

View File

@ -7136,16 +7136,8 @@ qemuBuildMachineCommandLine(virCommandPtr cmd,
virTristateSwitchTypeToString(vmport));
}
if (smm) {
if (!virQEMUCapsSupportsSMM(qemuCaps, def)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("smm is not available with this QEMU binary"));
goto cleanup;
}
virBufferAsprintf(&buf, ",smm=%s",
virTristateSwitchTypeToString(smm));
}
if (smm)
virBufferAsprintf(&buf, ",smm=%s", virTristateSwitchTypeToString(smm));
if (def->mem.dump_core) {
virBufferAsprintf(&buf, ",dump-guest-core=%s",

View File

@ -3743,7 +3743,8 @@ qemuDomainDefGetVcpuHotplugGranularity(const virDomainDef *def)
static int
qemuDomainDefValidateFeatures(const virDomainDef *def)
qemuDomainDefValidateFeatures(const virDomainDef *def,
virQEMUCapsPtr qemuCaps)
{
size_t i;
@ -3790,6 +3791,16 @@ qemuDomainDefValidateFeatures(const virDomainDef *def)
}
break;
case VIR_DOMAIN_FEATURE_SMM:
if (def->features[i] != VIR_TRISTATE_SWITCH_ABSENT &&
(!virQEMUCapsGet(qemuCaps, QEMU_CAPS_MACHINE_SMM_OPT) ||
!qemuDomainIsQ35(def))) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("smm is not available with this QEMU binary"));
return -1;
}
break;
case VIR_DOMAIN_FEATURE_ACPI:
case VIR_DOMAIN_FEATURE_APIC:
case VIR_DOMAIN_FEATURE_PAE:
@ -3802,7 +3813,6 @@ qemuDomainDefValidateFeatures(const virDomainDef *def)
case VIR_DOMAIN_FEATURE_CAPABILITIES:
case VIR_DOMAIN_FEATURE_PMU:
case VIR_DOMAIN_FEATURE_VMPORT:
case VIR_DOMAIN_FEATURE_SMM:
case VIR_DOMAIN_FEATURE_VMCOREINFO:
case VIR_DOMAIN_FEATURE_LAST:
break;
@ -3925,7 +3935,7 @@ qemuDomainDefValidate(const virDomainDef *def,
}
}
if (qemuDomainDefValidateFeatures(def) < 0)
if (qemuDomainDefValidateFeatures(def, qemuCaps) < 0)
goto cleanup;
ret = 0;