[pve-devel] [RFC common 1/2] partially fix #4501: next unused port: bump port reservation expiretime

Fiona Ebner f.ebner at proxmox.com
Tue Nov 14 15:02:03 CET 2023

For QEMU migration via TCP, there's a bit of time between port
reservation and usage, because currently, the port needs to be
reserved before invoking a fork, where the systemd scope needs to be
set up and swtpm might need to be started before the QEMU binary can
be invoked and actually use the port.

Not bumping too much, because mass migration with many small VMs might
need to re-use the ports rather quickly (there's only 50 ports).

The other two usages of the function are for VNC and SPICE, with
100 and 999 ports respectively. And for those, ports are usually used
for longer than 30 seconds anyways, so the higher expire time should
be fine.

Signed-off-by: Fiona Ebner <f.ebner at proxmox.com>
 src/PVE/Tools.pm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/PVE/Tools.pm b/src/PVE/Tools.pm
index b3af2c6..4d018e9 100644
--- a/src/PVE/Tools.pm
+++ b/src/PVE/Tools.pm
@@ -918,7 +918,7 @@ sub next_unused_port {
     my $code = sub {
-	my $expiretime = 5;
+	my $expiretime = 30;
 	my $ctime = time();
 	my $ports = {};

More information about the pve-devel mailing list