From: Dietmar Maurer Date: Tue, 25 Sep 2012 07:27:24 +0000 (+0200) Subject: pass timeout to qmp open_connection X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=6d04217600f2145ee80d5d62231b8ade34f2e5ff;p=qemu-server.git pass timeout to qmp open_connection --- 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);