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 <f.ebner@proxmox.com>
This commit is contained in:
Fiona Ebner 2024-11-11 14:54:31 +01:00 committed by Thomas Lamprecht
parent 67d9ef4c5d
commit 800ceed2c1

View File

@ -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);