VNC websocket port cleanup looks a bit repetetive. Let's set websocketReserved flag whenever we reserve port (auto or not). Also websocketReserved flag is not cleared on stop in case of reconnect with auto port (flags is set on reconnect in qemuProcessGraphicsReservePorts call). Yeah config is freed in the end of stopping domain but still. Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@xxxxxxxxxx> --- src/qemu/qemu_process.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 9c7583a10b..6db8bbc421 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -4002,6 +4002,7 @@ qemuProcessVNCAllocatePorts(virQEMUDriver *driver, return -1; graphics->data.vnc.websocket = port; graphics->data.vnc.websocketGenerated = true; + graphics->data.vnc.websocketReserved = true; } return 0; @@ -8268,12 +8269,13 @@ void qemuProcessStop(virQEMUDriver *driver, virPortAllocatorRelease(graphics->data.vnc.port); graphics->data.vnc.portReserved = false; } - if (graphics->data.vnc.websocketGenerated) { + if (graphics->data.vnc.websocketReserved) { virPortAllocatorRelease(graphics->data.vnc.websocket); + graphics->data.vnc.websocketReserved = false; + } + if (graphics->data.vnc.websocketGenerated) { graphics->data.vnc.websocketGenerated = false; graphics->data.vnc.websocket = -1; - } else if (graphics->data.vnc.websocketReserved) { - virPortAllocatorRelease(graphics->data.vnc.websocket); } } if (graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE) { -- 2.35.1