]> git.proxmox.com Git - qemu-server.git/commitdiff
fix command timeout
authorDietmar Maurer <dietmar@proxmox.com>
Fri, 13 Jul 2012 10:36:40 +0000 (12:36 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Fri, 13 Jul 2012 10:36:40 +0000 (12:36 +0200)
PVE/QMPClient.pm

index b4c79367c3c1abc3db1cb50b7c233902e71c84d9..85d307eaf9db613801726be59fc43827f66035b3 100755 (executable)
@@ -50,7 +50,7 @@ sub queue_cmd {
 
 # execute a single command
 sub cmd {
-    my ($self, $vmid, $cmd) = @_;
+    my ($self, $vmid, $cmd, $timeout) = @_;
 
     my $result;
 
@@ -59,12 +59,23 @@ sub cmd {
        $result = $resp->{'return'};
     };
 
+    die "no command specified" if !($cmd &&  $cmd->{execute});
+
     $cmd->{callback} = $callback;
     $cmd->{arguments} = {} if !defined($cmd->{arguments});
 
     $self->{queue}->{$vmid} = [ $cmd ];
 
-    $self->queue_execute();
+    if (!$timeout) {
+       # hack: monitor sometime blocks
+       if ($cmd->{execute} eq 'query-migrate') {
+           $timeout = 60*60; # 1 hour
+       } elsif ($cmd->{execute} =~ m/^(eject|change)/) {
+           $timeout = 60; # note: cdrom mount command is slow
+       }
+    }
+
+    $self->queue_execute($timeout);
 
     my $cmdstr = $cmd->{execute} || '';
     die "VM $vmid qmp command '$cmdstr' failed - $self->{errors}->{$vmid}"