mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-11 07:17:44 +00:00
qemu: Return SPICE ports on domain shutdown
Commit ed0d9f6c0c
added support for
automatic port allocation for SPICE but forgot to mark such ports as
unused when they are not used anymore.
This commit is contained in:
parent
2deb32ae02
commit
e6cf98ceb5
@ -2491,6 +2491,19 @@ static int qemudNextFreePort(struct qemud_driver *driver,
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
qemuReturnPort(struct qemud_driver *driver,
|
||||
int port)
|
||||
{
|
||||
if (port < QEMU_VNC_PORT_MIN)
|
||||
return;
|
||||
|
||||
if (virBitmapClearBit(driver->reservedVNCPorts,
|
||||
port - QEMU_VNC_PORT_MIN) < 0)
|
||||
VIR_DEBUG("Could not mark port %d as unused", port);
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
qemuAssignPCIAddresses(virDomainDefPtr def)
|
||||
{
|
||||
@ -2696,6 +2709,7 @@ static int qemudStartVMDaemon(virConnectPtr conn,
|
||||
if (tlsPort < 0) {
|
||||
qemuReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
"%s", _("Unable to find an unused SPICE TLS port"));
|
||||
qemuReturnPort(driver, port);
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
@ -3099,14 +3113,14 @@ retry:
|
||||
*/
|
||||
if ((vm->def->ngraphics == 1) &&
|
||||
vm->def->graphics[0]->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC &&
|
||||
vm->def->graphics[0]->data.vnc.autoport &&
|
||||
vm->def->graphics[0]->data.vnc.port >= QEMU_VNC_PORT_MIN) {
|
||||
if (virBitmapClearBit(driver->reservedVNCPorts,
|
||||
vm->def->graphics[0]->data.vnc.port - \
|
||||
QEMU_VNC_PORT_MIN) < 0) {
|
||||
VIR_DEBUG("virBitmapClearBit failed on bit %d",
|
||||
vm->def->graphics[0]->data.vnc.port - QEMU_VNC_PORT_MIN);
|
||||
}
|
||||
vm->def->graphics[0]->data.vnc.autoport) {
|
||||
qemuReturnPort(driver, vm->def->graphics[0]->data.vnc.port);
|
||||
}
|
||||
if ((vm->def->ngraphics == 1) &&
|
||||
vm->def->graphics[0]->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE &&
|
||||
vm->def->graphics[0]->data.spice.autoport) {
|
||||
qemuReturnPort(driver, vm->def->graphics[0]->data.spice.port);
|
||||
qemuReturnPort(driver, vm->def->graphics[0]->data.spice.tlsPort);
|
||||
}
|
||||
|
||||
vm->pid = -1;
|
||||
|
Loading…
Reference in New Issue
Block a user