提交 1a012c9a 编写于 作者: A Andrea Bolognani

qemu: Automatically choose usable GIC version

When the <gic/> element in not present in the domain XML, use the
domain capabilities to figure out what GIC version is usable and
choose that one automatically.

This allows guests to be created on hardware that only supports
GIC v3 without having to update virt-manager and similar tools.

Keep using the default GIC version if the <gic/> element has been
added to the domain XML but no version has been specified, as not
to break existing guests.
上级 58f0152f
...@@ -1931,24 +1931,41 @@ qemuDomainDefAddDefaultDevices(virDomainDefPtr def, ...@@ -1931,24 +1931,41 @@ qemuDomainDefAddDefaultDevices(virDomainDefPtr def,
/** /**
* qemuDomainDefEnableDefaultFeatures: * qemuDomainDefEnableDefaultFeatures:
* @def: domain definition * @def: domain definition
* @qemuCaps: QEMU capabilities
* *
* Make sure that features that should be enabled by default are actually * Make sure that features that should be enabled by default are actually
* enabled and configure default values related to those features. * enabled and configure default values related to those features.
*/ */
static void static void
qemuDomainDefEnableDefaultFeatures(virDomainDefPtr def) qemuDomainDefEnableDefaultFeatures(virDomainDefPtr def,
{ virQEMUCapsPtr qemuCaps)
switch (def->os.arch) { {
case VIR_ARCH_ARMV7L: virGICVersion version;
case VIR_ARCH_AARCH64:
if (qemuDomainMachineIsVirt(def)) { /* The virt machine type always uses GIC: if the relevant element
/* GIC is always available to ARM virt machines */ * was not included in the domain XML, we need to choose a suitable
def->features[VIR_DOMAIN_FEATURE_GIC] = VIR_TRISTATE_SWITCH_ON; * GIC version ourselves */
if (def->features[VIR_DOMAIN_FEATURE_GIC] == VIR_TRISTATE_SWITCH_ABSENT &&
(def->os.arch == VIR_ARCH_ARMV7L || def->os.arch == VIR_ARCH_AARCH64) &&
qemuDomainMachineIsVirt(def)) {
VIR_DEBUG("Looking for usable GIC version in domain capabilities");
for (version = VIR_GIC_VERSION_LAST - 1;
version > VIR_GIC_VERSION_NONE;
version--) {
if (virQEMUCapsSupportsGICVersion(qemuCaps,
def->virtType,
version)) {
VIR_DEBUG("Using GIC version %s",
virGICVersionTypeToString(version));
def->gic_version = version;
break;
}
} }
break;
default: /* Even if we haven't found a usable GIC version in the domain
break; * capabilities, we still want to enable this */
def->features[VIR_DOMAIN_FEATURE_GIC] = VIR_TRISTATE_SWITCH_ON;
} }
/* Use the default GIC version if no version was specified */ /* Use the default GIC version if no version was specified */
...@@ -2047,7 +2064,7 @@ qemuDomainDefPostParse(virDomainDefPtr def, ...@@ -2047,7 +2064,7 @@ qemuDomainDefPostParse(virDomainDefPtr def,
if (qemuCanonicalizeMachine(def, qemuCaps) < 0) if (qemuCanonicalizeMachine(def, qemuCaps) < 0)
goto cleanup; goto cleanup;
qemuDomainDefEnableDefaultFeatures(def); qemuDomainDefEnableDefaultFeatures(def, qemuCaps);
qemuDomainRecheckInternalPaths(def, cfg, parseFlags); qemuDomainRecheckInternalPaths(def, cfg, parseFlags);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册