From 800ceed2c17f5576c92e1d1755a693ece2b495a4 Mon Sep 17 00:00:00 2001 From: Fiona Ebner Date: Mon, 11 Nov 2024 14:54:31 +0100 Subject: [PATCH] backup: prepare: cancel previous job if still running This can happen after a hard failure, e.g. if the vzdump task was killed. The next backup (after unlocking the VM) would then fail with > ERROR: VM 125 qmp command 'backup' failed - previous backup not finished During the failure path of that attempt, 'backup-cancel' is executed and the subsequent attempt would then work again. Do it up-front with a warning instead of relying on this behavior. Signed-off-by: Fiona Ebner --- PVE/VZDump/QemuServer.pm | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/PVE/VZDump/QemuServer.pm b/PVE/VZDump/QemuServer.pm index 4c993b1c..ed742ed9 100644 --- a/PVE/VZDump/QemuServer.pm +++ b/PVE/VZDump/QemuServer.pm @@ -59,6 +59,13 @@ sub prepare { my $running = PVE::QemuServer::Helpers::vm_running_locally($vmid); + if ($running && (my $status = mon_cmd($vmid, 'query-backup'))) { + if ($status->{status} && $status->{status} eq 'active') { + $self->log('warn', "left-over backup job still running inside QEMU - canceling now"); + mon_cmd($vmid, 'backup-cancel'); + } + } + $task->{disks} = []; my $conf = $self->{vmlist}->{$vmid} = PVE::QemuConfig->load_config($vmid);