5
0
mirror of git://git.proxmox.com/git/qemu-server.git synced 2025-01-10 01:18:01 +03:00

fix #2244: Allow timeout for guest-agent shutdown

The "guest-shutdown" guest agent call is blocking for some reason, so if
it fails (e.g. agent not installed on guest) only the default timeout of
10 minutes (see QMPClient.pm, sub cmd) would apply.

With this change, if (and only if) a timeout is specified via CLI/API,
it is used instead. In case it is not specified, behaviour stays the
same (default 10 min timeout).

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
This commit is contained in:
Stefan Reiter 2019-06-24 10:33:07 +02:00 committed by Thomas Lamprecht
parent 0d79b008bb
commit 0eb2169136

View File

@ -5646,12 +5646,13 @@ sub vm_stop {
PVE::GuestHelpers::exec_hookscript($conf, $vmid, 'pre-stop'); PVE::GuestHelpers::exec_hookscript($conf, $vmid, 'pre-stop');
} }
$timeout = 60 if !defined($timeout);
eval { eval {
if ($shutdown) { if ($shutdown) {
if (defined($conf) && parse_guest_agent($conf)->{enabled}) { if (defined($conf) && parse_guest_agent($conf)->{enabled}) {
vm_qmp_command($vmid, { execute => "guest-shutdown" }, $nocheck); vm_qmp_command($vmid, {
execute => "guest-shutdown",
arguments => { timeout => $timeout }
}, $nocheck);
} else { } else {
vm_qmp_command($vmid, { execute => "system_powerdown" }, $nocheck); vm_qmp_command($vmid, { execute => "system_powerdown" }, $nocheck);
} }
@ -5662,6 +5663,8 @@ sub vm_stop {
my $err = $@; my $err = $@;
if (!$err) { if (!$err) {
$timeout = 60 if !defined($timeout);
my $count = 0; my $count = 0;
while (($count < $timeout) && check_running($vmid, $nocheck)) { while (($count < $timeout) && check_running($vmid, $nocheck)) {
$count++; $count++;