]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemuDeviceVideoGetModel: Deduplicate a check
authorMichal Privoznik <mprivozn@redhat.com>
Fri, 11 Jun 2021 11:31:56 +0000 (13:31 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Fri, 11 Jun 2021 19:53:42 +0000 (21:53 +0200)
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@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
src/qemu/qemu_command.c

index 7ca099bb3917c140220ebc89d35d29e8b7e9f6b6..9d8e41f4cde02e69bd7a27ca4c46432d026cdfd5 100644 (file)
@@ -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);