[pve-devel] applied: [PATCH qemu-server] fix #2244: Allow timeout for guest-agent shutdown

Thomas Lamprecht t.lamprecht at proxmox.com
Mon Jun 24 17:22:03 CEST 2019


On 6/24/19 10:33 AM, Stefan Reiter wrote:
> 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 at proxmox.com>
> ---
> 
> BTW, I did check "system_powerdown" and "quit", both are not blocking,
> so no changes needed there.
> 
>  PVE/QemuServer.pm | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
> index e8e1909..ed11609 100644
> --- a/PVE/QemuServer.pm
> +++ b/PVE/QemuServer.pm
> @@ -5646,12 +5646,13 @@ sub vm_stop {
>  	    PVE::GuestHelpers::exec_hookscript($conf, $vmid, 'pre-stop');
>  	}
>  
> -	$timeout = 60 if !defined($timeout);
> -
>  	eval {
>  	    if ($shutdown) {
>  		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 {
>  		    vm_qmp_command($vmid, { execute => "system_powerdown" }, $nocheck);
>  		}
> @@ -5662,6 +5663,8 @@ sub vm_stop {
>  	my $err = $@;
>  
>  	if (!$err) {
> +	    $timeout = 60 if !defined($timeout);
> +
>  	    my $count = 0;
>  	    while (($count < $timeout) && check_running($vmid, $nocheck)) {
>  		$count++;
> 

applied, thanks!




More information about the pve-devel mailing list