提交 c5a451ef 编写于 作者: A Andrea Bolognani

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: NAndrea Bolognani <abologna@redhat.com>
Reviewed-by: NJohn Ferlan <jferlan@redhat.com>
上级 132548ef
......@@ -900,6 +900,7 @@ VIR_ENUM_IMPL(virDomainLoader,
VIR_ENUM_IMPL(virDomainIOAPIC,
VIR_DOMAIN_IOAPIC_LAST,
"none",
"qemu",
"kvm")
......@@ -5913,8 +5914,7 @@ virDomainDefValidateInternal(const virDomainDef *def)
if (def->iommu &&
def->iommu->intremap == VIR_TRISTATE_SWITCH_ON &&
(def->features[VIR_DOMAIN_FEATURE_IOAPIC] != VIR_TRISTATE_SWITCH_ON ||
def->ioapic != VIR_DOMAIN_IOAPIC_QEMU)) {
def->features[VIR_DOMAIN_FEATURE_IOAPIC] != VIR_DOMAIN_IOAPIC_QEMU) {
virReportError(VIR_ERR_XML_ERROR, "%s",
_("IOMMU interrupt remapping requires split I/O APIC "
"(ioapic driver='qemu')"));
......@@ -19224,14 +19224,13 @@ virDomainDefParseXML(xmlDocPtr xml,
tmp = virXMLPropString(nodes[i], "driver");
if (tmp) {
int value = virDomainIOAPICTypeFromString(tmp);
if (value < 0) {
if (value < 0 || value == VIR_DOMAIN_IOAPIC_NONE) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Unknown driver mode: %s"),
tmp);
goto error;
}
def->ioapic = value;
def->features[val] = VIR_TRISTATE_SWITCH_ON;
def->features[val] = value;
VIR_FREE(tmp);
}
break;
......@@ -21410,16 +21409,13 @@ virDomainDefFeaturesCheckABIStability(virDomainDefPtr src,
break;
case VIR_DOMAIN_FEATURE_IOAPIC:
if (src->features[i] != dst->features[i] ||
src->ioapic != dst->ioapic) {
if (src->features[i] != dst->features[i]) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("State of feature '%s' differs: "
"source: '%s,%s=%s', destination: '%s,%s=%s'"),
"source: '%s=%s', destination: '%s=%s'"),
featureName,
virTristateSwitchTypeToString(src->features[i]),
"driver", virDomainIOAPICTypeToString(src->ioapic),
virTristateSwitchTypeToString(dst->features[i]),
"driver", virDomainIOAPICTypeToString(dst->ioapic));
"driver", virDomainIOAPICTypeToString(src->features[i]),
"driver", virDomainIOAPICTypeToString(dst->features[i]));
return false;
}
break;
......@@ -26945,10 +26941,11 @@ virDomainDefFormatInternal(virDomainDefPtr def,
break;
case VIR_DOMAIN_FEATURE_IOAPIC:
if (def->features[i] == VIR_TRISTATE_SWITCH_ON) {
virBufferAsprintf(buf, "<ioapic driver='%s'/>\n",
virDomainIOAPICTypeToString(def->ioapic));
}
if (def->features[i] == VIR_DOMAIN_IOAPIC_NONE)
break;
virBufferAsprintf(buf, "<ioapic driver='%s'/>\n",
virDomainIOAPICTypeToString(def->features[i]));
break;
case VIR_DOMAIN_FEATURE_HPT:
......
......@@ -1861,7 +1861,8 @@ struct _virDomainLoaderDef {
void virDomainLoaderDefFree(virDomainLoaderDefPtr loader);
typedef enum {
VIR_DOMAIN_IOAPIC_QEMU = 0,
VIR_DOMAIN_IOAPIC_NONE = 0,
VIR_DOMAIN_IOAPIC_QEMU,
VIR_DOMAIN_IOAPIC_KVM,
VIR_DOMAIN_IOAPIC_LAST
......@@ -2352,21 +2353,18 @@ struct _virDomainDef {
virDomainOSDef os;
char *emulator;
/* These three options are of type virTristateSwitch,
* except VIR_DOMAIN_FEATURE_CAPABILITIES that is of type
* virDomainCapabilitiesPolicy */
/* Most {caps_,hyperv_,kvm_,}feature options utilize a virTristateSwitch
* to handle support. A few assign specific data values to the option.
* See virDomainDefFeaturesCheckABIStability() for details. */
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 kvm_features[VIR_DOMAIN_KVM_LAST];
unsigned int hyperv_spinlocks;
virGICVersion gic_version;
char *hyperv_vendor_id;
virDomainIOAPIC ioapic;
virDomainHPTResizing hpt_resizing;
/* These options are of type virTristateSwitch: ON = keep, OFF = drop */
int caps_features[VIR_DOMAIN_CAPS_FEATURE_LAST];
int apic_eoi;
virDomainClockDef clock;
......
......@@ -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)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("I/O APIC tuning is not supported by this "
"QEMU binary"));
goto cleanup;
}
switch (def->ioapic) {
switch ((virDomainIOAPIC) def->features[VIR_DOMAIN_FEATURE_IOAPIC]) {
case VIR_DOMAIN_IOAPIC_QEMU:
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_MACHINE_KERNEL_IRQCHIP_SPLIT)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
......@@ -7243,6 +7243,7 @@ qemuBuildMachineCommandLine(virCommandPtr cmd,
case VIR_DOMAIN_IOAPIC_KVM:
virBufferAddLit(&buf, ",kernel_irqchip=on");
break;
case VIR_DOMAIN_IOAPIC_NONE:
case VIR_DOMAIN_IOAPIC_LAST:
break;
}
......
......@@ -3320,7 +3320,7 @@ qemuDomainDefValidateFeatures(const virDomainDef *def)
switch ((virDomainFeature) i) {
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)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("The '%s' feature is not supported for "
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册