提交 550950e5 编写于 作者: A Andrea Bolognani

qemu: Format gic-version=2 on the command line

Up until now we have only formatted non-default GIC versions on
the command line, in order to maintain compatibility with older
QEMU versions that didn't implement the gic-version option to
begin with; however, doing so is entirely unnecessary for newer
QEMU versions, where the option is available. Moreover, having
the GIC version formatted on the command line at all times
ensures that QEMU changing its own defaults doesn't affect the
ABI of libvirt guests.

A few test cases are removed to avoid extra churn. It doesn't
matter for coverage, as those scenarios are already covered by
other parts of the test suite.

This patch is better viewed with 'git show -w'.
Signed-off-by: NAndrea Bolognani <abologna@redhat.com>
Reviewed-by: NJohn Ferlan <jferlan@redhat.com>
上级 4d7384eb
......@@ -7295,21 +7295,39 @@ qemuBuildMachineCommandLine(virCommandPtr cmd,
goto cleanup;
if (def->features[VIR_DOMAIN_FEATURE_GIC] == VIR_TRISTATE_SWITCH_ON) {
if (def->gic_version != VIR_GIC_VERSION_NONE) {
/* The default GIC version (GICv2) should not be specified on
* the QEMU commandline for backwards compatibility reasons */
if (def->gic_version != VIR_GIC_VERSION_2) {
if (!virQEMUCapsGet(qemuCaps,
QEMU_CAPS_MACH_VIRT_GIC_VERSION)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("gic-version option is not available "
"with this QEMU binary"));
goto cleanup;
}
bool hasGICVersionOption = virQEMUCapsGet(qemuCaps,
QEMU_CAPS_MACH_VIRT_GIC_VERSION);
switch ((virGICVersion) def->gic_version) {
case VIR_GIC_VERSION_2:
if (!hasGICVersionOption) {
/* If the gic-version option is not available, we can't
* configure the GIC; however, we know that before the
* option was introduced the guests would always get a
* GICv2, so in order to maintain compatibility with
* those old QEMU versions all we need to do is stop
* early instead of erroring out */
break;
}
ATTRIBUTE_FALLTHROUGH;
virBufferAsprintf(&buf, ",gic-version=%s",
virGICVersionTypeToString(def->gic_version));
case VIR_GIC_VERSION_3:
case VIR_GIC_VERSION_HOST:
if (!hasGICVersionOption) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("gic-version option is not available "
"with this QEMU binary"));
goto cleanup;
}
virBufferAsprintf(&buf, ",gic-version=%s",
virGICVersionTypeToString(def->gic_version));
break;
case VIR_GIC_VERSION_NONE:
case VIR_GIC_VERSION_LAST:
default:
break;
}
}
......
......@@ -7,7 +7,7 @@ QEMU_AUDIO_DRV=none \
/usr/bin/qemu-system-aarch64 \
-name guest \
-S \
-machine virt,accel=tcg \
-machine virt,accel=tcg,gic-version=2 \
-cpu cortex-a57 \
-m 1024 \
-smp 1,sockets=1,cores=1,threads=1 \
......
......@@ -7,7 +7,7 @@ QEMU_AUDIO_DRV=none \
/usr/bin/qemu-system-aarch64 \
-name aarch64test \
-S \
-machine virt,accel=kvm \
-machine virt,accel=kvm,gic-version=2 \
-cpu host \
-m 1024 \
-smp 1,sockets=1,cores=1,threads=1 \
......
......@@ -2652,8 +2652,6 @@ mymain(void)
DO_TEST("aarch64-cpu-passthrough",
QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DEVICE_VIRTIO_MMIO,
QEMU_CAPS_KVM);
DO_TEST_GIC("aarch64-gic-none", GIC_NONE,
QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT);
DO_TEST_GIC("aarch64-gic-none", GIC_NONE,
QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT,
QEMU_CAPS_MACH_VIRT_GIC_VERSION);
......@@ -2669,8 +2667,6 @@ mymain(void)
DO_TEST_GIC("aarch64-gic-none-tcg", GIC_BOTH,
QEMU_CAPS_MACHINE_OPT,
QEMU_CAPS_MACH_VIRT_GIC_VERSION);
DO_TEST_GIC("aarch64-gic-default", GIC_NONE,
QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT);
DO_TEST_GIC("aarch64-gic-default", GIC_NONE,
QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT,
QEMU_CAPS_MACH_VIRT_GIC_VERSION);
......@@ -2683,8 +2679,6 @@ mymain(void)
DO_TEST_GIC("aarch64-gic-default-both", GIC_BOTH,
QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT,
QEMU_CAPS_MACH_VIRT_GIC_VERSION);
DO_TEST_GIC("aarch64-gic-v2", GIC_NONE,
QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT);
DO_TEST_GIC("aarch64-gic-v2", GIC_NONE,
QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT,
QEMU_CAPS_MACH_VIRT_GIC_VERSION);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册