[PATCH v2 2/3] qemu: Add support for gic-version machine option

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Support for GICv3 has been recently introduced in qemu using gic-version
option for the 'virt' machine. The option can actually take values of
'2', '3' and 'host', however, since in libvirt this is a numeric
parameter, we limit it only to 2 and 3. Value of 2 is not added to the
command line in order to keep backward compatibility with older qemu
versions.

Signed-off-by: Pavel Fedin <p.fedin@xxxxxxxxxxx>
---
 src/qemu/qemu_command.c | 43 ++++++++++++++++++++++++++++++-------------
 1 file changed, 30 insertions(+), 13 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index bb1835c..a47e188 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -7702,19 +7702,6 @@ qemuBuildCpuArgStr(virQEMUDriverPtr driver,
         have_cpu = true;
     }
 
-    if (def->features[VIR_DOMAIN_FEATURE_GIC] == VIR_TRISTATE_SWITCH_ON) {
-        if (def->gic_version && def->gic_version != 2) {
-            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                           _("gic version '%u' is not supported"),
-                           def->gic_version);
-            goto cleanup;
-        }
-
-        /* There's no command line argument currently to turn on/off GIC. It's
-         * done automatically by qemu-system-aarch64. But if this changes, lets
-         * put the code here. */
-    }
-
     if (virBufferCheckError(&buf) < 0)
         goto cleanup;
 
@@ -7931,6 +7918,36 @@ qemuBuildMachineArgStr(virCommandPtr cmd,
             return -1;
         }
 
+	if (def->features[VIR_DOMAIN_FEATURE_GIC] == VIR_TRISTATE_SWITCH_ON) {
+	    if (def->gic_version) {
+       	        if (!STREQ(def->os.machine, "virt") &&
+       	            !STRPREFIX(def->os.machine, "virt-")) {
+       	            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                                   _("gic-version option is available "
+                                     "only for virt machine"));
+                    virBufferFreeAndReset(&buf);
+                    return -1;
+       	        }
+
+	        /* 2 is the default, so we don't put it as option for
+	         * backwards compatibility
+	         */
+                if (def->gic_version != 2) {
+                    if (virQEMUCapsGet(qemuCaps,
+                                       QEMU_CAPS_MACH_VIRT_GIC_VERSION)) {
+                        virBufferAsprintf(&buf, ",gic-version=%d",
+                                          def->gic_version);
+                    } else {
+                        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                                       _("gic-version option is not available "
+                                         "with this QEMU binary"));
+                        virBufferFreeAndReset(&buf);
+                        return -1;
+                    }
+                }
+	    }
+	}
+
         virCommandAddArgBuffer(cmd, &buf);
     }
 
-- 
2.1.4

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]