X-Git-Url: https://git.proxmox.com/?p=qemu-server.git;a=blobdiff_plain;f=PVE%2FQMPClient.pm;h=9829986ae77e82d340974e4d4128741ef85b4a0e;hp=d026f4d4c3012203d96660a311b1890e84e6aa18;hb=6d04217600f2145ee80d5d62231b8ade34f2e5ff;hpb=037a97463447b06ebf79a7f1d40c596d9955acee diff --git a/PVE/QMPClient.pm b/PVE/QMPClient.pm index d026f4d..9829986 100755 --- a/PVE/QMPClient.pm +++ b/PVE/QMPClient.pm @@ -114,10 +114,12 @@ my $close_connection = sub { }; my $open_connection = sub { - my ($self, $vmid) = @_; + my ($self, $vmid, $timeout) = @_; my $sname = PVE::QemuServer::qmp_socket($vmid); + $timeout = 1 if !$timeout; + my $fh; my $starttime = [gettimeofday]; my $count = 0; @@ -129,7 +131,7 @@ my $open_connection = sub { die "unable to connect to VM $vmid socket - $!\n"; } my $elapsed = tv_interval($starttime, [gettimeofday]); - if ($elapsed > 1) { + if ($elapsed >= $timeout) { die "unable to connect to VM $vmid socket - timeout after $count retries\n"; } usleep(100000); @@ -204,7 +206,7 @@ sub queue_execute { next if !scalar(@{$self->{queue}->{$vmid}}); # no commands for the VM eval { - my $fh = &$open_connection($self, $vmid); + my $fh = &$open_connection($self, $vmid, $timeout); my $cmd = { execute => 'qmp_capabilities', arguments => {} }; unshift @{$self->{queue}->{$vmid}}, $cmd; $self->{mux}->set_timeout($fh, $timeout);