From: Dylan Whyte <d.whyte@proxmox.com>
To: pbs-devel@lists.proxmox.com
Cc: dylan <dylan@pve.proxmox.com>
Subject: Re: [pbs-devel] [PATCH] fix #3369: auto-start vms after failed pbs backup
Date: Wed, 7 Apr 2021 16:10:24 +0200 [thread overview]
Message-ID: <6e3396eb-774a-c96d-227f-d78f16842261@proxmox.com> (raw)
In-Reply-To: <20210407140228.32382-1-d.whyte@proxmox.com>
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 <dylan@pve.proxmox.com>
>
> Fixes an issue in which a VM fails to automatically restart after a
> failed stop-mode backup to pbs.
>
> Signed-off-by: Dylan Whyte <d.whyte@proxmox.com>
> ---
>
> 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);
prev parent reply other threads:[~2021-04-07 14:10 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-07 14:02 Dylan Whyte
2021-04-07 14:10 ` Dylan Whyte [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6e3396eb-774a-c96d-227f-d78f16842261@proxmox.com \
--to=d.whyte@proxmox.com \
--cc=dylan@pve.proxmox.com \
--cc=pbs-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox