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;
|
virDomainDiskSetSource;
|
||||||
virDomainDiskSetType;
|
virDomainDiskSetType;
|
||||||
virDomainDiskTranslateSourcePool;
|
virDomainDiskTranslateSourcePool;
|
||||||
|
virDomainFeatureTypeFromString;
|
||||||
|
virDomainFeatureTypeToString;
|
||||||
virDomainFSDefFree;
|
virDomainFSDefFree;
|
||||||
virDomainFSDefNew;
|
virDomainFSDefNew;
|
||||||
virDomainFSDriverTypeToString;
|
virDomainFSDriverTypeToString;
|
||||||
|
@ -3315,21 +3315,56 @@ qemuDomainDefGetVcpuHotplugGranularity(const virDomainDef *def)
|
|||||||
static int
|
static int
|
||||||
qemuDomainDefValidateFeatures(const virDomainDef *def)
|
qemuDomainDefValidateFeatures(const virDomainDef *def)
|
||||||
{
|
{
|
||||||
if (def->features[VIR_DOMAIN_FEATURE_IOAPIC] == VIR_TRISTATE_SWITCH_ON &&
|
size_t i;
|
||||||
!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 &&
|
for (i = 0; i < VIR_DOMAIN_FEATURE_LAST; i++) {
|
||||||
!qemuDomainIsPSeries(def)) {
|
const char *featureName = virDomainFeatureTypeToString(i);
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
|
||||||
"%s",
|
switch ((virDomainFeature) i) {
|
||||||
_("HPT tuning is only supported for pSeries guests"));
|
case VIR_DOMAIN_FEATURE_IOAPIC:
|
||||||
return -1;
|
if (def->features[i] == VIR_TRISTATE_SWITCH_ON &&
|
||||||
|
!ARCH_IS_X86(def->os.arch)) {
|
||||||
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||||
|
_("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_HPT:
|
||||||
|
if (def->features[i] == VIR_TRISTATE_SWITCH_ON &&
|
||||||
|
!qemuDomainIsPSeries(def)) {
|
||||||
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||||
|
_("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;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user