[PATCH 4/4] qemu: cleanup code to relece SPICE ports
Nikolay Shirokovskiy
nikolay.shirokovskiy at openvz.org
Tue Apr 12 07:31:30 UTC 2022
SPICE ports cleanup looks overly complicated. We can just set *reserved
flags whenever port is reserved (auto or non auto).
Also *Reserved flags are not cleared on stop in case of reconnect with
autoport (flags are set on reconnect in qemuProcessGraphicsReservePorts
call). Yeah config is freed in the end of stopping domain but still.
Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy at openvz.org>
---
src/qemu/qemu_process.c | 25 ++++++++-----------------
1 file changed, 8 insertions(+), 17 deletions(-)
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 6db8bbc421..08a38edfb6 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -4071,9 +4071,7 @@ qemuProcessSPICEAllocatePorts(virQEMUDriver *driver,
return -1;
graphics->data.spice.port = port;
-
- if (!graphics->data.spice.autoport)
- graphics->data.spice.portReserved = true;
+ graphics->data.spice.portReserved = true;
}
if (needTLSPort || graphics->data.spice.tlsPort == -1) {
@@ -4088,9 +4086,7 @@ qemuProcessSPICEAllocatePorts(virQEMUDriver *driver,
return -1;
graphics->data.spice.tlsPort = tlsPort;
-
- if (!graphics->data.spice.autoport)
- graphics->data.spice.tlsPortReserved = true;
+ graphics->data.spice.tlsPortReserved = true;
}
return 0;
@@ -8279,19 +8275,14 @@ void qemuProcessStop(virQEMUDriver *driver,
}
}
if (graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE) {
- if (graphics->data.spice.autoport) {
+ if (graphics->data.spice.portReserved) {
virPortAllocatorRelease(graphics->data.spice.port);
- virPortAllocatorRelease(graphics->data.spice.tlsPort);
- } else {
- if (graphics->data.spice.portReserved) {
- virPortAllocatorRelease(graphics->data.spice.port);
- graphics->data.spice.portReserved = false;
- }
+ graphics->data.spice.portReserved = false;
+ }
- if (graphics->data.spice.tlsPortReserved) {
- virPortAllocatorRelease(graphics->data.spice.tlsPort);
- graphics->data.spice.tlsPortReserved = false;
- }
+ if (graphics->data.spice.tlsPortReserved) {
+ virPortAllocatorRelease(graphics->data.spice.tlsPort);
+ graphics->data.spice.tlsPortReserved = false;
}
}
}
--
2.35.1
More information about the libvir-list
mailing list