]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: Fix GIC behavior for the default case
authorAndrea Bolognani <abologna@redhat.com>
Thu, 1 Feb 2018 16:52:48 +0000 (17:52 +0100)
committerAndrea Bolognani <abologna@redhat.com>
Tue, 13 Feb 2018 13:40:03 +0000 (14:40 +0100)
When no GIC version is specified, we currently default to GIC v2;
however, that's not a great default, since guests will fail to
start if the hardware only supports GIC v3.

Change the behavior so that a sensible default is chosen instead.
That basically means using the same algorithm whether the user
didn't explicitly enable the GIC feature or they explicitly
enabled it but didn't specify any GIC version.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
src/qemu/qemu_domain.c
tests/qemuxml2argvdata/aarch64-gic-default-both.args
tests/qemuxml2argvdata/aarch64-gic-default-v3.args
tests/qemuxml2xmloutdata/aarch64-gic-default-both.xml
tests/qemuxml2xmloutdata/aarch64-gic-default-v3.xml

index 59491fc21ccf2ee590c7e6b43a0ccbd4fd041352..e943c675544e9c9e5819754bbe840d2d90f19e83 100644 (file)
@@ -2927,13 +2927,14 @@ static void
 qemuDomainDefEnableDefaultFeatures(virDomainDefPtr def,
                                    virQEMUCapsPtr qemuCaps)
 {
-    virGICVersion version;
-
-    /* The virt machine type always uses GIC: if the relevant element
+    /* The virt machine type always uses GIC: if the relevant information
      * was not included in the domain XML, we need to choose a suitable
      * GIC version ourselves */
-    if (def->features[VIR_DOMAIN_FEATURE_GIC] == VIR_TRISTATE_SWITCH_ABSENT &&
-        qemuDomainIsVirt(def)) {
+    if ((def->features[VIR_DOMAIN_FEATURE_GIC] == VIR_TRISTATE_SWITCH_ABSENT &&
+         qemuDomainIsVirt(def)) ||
+        (def->features[VIR_DOMAIN_FEATURE_GIC] == VIR_TRISTATE_SWITCH_ON &&
+         def->gic_version == VIR_GIC_VERSION_NONE)) {
+        virGICVersion version;
 
         VIR_DEBUG("Looking for usable GIC version in domain capabilities");
         for (version = VIR_GIC_VERSION_LAST - 1;
@@ -2948,9 +2949,6 @@ qemuDomainDefEnableDefaultFeatures(virDomainDefPtr def,
              * and rely on the code below to pick the default version, GICv2,
              * which supports all the features we need.
              *
-             * We'll want to revisit this once MSI support for GICv3 has been
-             * implemented in QEMU.
-             *
              * See https://bugzilla.redhat.com/show_bug.cgi?id=1414081 */
             if (version == VIR_GIC_VERSION_3 &&
                 def->virtType == VIR_DOMAIN_VIRT_QEMU) {
@@ -2967,17 +2965,17 @@ qemuDomainDefEnableDefaultFeatures(virDomainDefPtr def,
             }
         }
 
+        /* Use the default GIC version (GICv2) as a last-ditch attempt
+         * if no match could be found above */
+        if (def->gic_version == VIR_GIC_VERSION_NONE) {
+            VIR_DEBUG("Using GIC version 2 (default)");
+            def->gic_version = VIR_GIC_VERSION_2;
+        }
+
         /* Even if we haven't found a usable GIC version in the domain
          * capabilities, we still want to enable this */
         def->features[VIR_DOMAIN_FEATURE_GIC] = VIR_TRISTATE_SWITCH_ON;
     }
-
-    /* Use the default GIC version (GICv2) if no version was specified */
-    if (def->features[VIR_DOMAIN_FEATURE_GIC] == VIR_TRISTATE_SWITCH_ON &&
-        def->gic_version == VIR_GIC_VERSION_NONE) {
-        VIR_DEBUG("Using GIC version 2 (default)");
-        def->gic_version = VIR_GIC_VERSION_2;
-    }
 }
 
 
index 04ecd4ce76c27a39f4ab981360125fdb30a07fea..6209eff4b02f3e4d01b722c425a91c493ee3ebab 120000 (symlink)
@@ -1 +1 @@
-aarch64-gic-v2.args
\ No newline at end of file
+aarch64-gic-v3.args
\ No newline at end of file
index 04ecd4ce76c27a39f4ab981360125fdb30a07fea..6209eff4b02f3e4d01b722c425a91c493ee3ebab 120000 (symlink)
@@ -1 +1 @@
-aarch64-gic-v2.args
\ No newline at end of file
+aarch64-gic-v3.args
\ No newline at end of file
index ee470fb1fae5a61ff22e3df936a02381877a99fc..bf9d58c385e2e37f0e0f6d697ef131941426a87f 120000 (symlink)
@@ -1 +1 @@
-../qemuxml2argvdata/aarch64-gic-v2.xml
\ No newline at end of file
+../qemuxml2argvdata/aarch64-gic-v3.xml
\ No newline at end of file
index ee470fb1fae5a61ff22e3df936a02381877a99fc..bf9d58c385e2e37f0e0f6d697ef131941426a87f 120000 (symlink)
@@ -1 +1 @@
-../qemuxml2argvdata/aarch64-gic-v2.xml
\ No newline at end of file
+../qemuxml2argvdata/aarch64-gic-v3.xml
\ No newline at end of file