X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=src%2FPVE%2FTools.pm;h=6d579d8f9cd1234cecafd986e60cf9eaec7a6c5b;hb=590b924e19426c93e0c7f4b969ff80eed66ab29e;hp=2c64f6ac33206791a5e70b038b49b76fa71b13dd;hpb=8fd0d63460153d1aeb2933a71ffdd18a8448d960;p=pve-common.git diff --git a/src/PVE/Tools.pm b/src/PVE/Tools.pm index 2c64f6a..6d579d8 100644 --- a/src/PVE/Tools.pm +++ b/src/PVE/Tools.pm @@ -791,17 +791,20 @@ sub extract_param { # Note: we use this to wait until vncterm/spiceterm is ready sub wait_for_vnc_port { - my ($port, $timeout) = @_; + my ($port, $family, $timeout) = @_; $timeout = 5 if !$timeout; my $sleeptime = 0; my $starttime = [gettimeofday]; my $elapsed; + my $cmd = ['/bin/ss', '-Htln', "sport = :$port"]; + push @$cmd, $family == AF_INET6 ? '-6' : '-4' if defined($family); + my $found; while (($elapsed = tv_interval($starttime)) < $timeout) { # -Htln = don't print header, tcp, listening sockets only, numeric ports - run_command(['/bin/ss', '-Htln', "sport = :$port"], outfunc => sub { + run_command($cmd, outfunc => sub { my $line = shift; if ($line =~ m/^LISTEN\s+\d+\s+\d+\s+\S+:(\d+)\s/) { $found = 1 if ($port == $1);