From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id C471D71260 for ; Wed, 7 Apr 2021 16:10:27 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id BD6CB1156E for ; Wed, 7 Apr 2021 16:10:27 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [212.186.127.180]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id C92DA11551 for ; Wed, 7 Apr 2021 16:10:25 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 8DB434592C; Wed, 7 Apr 2021 16:10:25 +0200 (CEST) From: Dylan Whyte To: pbs-devel@lists.proxmox.com Cc: dylan Reply-To: Proxmox Backup Server development discussion References: <20210407140228.32382-1-d.whyte@proxmox.com> Message-ID: <6e3396eb-774a-c96d-227f-d78f16842261@proxmox.com> Date: Wed, 7 Apr 2021 16:10:24 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.9.0 MIME-Version: 1.0 In-Reply-To: <20210407140228.32382-1-d.whyte@proxmox.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-SPAM-LEVEL: Spam detection results: 0 AWL 0.015 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment NICE_REPLY_A -0.001 Looks like a legit reply (A) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [vzdump.pm] Subject: Re: [pbs-devel] [PATCH] fix #3369: auto-start vms after failed pbs backup X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Apr 2021 14:10:27 -0000 Please disregard this. It was sent in error to the wrong list. I will send an update to pve-devel shortly. Kind regards, Dylan On 4/7/21 4:02 PM, Dylan Whyte wrote: > From: dylan > > Fixes an issue in which a VM fails to automatically restart after a > failed stop-mode backup to pbs. > > Signed-off-by: Dylan Whyte > --- > > Notes: > 1. The 1sec time delay was needed, as the check to see if the VM is running > was still true while this code was executed (although the vm was just > about to stop) > > 2. The previously used vm_status call just checks if a PID exists and > returns true if so. This also returns true when the VM is in "prelauch" > state, hence PVE::QemuServer::vmstatus was used to see the exact state > and handle the situation accordingly. Otherwise, the VM gets stuck in > prelauch state from time to time. > > > PVE/VZDump.pm | 14 +++++++++++--- > 1 file changed, 11 insertions(+), 3 deletions(-) > > diff --git a/PVE/VZDump.pm b/PVE/VZDump.pm > index fb4c8bad..1bda1f15 100644 > --- a/PVE/VZDump.pm > +++ b/PVE/VZDump.pm > @@ -23,6 +23,7 @@ use PVE::VZDump::Common; > use PVE::VZDump::Plugin; > use PVE::Tools qw(extract_param split_list); > use PVE::API2Tools; > +use PVE::QemuServer; > > my @posix_filesystems = qw(ext3 ext4 nfs nfs4 reiserfs xfs); > > @@ -1039,10 +1040,17 @@ sub exec_backup_task { > debugmsg ('info', "resume vm", $logfd); > $plugin->resume_vm ($task, $vmid); > } else { > - my $running = $plugin->vm_status($vmid); > - if (!$running) { > + sleep(1); > + my $vmstatus = PVE::QemuServer::vmstatus($vmid, 1); > + my $stat = $vmstatus->{$vmid}; > + my $status = $stat->{qmpstatus}; > + > + if ($status eq "stopped") { > + $plugin->start_vm ($task, $vmid); > + debugmsg ('info', "restarting vm", $logfd); > + } elsif ($status eq "prelaunch") { > + $plugin->resume_vm ($task, $vmid); > debugmsg ('info', "restarting vm", $logfd); > - $plugin->start_vm ($task, $vmid); > } > } > $self->run_hook_script ('post-restart', $task, $logfd);