various CVE fixes
[pve-qemu-kvm.git] / debian / patches / pve / 0018-backup-do-not-return-errors-in-dump-callback.patch
blobeaff295c16145ed3e5cddcec65fe281229aae2e8
1 From 0db7b5b9c1799414788a43c3181c5b965d1b4be7 Mon Sep 17 00:00:00 2001
2 From: Wolfgang Bumiller <w.bumiller@proxmox.com>
3 Date: Wed, 9 Dec 2015 15:22:19 +0100
4 Subject: [PATCH 18/55] backup: do not return errors in dump callback
6 ---
7 blockdev.c | 26 ++++++++++++++++++++------
8 1 file changed, 20 insertions(+), 6 deletions(-)
10 diff --git a/blockdev.c b/blockdev.c
11 index 0537a53..157cc44 100644
12 --- a/blockdev.c
13 +++ b/blockdev.c
14 @@ -3026,6 +3026,11 @@ static int pvebackup_dump_cb(void *opaque, BlockDriverState *target,
16 PVEBackupDevInfo *di = opaque;
18 + int size = n_sectors * BDRV_SECTOR_SIZE;
19 + if (backup_state.cancel) {
20 + return size; // return success
21 + }
23 if (sector_num & 0x7f) {
24 if (!backup_state.error) {
25 error_setg(&backup_state.error,
26 @@ -3036,7 +3041,6 @@ static int pvebackup_dump_cb(void *opaque, BlockDriverState *target,
29 int64_t cluster_num = sector_num >> 7;
30 - int size = n_sectors * BDRV_SECTOR_SIZE;
32 int ret = -1;
34 @@ -3044,17 +3048,27 @@ static int pvebackup_dump_cb(void *opaque, BlockDriverState *target,
35 size_t zero_bytes = 0;
36 ret = vma_writer_write(backup_state.vmaw, di->dev_id, cluster_num,
37 buf, &zero_bytes);
38 - backup_state.zero_bytes += zero_bytes;
39 + if (ret < 0) {
40 + if (!backup_state.error) {
41 + error_setg(&backup_state.error, "vma_writer_write error %d", ret);
42 + }
43 + if (di->bs && di->bs->job) {
44 + block_job_cancel(di->bs->job);
45 + }
46 + } else {
47 + backup_state.zero_bytes += zero_bytes;
48 + backup_state.transferred += size;
49 + }
50 } else {
51 - ret = size;
52 if (!buf) {
53 backup_state.zero_bytes += size;
55 + backup_state.transferred += size;
58 - backup_state.transferred += size;
59 + // Note: always return success, because we want that writes succeed anyways.
61 - return ret;
62 + return size;
65 static void pvebackup_cleanup(void)
66 @@ -3126,7 +3140,7 @@ static void pvebackup_cancel(void *opaque)
67 BlockJob *job = di->bs->job;
68 if (job) {
69 if (!di->completed) {
70 - block_job_cancel_sync(job);
71 + block_job_cancel_sync(job);
75 --
76 2.1.4