diff --git a/PVE/QMPClient.pm b/PVE/QMPClient.pm index 85d307ea..cc975abe 100755 --- a/PVE/QMPClient.pm +++ b/PVE/QMPClient.pm @@ -72,6 +72,8 @@ sub cmd { $timeout = 60*60; # 1 hour } elsif ($cmd->{execute} =~ m/^(eject|change)/) { $timeout = 60; # note: cdrom mount command is slow + } else { + $timeout = 3; # default } } diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm index c7e9a07e..79231ebe 100644 --- a/PVE/QemuServer.pm +++ b/PVE/QemuServer.pm @@ -2808,13 +2808,19 @@ sub vm_qmp_command { my $res; + my $timeout; + if ($cmd->{arguments} && $cmd->{arguments}->{timeout}) { + $timeout = $cmd->{arguments}->{timeout}; + delete $cmd->{arguments}->{timeout}; + } + eval { die "VM $vmid not running\n" if !check_running($vmid, $nocheck); my $sname = PVE::QemuServer::qmp_socket($vmid); if (-e $sname) { my $qmpclient = PVE::QMPClient->new(); - $res = $qmpclient->cmd($vmid, $cmd); + $res = $qmpclient->cmd($vmid, $cmd, $timeout); } elsif (-e "${var_run_tmpdir}/$vmid.mon") { die "can't execute complex command on old monitor - stop/start your vm to fix the problem\n" if scalar(%{$cmd->{arguments}});