various CVE fixes
[pve-qemu-kvm.git] / debian / patches / pve / 0036-savevm-async-migration-and-bdrv_open-update.patch
blobdb2c4d825185e7fe9378fc0d4c3d983648444fc2
1 From 6517453d33b72863940749b1b4ee1b36b7acf24c Mon Sep 17 00:00:00 2001
2 From: Wolfgang Bumiller <w.bumiller@proxmox.com>
3 Date: Thu, 10 Dec 2015 15:14:00 +0100
4 Subject: [PATCH 36/55] savevm-async: migration and bdrv_open update
6 ---
7 savevm-async.c | 25 ++++++++++++-------------
8 1 file changed, 12 insertions(+), 13 deletions(-)
10 diff --git a/savevm-async.c b/savevm-async.c
11 index 8117443..bb4372c 100644
12 --- a/savevm-async.c
13 +++ b/savevm-async.c
14 @@ -150,10 +150,10 @@ static int block_state_close(void *opaque)
15 return bdrv_flush(snap_state.bs);
18 -static int block_state_put_buffer(void *opaque, const uint8_t *buf,
19 - int64_t pos, int size)
20 +static ssize_t block_state_put_buffer(void *opaque, const uint8_t *buf,
21 + int64_t pos, size_t size)
23 - int ret;
24 + ssize_t ret;
26 assert(pos == snap_state.bs_pos);
28 @@ -197,12 +197,13 @@ static void process_savevm_co(void *opaque)
31 while (snap_state.state == SAVE_STATE_ACTIVE) {
32 - uint64_t pending_size;
33 + uint64_t pending_size, pend_post, pend_nonpost;
35 - pending_size = qemu_savevm_state_pending(snap_state.file, 0);
36 + qemu_savevm_state_pending(snap_state.file, 0, &pend_nonpost, &pend_post);
37 + pending_size = pend_post + pend_nonpost;
39 if (pending_size) {
40 - ret = qemu_savevm_state_iterate(snap_state.file);
41 + ret = qemu_savevm_state_iterate(snap_state.file, false);
42 if (ret < 0) {
43 save_snapshot_error("qemu_savevm_state_iterate error %d", ret);
44 break;
45 @@ -213,7 +214,7 @@ static void process_savevm_co(void *opaque)
46 if (store_and_stop())
47 break;
48 DPRINTF("savevm inerate finished\n");
49 - qemu_savevm_state_complete_precopy(snap_state.file);
50 + qemu_savevm_state_complete_precopy(snap_state.file, false);
51 DPRINTF("save complete\n");
52 save_snapshot_completed();
53 break;
54 @@ -246,7 +247,6 @@ static const QEMUFileOps block_file_ops = {
56 void qmp_savevm_start(bool has_statefile, const char *statefile, Error **errp)
58 - BlockDriver *drv = NULL;
59 Error *local_err = NULL;
61 int bdrv_oflags = BDRV_O_CACHE_WB | BDRV_O_RDWR;
62 @@ -285,7 +285,7 @@ void qmp_savevm_start(bool has_statefile, const char *statefile, Error **errp)
63 QDict *options = NULL;
64 options = qdict_new();
65 qdict_put(options, "driver", qstring_from_str("raw"));
66 - ret = bdrv_open(&snap_state.bs, statefile, NULL, options, bdrv_oflags, drv, &local_err);
67 + ret = bdrv_open(&snap_state.bs, statefile, NULL, options, bdrv_oflags, &local_err);
68 if (ret < 0) {
69 error_set(errp, ERROR_CLASS_GENERIC_ERROR, "failed to open '%s'", statefile);
70 goto restart;
71 @@ -450,8 +450,8 @@ void qmp_delete_drive_snapshot(const char *device, const char *name,
75 -static int loadstate_get_buffer(void *opaque, uint8_t *buf, int64_t pos,
76 - int size)
77 +static ssize_t loadstate_get_buffer(void *opaque, uint8_t *buf, int64_t pos,
78 + size_t size)
80 BlockDriverState *bs = (BlockDriverState *)opaque;
81 int64_t maxlen = bdrv_getlength(bs);
82 @@ -474,7 +474,6 @@ static const QEMUFileOps loadstate_file_ops = {
83 int load_state_from_blockdev(const char *filename)
85 BlockDriverState *bs = NULL;
86 - BlockDriver *drv = NULL;
87 Error *local_err = NULL;
88 Error *blocker = NULL;
90 @@ -482,7 +481,7 @@ int load_state_from_blockdev(const char *filename)
91 int ret;
93 bs = bdrv_new();
94 - ret = bdrv_open(&bs, filename, NULL, NULL, BDRV_O_CACHE_WB, drv, &local_err);
95 + ret = bdrv_open(&bs, filename, NULL, NULL, BDRV_O_CACHE_WB, &local_err);
96 error_setg(&blocker, "block device is in use by load state");
97 bdrv_op_block_all(bs, blocker);
99 --
100 2.1.4