qemu: Move feature verification from PostParse() to Validate()

We want to perform all feature verification in a single spot, but
some of it (eg. GIC) is currently being performed at command line
generation time, and moving it to PostParse() would cause guests
to disappear. Moving verification to Validate() allows us to
side-step the issue.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
Andrea Bolognani 2018-02-02 10:58:13 +01:00
parent 554a5edcb4
commit 56ca68c3c8

View File

@ -3202,30 +3202,6 @@ qemuDomainDefCPUPostParse(virDomainDefPtr def)
}
static int
qemuDomainDefVerifyFeatures(const virDomainDef *def)
{
if (def->features[VIR_DOMAIN_FEATURE_IOAPIC] == VIR_TRISTATE_SWITCH_ON &&
!ARCH_IS_X86(def->os.arch)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("I/O APIC tuning is not supported "
"for '%s' architecture"),
virArchToString(def->os.arch));
return -1;
}
if (def->features[VIR_DOMAIN_FEATURE_HPT] == VIR_TRISTATE_SWITCH_ON &&
!qemuDomainIsPSeries(def)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
"%s",
_("HPT tuning is only supported for pSeries guests"));
return -1;
}
return 0;
}
static int
qemuDomainDefPostParseBasic(virDomainDefPtr def,
virCapsPtr caps,
@ -3284,9 +3260,6 @@ qemuDomainDefPostParse(virDomainDefPtr def,
qemuDomainDefEnableDefaultFeatures(def, qemuCaps);
if (qemuDomainDefVerifyFeatures(def) < 0)
goto cleanup;
if (qemuDomainRecheckInternalPaths(def, cfg, parseFlags) < 0)
goto cleanup;
@ -3339,6 +3312,30 @@ qemuDomainDefGetVcpuHotplugGranularity(const virDomainDef *def)
#define QEMU_MAX_VCPUS_WITHOUT_EIM 255
static int
qemuDomainDefValidateFeatures(const virDomainDef *def)
{
if (def->features[VIR_DOMAIN_FEATURE_IOAPIC] == VIR_TRISTATE_SWITCH_ON &&
!ARCH_IS_X86(def->os.arch)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("I/O APIC tuning is not supported "
"for '%s' architecture"),
virArchToString(def->os.arch));
return -1;
}
if (def->features[VIR_DOMAIN_FEATURE_HPT] == VIR_TRISTATE_SWITCH_ON &&
!qemuDomainIsPSeries(def)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
"%s",
_("HPT tuning is only supported for pSeries guests"));
return -1;
}
return 0;
}
static int
qemuDomainDefValidate(const virDomainDef *def,
virCapsPtr caps ATTRIBUTE_UNUSED,
@ -3451,6 +3448,9 @@ qemuDomainDefValidate(const virDomainDef *def,
}
}
if (qemuDomainDefValidateFeatures(def) < 0)
goto cleanup;
ret = 0;
cleanup: