1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-01-23 02:04:16 +03:00

conf: Improve IOAPIC feature handling

Instead of storing separately whether the feature is enabled
or not and what driver should be used, store both of them in
a single place.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
Andrea Bolognani 2018-02-06 14:30:40 +01:00
parent 132548efde
commit c5a451ef21
4 changed files with 24 additions and 28 deletions

View File

@ -900,6 +900,7 @@ VIR_ENUM_IMPL(virDomainLoader,
VIR_ENUM_IMPL(virDomainIOAPIC, VIR_ENUM_IMPL(virDomainIOAPIC,
VIR_DOMAIN_IOAPIC_LAST, VIR_DOMAIN_IOAPIC_LAST,
"none",
"qemu", "qemu",
"kvm") "kvm")
@ -5913,8 +5914,7 @@ virDomainDefValidateInternal(const virDomainDef *def)
if (def->iommu && if (def->iommu &&
def->iommu->intremap == VIR_TRISTATE_SWITCH_ON && def->iommu->intremap == VIR_TRISTATE_SWITCH_ON &&
(def->features[VIR_DOMAIN_FEATURE_IOAPIC] != VIR_TRISTATE_SWITCH_ON || def->features[VIR_DOMAIN_FEATURE_IOAPIC] != VIR_DOMAIN_IOAPIC_QEMU) {
def->ioapic != VIR_DOMAIN_IOAPIC_QEMU)) {
virReportError(VIR_ERR_XML_ERROR, "%s", virReportError(VIR_ERR_XML_ERROR, "%s",
_("IOMMU interrupt remapping requires split I/O APIC " _("IOMMU interrupt remapping requires split I/O APIC "
"(ioapic driver='qemu')")); "(ioapic driver='qemu')"));
@ -19224,14 +19224,13 @@ virDomainDefParseXML(xmlDocPtr xml,
tmp = virXMLPropString(nodes[i], "driver"); tmp = virXMLPropString(nodes[i], "driver");
if (tmp) { if (tmp) {
int value = virDomainIOAPICTypeFromString(tmp); int value = virDomainIOAPICTypeFromString(tmp);
if (value < 0) { if (value < 0 || value == VIR_DOMAIN_IOAPIC_NONE) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Unknown driver mode: %s"), _("Unknown driver mode: %s"),
tmp); tmp);
goto error; goto error;
} }
def->ioapic = value; def->features[val] = value;
def->features[val] = VIR_TRISTATE_SWITCH_ON;
VIR_FREE(tmp); VIR_FREE(tmp);
} }
break; break;
@ -21410,16 +21409,13 @@ virDomainDefFeaturesCheckABIStability(virDomainDefPtr src,
break; break;
case VIR_DOMAIN_FEATURE_IOAPIC: case VIR_DOMAIN_FEATURE_IOAPIC:
if (src->features[i] != dst->features[i] || if (src->features[i] != dst->features[i]) {
src->ioapic != dst->ioapic) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("State of feature '%s' differs: " _("State of feature '%s' differs: "
"source: '%s,%s=%s', destination: '%s,%s=%s'"), "source: '%s=%s', destination: '%s=%s'"),
featureName, featureName,
virTristateSwitchTypeToString(src->features[i]), "driver", virDomainIOAPICTypeToString(src->features[i]),
"driver", virDomainIOAPICTypeToString(src->ioapic), "driver", virDomainIOAPICTypeToString(dst->features[i]));
virTristateSwitchTypeToString(dst->features[i]),
"driver", virDomainIOAPICTypeToString(dst->ioapic));
return false; return false;
} }
break; break;
@ -26945,10 +26941,11 @@ virDomainDefFormatInternal(virDomainDefPtr def,
break; break;
case VIR_DOMAIN_FEATURE_IOAPIC: case VIR_DOMAIN_FEATURE_IOAPIC:
if (def->features[i] == VIR_TRISTATE_SWITCH_ON) { if (def->features[i] == VIR_DOMAIN_IOAPIC_NONE)
virBufferAsprintf(buf, "<ioapic driver='%s'/>\n", break;
virDomainIOAPICTypeToString(def->ioapic));
} virBufferAsprintf(buf, "<ioapic driver='%s'/>\n",
virDomainIOAPICTypeToString(def->features[i]));
break; break;
case VIR_DOMAIN_FEATURE_HPT: case VIR_DOMAIN_FEATURE_HPT:

View File

@ -1861,7 +1861,8 @@ struct _virDomainLoaderDef {
void virDomainLoaderDefFree(virDomainLoaderDefPtr loader); void virDomainLoaderDefFree(virDomainLoaderDefPtr loader);
typedef enum { typedef enum {
VIR_DOMAIN_IOAPIC_QEMU = 0, VIR_DOMAIN_IOAPIC_NONE = 0,
VIR_DOMAIN_IOAPIC_QEMU,
VIR_DOMAIN_IOAPIC_KVM, VIR_DOMAIN_IOAPIC_KVM,
VIR_DOMAIN_IOAPIC_LAST VIR_DOMAIN_IOAPIC_LAST
@ -2352,21 +2353,18 @@ struct _virDomainDef {
virDomainOSDef os; virDomainOSDef os;
char *emulator; char *emulator;
/* These three options are of type virTristateSwitch, /* Most {caps_,hyperv_,kvm_,}feature options utilize a virTristateSwitch
* except VIR_DOMAIN_FEATURE_CAPABILITIES that is of type * to handle support. A few assign specific data values to the option.
* virDomainCapabilitiesPolicy */ * See virDomainDefFeaturesCheckABIStability() for details. */
int features[VIR_DOMAIN_FEATURE_LAST]; int features[VIR_DOMAIN_FEATURE_LAST];
int apic_eoi; int caps_features[VIR_DOMAIN_CAPS_FEATURE_LAST];
int hyperv_features[VIR_DOMAIN_HYPERV_LAST]; int hyperv_features[VIR_DOMAIN_HYPERV_LAST];
int kvm_features[VIR_DOMAIN_KVM_LAST]; int kvm_features[VIR_DOMAIN_KVM_LAST];
unsigned int hyperv_spinlocks; unsigned int hyperv_spinlocks;
virGICVersion gic_version; virGICVersion gic_version;
char *hyperv_vendor_id; char *hyperv_vendor_id;
virDomainIOAPIC ioapic;
virDomainHPTResizing hpt_resizing; virDomainHPTResizing hpt_resizing;
int apic_eoi;
/* These options are of type virTristateSwitch: ON = keep, OFF = drop */
int caps_features[VIR_DOMAIN_CAPS_FEATURE_LAST];
virDomainClockDef clock; virDomainClockDef clock;

View File

@ -7223,14 +7223,14 @@ qemuBuildMachineCommandLine(virCommandPtr cmd,
} }
} }
if (def->features[VIR_DOMAIN_FEATURE_IOAPIC] == VIR_TRISTATE_SWITCH_ON) { if (def->features[VIR_DOMAIN_FEATURE_IOAPIC] != VIR_DOMAIN_IOAPIC_NONE) {
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_MACHINE_KERNEL_IRQCHIP)) { if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_MACHINE_KERNEL_IRQCHIP)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("I/O APIC tuning is not supported by this " _("I/O APIC tuning is not supported by this "
"QEMU binary")); "QEMU binary"));
goto cleanup; goto cleanup;
} }
switch (def->ioapic) { switch ((virDomainIOAPIC) def->features[VIR_DOMAIN_FEATURE_IOAPIC]) {
case VIR_DOMAIN_IOAPIC_QEMU: case VIR_DOMAIN_IOAPIC_QEMU:
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_MACHINE_KERNEL_IRQCHIP_SPLIT)) { if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_MACHINE_KERNEL_IRQCHIP_SPLIT)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
@ -7243,6 +7243,7 @@ qemuBuildMachineCommandLine(virCommandPtr cmd,
case VIR_DOMAIN_IOAPIC_KVM: case VIR_DOMAIN_IOAPIC_KVM:
virBufferAddLit(&buf, ",kernel_irqchip=on"); virBufferAddLit(&buf, ",kernel_irqchip=on");
break; break;
case VIR_DOMAIN_IOAPIC_NONE:
case VIR_DOMAIN_IOAPIC_LAST: case VIR_DOMAIN_IOAPIC_LAST:
break; break;
} }

View File

@ -3320,7 +3320,7 @@ qemuDomainDefValidateFeatures(const virDomainDef *def)
switch ((virDomainFeature) i) { switch ((virDomainFeature) i) {
case VIR_DOMAIN_FEATURE_IOAPIC: case VIR_DOMAIN_FEATURE_IOAPIC:
if (def->features[i] == VIR_TRISTATE_SWITCH_ON && if (def->features[i] != VIR_DOMAIN_IOAPIC_NONE &&
!ARCH_IS_X86(def->os.arch)) { !ARCH_IS_X86(def->os.arch)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("The '%s' feature is not supported for " _("The '%s' feature is not supported for "