[PATCH 1/3] qemu: refactor: use switch for enum in qemuProcessGraphicsReservePorts

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

 



---
 src/qemu/qemu_process.c | 30 +++++++++++++++++++++---------
 1 file changed, 21 insertions(+), 9 deletions(-)

diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 3552a31..6aaaa10 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -4056,16 +4056,21 @@ qemuProcessGraphicsReservePorts(virQEMUDriverPtr driver,
         glisten->type != VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK)
         return 0;
 
-    if (graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC &&
-        !graphics->data.vnc.autoport) {
-        if (virPortAllocatorSetUsed(driver->remotePorts,
-                                    graphics->data.vnc.port,
-                                    true) < 0)
-            return -1;
-        graphics->data.vnc.portReserved = true;
+    switch (graphics->type) {
+    case VIR_DOMAIN_GRAPHICS_TYPE_VNC:
+        if (!graphics->data.vnc.autoport) {
+            if (virPortAllocatorSetUsed(driver->remotePorts,
+                                        graphics->data.vnc.port,
+                                        true) < 0)
+                return -1;
+            graphics->data.vnc.portReserved = true;
+        }
+        break;
+
+    case VIR_DOMAIN_GRAPHICS_TYPE_SPICE:
+        if (graphics->data.spice.autoport)
+            return 0;
 
-    } else if (graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE &&
-               !graphics->data.spice.autoport) {
         if (graphics->data.spice.port > 0) {
             if (virPortAllocatorSetUsed(driver->remotePorts,
                                         graphics->data.spice.port,
@@ -4081,6 +4086,13 @@ qemuProcessGraphicsReservePorts(virQEMUDriverPtr driver,
                 return -1;
             graphics->data.spice.tlsPortReserved = true;
         }
+        break;
+
+    case VIR_DOMAIN_GRAPHICS_TYPE_SDL:
+    case VIR_DOMAIN_GRAPHICS_TYPE_RDP:
+    case VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP:
+    case VIR_DOMAIN_GRAPHICS_TYPE_LAST:
+        break;
     }
 
     return 0;
-- 
1.8.3.1

--
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]
  Powered by Linux