From 14db53662af7a737e3f6b0edcaca87d8f94ec593 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Mon, 27 Aug 2012 13:13:36 +0200 Subject: [PATCH] set default qmp timout to 3 seconds And allow to pass timeout paramater to vm_qmp_command(). --- PVE/QMPClient.pm | 2 ++ PVE/QemuServer.pm | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/PVE/QMPClient.pm b/PVE/QMPClient.pm index 85d307e..cc975ab 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 c7e9a07..79231eb 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}}); -- 2.39.2