]> git.proxmox.com Git - pve-qemu.git/blame - debian/patches/pve/0057-PVE-Backup-create-jobs-correctly-cancel-in-error-sce.patch
update submodule and patches to 7.1.0
[pve-qemu.git] / debian / patches / pve / 0057-PVE-Backup-create-jobs-correctly-cancel-in-error-sce.patch
CommitLineData
7f4326d1
WB
1From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2From: Fabian Ebner <f.ebner@proxmox.com>
3Date: Wed, 25 May 2022 13:59:37 +0200
4Subject: [PATCH] PVE-Backup: create jobs: correctly cancel in error scenario
5
6The first call to job_cancel_sync() will cancel and free all jobs in
7the transaction, so ensure that it's called only once and get rid of
8the job_unref() that would operate on freed memory.
9
10It's also necessary to NULL backup_state.pbs in the error scenario,
11because a subsequent backup_cancel QMP call (as happens in PVE when
12the backup QMP command fails) would try to call proxmox_backup_abort()
13and run into a segfault.
14
15Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
16Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
17---
18 pve-backup.c | 10 ++++++++--
19 1 file changed, 8 insertions(+), 2 deletions(-)
20
21diff --git a/pve-backup.c b/pve-backup.c
22index f6a5f8c785..5bed6f4014 100644
23--- a/pve-backup.c
24+++ b/pve-backup.c
25@@ -506,6 +506,11 @@ static void create_backup_jobs_bh(void *opaque) {
26 }
27
28 if (*errp) {
29+ /*
30+ * It's enough to cancel one job in the transaction, the rest will
31+ * follow automatically.
32+ */
33+ bool canceled = false;
34 l = backup_state.di_list;
35 while (l) {
36 PVEBackupDevInfo *di = (PVEBackupDevInfo *)l->data;
37@@ -516,12 +521,12 @@ static void create_backup_jobs_bh(void *opaque) {
38 di->target = NULL;
39 }
40
41- if (di->job) {
42+ if (!canceled && di->job) {
43 AioContext *ctx = di->job->job.aio_context;
44 aio_context_acquire(ctx);
45 job_cancel_sync(&di->job->job, true);
46- job_unref(&di->job->job);
47 aio_context_release(ctx);
48+ canceled = true;
49 }
50 }
51 }
52@@ -947,6 +952,7 @@ err:
53
54 if (pbs) {
55 proxmox_backup_disconnect(pbs);
56+ backup_state.pbs = NULL;
57 }
58
59 if (backup_dir) {