[libvirt] [PATCH v3 1/4] qemu: default video device type selection algoritm moved into its own function

Pavel Mores pmores at redhat.com
Mon Nov 25 10:54:23 UTC 2019


The default video device type selection algorithm we're about to deploy will
increase the amount of code dedicated to the task by amount enough to warrant
factoring the whole thing into its own function so as not to pollute the
caller qemuDomainDeviceVideoDefPostParse().  Do it now so that the actual
algorithm change later on is in a clean commit by itself and easy to review.

Signed-off-by: Pavel Mores <pmores at redhat.com>
---
 src/qemu/qemu_domain.c | 26 ++++++++++++++++----------
 1 file changed, 16 insertions(+), 10 deletions(-)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index d56dfa9f00..26da41f9ee 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -7876,20 +7876,26 @@ qemuDomainDeviceNetDefPostParse(virDomainNetDefPtr net,
 }
 
 
+static int
+qemuDomainDefaultVideoDevice(const virDomainDef *def)
+{
+    if (ARCH_IS_PPC64(def->os.arch))
+        return VIR_DOMAIN_VIDEO_TYPE_VGA;
+    else if (qemuDomainIsARMVirt(def) ||
+             qemuDomainIsRISCVVirt(def) ||
+             ARCH_IS_S390(def->os.arch))
+        return VIR_DOMAIN_VIDEO_TYPE_VIRTIO;
+    else
+        return VIR_DOMAIN_VIDEO_TYPE_CIRRUS;
+}
+
+
 static int
 qemuDomainDeviceVideoDefPostParse(virDomainVideoDefPtr video,
                                   const virDomainDef *def)
 {
-    if (video->type == VIR_DOMAIN_VIDEO_TYPE_DEFAULT) {
-        if (ARCH_IS_PPC64(def->os.arch))
-            video->type = VIR_DOMAIN_VIDEO_TYPE_VGA;
-        else if (qemuDomainIsARMVirt(def) ||
-                 qemuDomainIsRISCVVirt(def) ||
-                 ARCH_IS_S390(def->os.arch))
-            video->type = VIR_DOMAIN_VIDEO_TYPE_VIRTIO;
-        else
-            video->type = VIR_DOMAIN_VIDEO_TYPE_CIRRUS;
-    }
+    if (video->type == VIR_DOMAIN_VIDEO_TYPE_DEFAULT)
+        video->type = qemuDomainDefaultVideoDevice(def);
 
     if (video->type == VIR_DOMAIN_VIDEO_TYPE_QXL &&
         !video->vgamem) {
-- 
2.21.0




More information about the libvir-list mailing list