[PATCH 3/7] qemuDeviceVideoGetModel: Deduplicate a check

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

 



There is the same check written twice (whether given video card
is primary one and whether it supports VGA mode). Write it just
once and store it in a boolean variable.

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 src/qemu/qemu_command.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 7ca099bb39..9d8e41f4cd 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -4200,18 +4200,22 @@ qemuDeviceVideoGetModel(virQEMUCaps *qemuCaps,
                         const virDomainVideoDef *video)
 {
     const char *model = NULL;
+    bool primaryVga = false;
+
+    if (video->primary && qemuDomainSupportsVideoVga(video, qemuCaps))
+        primaryVga = true;
 
     /* We try to chose the best model for primary video device by preferring
      * model with VGA compatibility mode.  For some video devices on some
      * architectures there might not be such model so fallback to one
      * without VGA compatibility mode. */
     if (video->backend == VIR_DOMAIN_VIDEO_BACKEND_TYPE_VHOSTUSER) {
-        if (video->primary && qemuDomainSupportsVideoVga(video, qemuCaps))
+        if (primaryVga)
             model = "vhost-user-vga";
         else
             model = "vhost-user-gpu";
     } else {
-        if (video->primary && qemuDomainSupportsVideoVga(video, qemuCaps))
+        if (primaryVga)
             model = qemuDeviceVideoTypeToString(video->type);
         else
             model = qemuDeviceVideoSecondaryTypeToString(video->type);
-- 
2.31.1




[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]

  Powered by Linux