A failure during enforce_vm_running_for_backup() would result in
restore_vm_power_state() not being called, but the VM might already
have been started before the failure. In particular, this could happen
in the context of bug #6007 [0], where the 'set_link' QMP command
fails right after VM start.

If the failure happens before successful start, there will be an
additional error message issued by restore_vm_power_state() (that the
VM is not running). This could be avoided by returning early if the VM
is not running anymore, but that would mean not warning about it in
other scenarios where it is not expected and keeping track of whether
the VM was actually started or not does not seem to be worth it just
for avoiding that error message in this edge case.

[0]: https://bugzilla.proxmox.com/show_bug.cgi?id=6007

Signed-off-by: Fiona Ebner <f.eb...@proxmox.com>
---
 PVE/VZDump/QemuServer.pm | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/PVE/VZDump/QemuServer.pm b/PVE/VZDump/QemuServer.pm
index 44b68ae9..9d7c26a3 100644
--- a/PVE/VZDump/QemuServer.pm
+++ b/PVE/VZDump/QemuServer.pm
@@ -698,15 +698,15 @@ sub archive_pbs {
     # get list early so we die on unknown drive types before doing anything
     my $devlist = _get_task_devlist($task);
 
-    $self->enforce_vm_running_for_backup($vmid);
-    $self->{qmeventd_fh} = PVE::QemuServer::register_qmeventd_handle($vmid);
-
     my $backup_job_uuid;
     eval {
        $SIG{INT} = $SIG{TERM} = $SIG{QUIT} = $SIG{HUP} = $SIG{PIPE} = sub {
            die "interrupted by signal\n";
        };
 
+       $self->enforce_vm_running_for_backup($vmid);
+       $self->{qmeventd_fh} = PVE::QemuServer::register_qmeventd_handle($vmid);
+
        my $qemu_support = eval { mon_cmd($vmid, "query-proxmox-support") };
        my $err = $@;
        if (!$qemu_support || $err) {
@@ -893,9 +893,6 @@ sub archive_vma {
 
     my $devlist = _get_task_devlist($task);
 
-    $self->enforce_vm_running_for_backup($vmid);
-    $self->{qmeventd_fh} = PVE::QemuServer::register_qmeventd_handle($vmid);
-
     my $cpid;
     my $backup_job_uuid;
 
@@ -904,6 +901,9 @@ sub archive_vma {
            die "interrupted by signal\n";
        };
 
+       $self->enforce_vm_running_for_backup($vmid);
+       $self->{qmeventd_fh} = PVE::QemuServer::register_qmeventd_handle($vmid);
+
        # Currently, failing to determine Proxmox support is not critical here, 
because it's only
        # used for performance settings like 'max-workers'.
        my $qemu_support = eval { mon_cmd($vmid, "query-proxmox-support") };
-- 
2.39.5



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to