set default qmp timout to 3 seconds

And allow to pass timeout paramater to vm_qmp_command().
This commit is contained in:
Dietmar Maurer 2012-08-27 13:13:36 +02:00
parent eb26097ef4
commit 14db53662a
2 changed files with 9 additions and 1 deletions

View File

@ -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
}
}

View File

@ -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}});