mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-28 11:31:16 +00:00
qemu: Use switch in qemuDomainDefValidateFeatures()
The compiler can make sure we are handling all features. While reworking the logic, also change error messages to a more consistent style. Signed-off-by: Andrea Bolognani <abologna@redhat.com> Reviewed-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
parent
56ca68c3c8
commit
ce24802a6b
@ -346,6 +346,8 @@ virDomainDiskSetFormat;
|
||||
virDomainDiskSetSource;
|
||||
virDomainDiskSetType;
|
||||
virDomainDiskTranslateSourcePool;
|
||||
virDomainFeatureTypeFromString;
|
||||
virDomainFeatureTypeToString;
|
||||
virDomainFSDefFree;
|
||||
virDomainFSDefNew;
|
||||
virDomainFSDriverTypeToString;
|
||||
|
@ -3315,22 +3315,57 @@ qemuDomainDefGetVcpuHotplugGranularity(const virDomainDef *def)
|
||||
static int
|
||||
qemuDomainDefValidateFeatures(const virDomainDef *def)
|
||||
{
|
||||
if (def->features[VIR_DOMAIN_FEATURE_IOAPIC] == VIR_TRISTATE_SWITCH_ON &&
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < VIR_DOMAIN_FEATURE_LAST; i++) {
|
||||
const char *featureName = virDomainFeatureTypeToString(i);
|
||||
|
||||
switch ((virDomainFeature) i) {
|
||||
case VIR_DOMAIN_FEATURE_IOAPIC:
|
||||
if (def->features[i] == 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));
|
||||
_("The '%s' feature is not supported for "
|
||||
"architecture '%s' or machine type '%s'"),
|
||||
featureName,
|
||||
virArchToString(def->os.arch),
|
||||
def->os.machine);
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
|
||||
if (def->features[VIR_DOMAIN_FEATURE_HPT] == VIR_TRISTATE_SWITCH_ON &&
|
||||
case VIR_DOMAIN_FEATURE_HPT:
|
||||
if (def->features[i] == VIR_TRISTATE_SWITCH_ON &&
|
||||
!qemuDomainIsPSeries(def)) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
"%s",
|
||||
_("HPT tuning is only supported for pSeries guests"));
|
||||
_("The '%s' feature is not supported for "
|
||||
"architecture '%s' or machine type '%s'"),
|
||||
featureName,
|
||||
virArchToString(def->os.arch),
|
||||
def->os.machine);
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_FEATURE_ACPI:
|
||||
case VIR_DOMAIN_FEATURE_APIC:
|
||||
case VIR_DOMAIN_FEATURE_PAE:
|
||||
case VIR_DOMAIN_FEATURE_HAP:
|
||||
case VIR_DOMAIN_FEATURE_VIRIDIAN:
|
||||
case VIR_DOMAIN_FEATURE_PRIVNET:
|
||||
case VIR_DOMAIN_FEATURE_HYPERV:
|
||||
case VIR_DOMAIN_FEATURE_KVM:
|
||||
case VIR_DOMAIN_FEATURE_PVSPINLOCK:
|
||||
case VIR_DOMAIN_FEATURE_CAPABILITIES:
|
||||
case VIR_DOMAIN_FEATURE_PMU:
|
||||
case VIR_DOMAIN_FEATURE_VMPORT:
|
||||
case VIR_DOMAIN_FEATURE_GIC:
|
||||
case VIR_DOMAIN_FEATURE_SMM:
|
||||
case VIR_DOMAIN_FEATURE_VMCOREINFO:
|
||||
case VIR_DOMAIN_FEATURE_LAST:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user