]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: Format gic-version=2 on the command line
authorAndrea Bolognani <abologna@redhat.com>
Thu, 29 Mar 2018 11:38:30 +0000 (13:38 +0200)
committerAndrea Bolognani <abologna@redhat.com>
Wed, 11 Apr 2018 13:56:11 +0000 (15:56 +0200)
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: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
src/qemu/qemu_command.c
tests/qemuxml2argvdata/aarch64-gic-none-tcg.args
tests/qemuxml2argvdata/aarch64-gic-v2.args
tests/qemuxml2argvtest.c

index 514c3ab2efd6d58df8229305634cfdae615d0421..955134d01904120d982b62bf3d06be8055424302 100644 (file)
@@ -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;
             }
         }
 
index 4e3c0eee2db2c9258e9a8fa0a59488361dfa2c07..b766a821d5fbaca2ce4df37d03f9052443bf1dba 100644 (file)
@@ -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 \
index 7e88bbde3f25821bd6065f972ce7b2bd558b80c8..eec5c4a0829e709d8fa5e7077dc3b2e1a4acd251 100644 (file)
@@ -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 \
index 165137e93cc31ca28621455699ab46c9d305a55d..3a328e02a27d6901bafd3e0be4a6e304014c81df 100644 (file)
@@ -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);