]> git.proxmox.com Git - pve-qemu-kvm.git/blob - debian/patches/backup-modify-job-api.patch
re-add pve backup monitor commands
[pve-qemu-kvm.git] / debian / patches / backup-modify-job-api.patch
1 Index: new/block/backup.c
2 ===================================================================
3 --- new.orig/block/backup.c 2013-11-27 10:51:32.000000000 +0100
4 +++ new/block/backup.c 2013-12-02 07:41:30.000000000 +0100
5 @@ -39,6 +39,7 @@
6 BlockDriverState *target;
7 MirrorSyncMode sync_mode;
8 RateLimit limit;
9 + BackupDumpFunc *dump_cb;
10 BlockdevOnError on_source_error;
11 BlockdevOnError on_target_error;
12 CoRwlock flush_rwlock;
13 @@ -137,12 +138,20 @@
14 }
15
16 if (buffer_is_zero(iov.iov_base, iov.iov_len)) {
17 - ret = bdrv_co_write_zeroes(job->target,
18 - start * BACKUP_SECTORS_PER_CLUSTER, n);
19 + if (job->dump_cb) {
20 + ret = job->dump_cb(job->common.opaque, bs, start, NULL);
21 + } else {
22 + ret = bdrv_co_write_zeroes(job->target,
23 + start * BACKUP_SECTORS_PER_CLUSTER, n);
24 + }
25 } else {
26 - ret = bdrv_co_writev(job->target,
27 - start * BACKUP_SECTORS_PER_CLUSTER, n,
28 - &bounce_qiov);
29 + if (job->dump_cb) {
30 + ret = job->dump_cb(job->common.opaque, bs, start, bounce_buffer);
31 + } else {
32 + ret = bdrv_co_writev(job->target,
33 + start * BACKUP_SECTORS_PER_CLUSTER, n,
34 + &bounce_qiov);
35 + }
36 }
37 if (ret < 0) {
38 trace_backup_do_cow_write_fail(job, start, ret);
39 @@ -199,7 +208,9 @@
40 {
41 BackupBlockJob *s = container_of(job, BackupBlockJob, common);
42
43 - bdrv_iostatus_reset(s->target);
44 + if (s->target) {
45 + bdrv_iostatus_reset(s->target);
46 + }
47 }
48
49 static const BlockJobDriver backup_job_driver = {
50 @@ -215,9 +226,11 @@
51 if (read) {
52 return block_job_error_action(&job->common, job->common.bs,
53 job->on_source_error, true, error);
54 - } else {
55 + } else if (job->target) {
56 return block_job_error_action(&job->common, job->target,
57 job->on_target_error, false, error);
58 + } else {
59 + return BDRV_ACTION_REPORT;
60 }
61 }
62
63 @@ -242,9 +255,11 @@
64
65 job->bitmap = hbitmap_alloc(end, 0);
66
67 - bdrv_set_enable_write_cache(target, true);
68 - bdrv_set_on_error(target, on_target_error, on_target_error);
69 - bdrv_iostatus_enable(target);
70 + if (target) {
71 + bdrv_set_enable_write_cache(target, true);
72 + bdrv_set_on_error(target, on_target_error, on_target_error);
73 + bdrv_iostatus_enable(target);
74 + }
75
76 bdrv_add_before_write_notifier(bs, &before_write);
77
78 @@ -337,8 +352,10 @@
79
80 hbitmap_free(job->bitmap);
81
82 - bdrv_iostatus_disable(target);
83 - bdrv_unref(target);
84 + if (target) {
85 + bdrv_iostatus_disable(target);
86 + bdrv_unref(target);
87 + }
88
89 block_job_completed(&job->common, ret);
90 }
91 @@ -347,13 +364,14 @@
92 int64_t speed, MirrorSyncMode sync_mode,
93 BlockdevOnError on_source_error,
94 BlockdevOnError on_target_error,
95 + BackupDumpFunc *dump_cb,
96 BlockDriverCompletionFunc *cb, void *opaque,
97 Error **errp)
98 {
99 int64_t len;
100
101 assert(bs);
102 - assert(target);
103 + assert(target || dump_cb);
104 assert(cb);
105
106 if ((on_source_error == BLOCKDEV_ON_ERROR_STOP ||
107 @@ -376,6 +394,7 @@
108 return;
109 }
110
111 + job->dump_cb = dump_cb;
112 job->on_source_error = on_source_error;
113 job->on_target_error = on_target_error;
114 job->target = target;
115 Index: new/blockdev.c
116 ===================================================================
117 --- new.orig/blockdev.c 2013-12-02 06:12:24.000000000 +0100
118 +++ new/blockdev.c 2013-12-02 08:43:25.000000000 +0100
119 @@ -1932,7 +1932,7 @@
120 }
121
122 backup_start(bs, target_bs, speed, sync, on_source_error, on_target_error,
123 - block_job_cb, bs, &local_err);
124 + NULL, block_job_cb, bs, &local_err);
125 if (local_err != NULL) {
126 bdrv_unref(target_bs);
127 error_propagate(errp, local_err);
128 Index: new/include/block/block_int.h
129 ===================================================================
130 --- new.orig/include/block/block_int.h 2013-11-27 10:51:33.000000000 +0100
131 +++ new/include/block/block_int.h 2013-12-02 07:40:35.000000000 +0100
132 @@ -54,6 +54,9 @@
133 #define BLOCK_OPT_LAZY_REFCOUNTS "lazy_refcounts"
134 #define BLOCK_OPT_ADAPTER_TYPE "adapter_type"
135
136 +typedef int BackupDumpFunc(void *opaque, BlockDriverState *bs,
137 + int64_t cluster_num, unsigned char *buf);
138 +
139 typedef struct BdrvTrackedRequest {
140 BlockDriverState *bs;
141 int64_t sector_num;
142 @@ -427,6 +430,7 @@
143 int64_t speed, MirrorSyncMode sync_mode,
144 BlockdevOnError on_source_error,
145 BlockdevOnError on_target_error,
146 + BackupDumpFunc *dump_cb,
147 BlockDriverCompletionFunc *cb, void *opaque,
148 Error **errp);
149