]>
Commit | Line | Data |
---|---|---|
7f4326d1 WB |
1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 |
2 | From: Fabian Ebner <f.ebner@proxmox.com> | |
3 | Date: Wed, 25 May 2022 13:59:37 +0200 | |
4 | Subject: [PATCH] PVE-Backup: create jobs: correctly cancel in error scenario | |
5 | ||
6 | The first call to job_cancel_sync() will cancel and free all jobs in | |
7 | the transaction, so ensure that it's called only once and get rid of | |
8 | the job_unref() that would operate on freed memory. | |
9 | ||
10 | It's also necessary to NULL backup_state.pbs in the error scenario, | |
11 | because a subsequent backup_cancel QMP call (as happens in PVE when | |
12 | the backup QMP command fails) would try to call proxmox_backup_abort() | |
13 | and run into a segfault. | |
14 | ||
15 | Signed-off-by: Fabian Ebner <f.ebner@proxmox.com> | |
16 | Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com> | |
17 | --- | |
18 | pve-backup.c | 10 ++++++++-- | |
19 | 1 file changed, 8 insertions(+), 2 deletions(-) | |
20 | ||
21 | diff --git a/pve-backup.c b/pve-backup.c | |
22 | index 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) { |