]> git.proxmox.com Git - qemu-server.git/blobdiff - PVE/QMPClient.pm
pass timeout to qmp open_connection
[qemu-server.git] / PVE / QMPClient.pm
index f8b0dc637bbca938a612b569e400573806fd5f26..9829986ae77e82d340974e4d4128741ef85b4a0e 100755 (executable)
@@ -75,6 +75,12 @@ sub cmd {
            $timeout = 60*60; # 1 hour
        } elsif ($cmd->{execute} =~ m/^(eject|change)/) {
            $timeout = 60; # note: cdrom mount command is slow
+       } elsif ($cmd->{execute} eq 'savevm-start' ||
+                $cmd->{execute} eq 'savevm-end' ||
+                $cmd->{execute} eq 'query-savevm' ||
+                $cmd->{execute} eq 'delete-drive-snapshot' ||
+                $cmd->{execute} eq 'snapshot-drive'  ) {
+           $timeout = 10*60; # 10 mins ?
        } else {
            $timeout = 3; # default
        }
@@ -108,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;
@@ -123,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);
@@ -198,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);