Commit ed0d9f6c0cdd56f38ce31b8d9b5293162addaa23 added support for automatic port allocation for SPICE but forgot to mark such ports as unused when they are not used anymore. --- src/qemu/qemu_driver.c | 30 ++++++++++++++++++++++-------- 1 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 1a26a50..1de6f4a 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -2491,6 +2491,19 @@ static int qemudNextFreePort(struct qemud_driver *driver, } +static void +qemudReturnPort(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")); + qemudReturnPort(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) { + qemudReturnPort(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) { + qemudReturnPort(driver, vm->def->graphics[0]->data.spice.port); + qemudReturnPort(driver, vm->def->graphics[0]->data.spice.tlsPort); } vm->pid = -1; -- 1.7.3.4 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list