adding 2.5 pve patches and left-over extra fixes
[pve-qemu-kvm.git] / debian / patches / pve / 0018-backup-do-not-return-errors-in-dump-callback.patch
blob2f07955c6b9819e1cae7a1f7e8c536c7f10b39fe
1 From 9b6ccb4512735cf5455a473f99a946371a466a3d 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/41] 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 29a33c0..9bb354c 100644
12 --- a/blockdev.c
13 +++ b/blockdev.c
14 @@ -2912,6 +2912,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 @@ -2922,7 +2927,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 @@ -2930,17 +2934,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 @@ -3012,7 +3026,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