[PATCH 2/4] qemu: fix releasing VNC websocket port domain does not own

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

 



Scenario is with two domains with same VNC websocket port.

- start first domain
- start second, it will fail as port is occupied

As a result port will be released which breaks port reservation logic.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@xxxxxxxxxx>
---
 src/conf/domain_conf.h  |  1 +
 src/qemu/qemu_process.c | 10 ++++++----
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 694491cd63..88a411d00c 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1901,6 +1901,7 @@ struct _virDomainGraphicsDef {
             bool portReserved;
             int websocket;
             bool websocketGenerated;
+            bool websocketReserved;
             bool autoport;
             char *keymap;
             virDomainGraphicsAuthDef auth;
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index cae87cdeca..9c7583a10b 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -4678,9 +4678,11 @@ qemuProcessGraphicsReservePorts(virDomainGraphicsDef *graphics,
                 return -1;
             graphics->data.vnc.portReserved = true;
         }
-        if (graphics->data.vnc.websocket > 0 &&
-            virPortAllocatorSetUsed(graphics->data.vnc.websocket) < 0)
-            return -1;
+        if (graphics->data.vnc.websocket > 0) {
+            if (virPortAllocatorSetUsed(graphics->data.vnc.websocket) < 0)
+                return -1;
+            graphics->data.vnc.websocketReserved = true;
+        }
         break;
 
     case VIR_DOMAIN_GRAPHICS_TYPE_SPICE:
@@ -8270,7 +8272,7 @@ void qemuProcessStop(virQEMUDriver *driver,
                 virPortAllocatorRelease(graphics->data.vnc.websocket);
                 graphics->data.vnc.websocketGenerated = false;
                 graphics->data.vnc.websocket = -1;
-            } else if (graphics->data.vnc.websocket) {
+            } else if (graphics->data.vnc.websocketReserved) {
                 virPortAllocatorRelease(graphics->data.vnc.websocket);
             }
         }
-- 
2.35.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