blob: d62a8b80bac428bb9a13780991db3f4196fda435 [file] [log] [blame]
lirans@il.ibm.comc163b5c2009-11-02 15:40:58 +02001/*
2 * QEMU live block migration
3 *
4 * Copyright IBM, Corp. 2009
5 *
6 * Authors:
7 * Liran Schour <lirans@il.ibm.com>
8 *
9 * This work is licensed under the terms of the GNU GPL, version 2. See
10 * the COPYING file in the top-level directory.
11 *
Paolo Bonzini6b620ca2012-01-13 17:44:23 +010012 * Contributions after 2012-01-13 are licensed under the terms of the
13 * GNU GPL, version 2 or (at your option) any later version.
lirans@il.ibm.comc163b5c2009-11-02 15:40:58 +020014 */
15
16#include "qemu-common.h"
Paolo Bonzini737e1502012-12-17 18:19:44 +010017#include "block/block_int.h"
lirans@il.ibm.comc163b5c2009-11-02 15:40:58 +020018#include "hw/hw.h"
Paolo Bonzini1de7afc2012-12-17 18:20:00 +010019#include "qemu/queue.h"
20#include "qemu/timer.h"
Paolo Bonzinicaf71f82012-12-17 18:19:50 +010021#include "migration/block.h"
22#include "migration/migration.h"
Paolo Bonzini9c17d612012-12-17 18:20:04 +010023#include "sysemu/blockdev.h"
lirans@il.ibm.comc163b5c2009-11-02 15:40:58 +020024#include <assert.h>
lirans@il.ibm.comc163b5c2009-11-02 15:40:58 +020025
Paolo Bonzini50717e92013-01-21 17:09:45 +010026#define BLOCK_SIZE (1 << 20)
27#define BDRV_SECTORS_PER_DIRTY_CHUNK (BLOCK_SIZE >> BDRV_SECTOR_BITS)
lirans@il.ibm.comc163b5c2009-11-02 15:40:58 +020028
29#define BLK_MIG_FLAG_DEVICE_BLOCK 0x01
30#define BLK_MIG_FLAG_EOS 0x02
Jan Kiszka01e61e22009-12-01 15:20:17 +010031#define BLK_MIG_FLAG_PROGRESS 0x04
lirans@il.ibm.comc163b5c2009-11-02 15:40:58 +020032
33#define MAX_IS_ALLOCATED_SEARCH 65536
lirans@il.ibm.comc163b5c2009-11-02 15:40:58 +020034
35//#define DEBUG_BLK_MIGRATION
36
37#ifdef DEBUG_BLK_MIGRATION
malcd0f2c4c2010-02-07 02:03:50 +030038#define DPRINTF(fmt, ...) \
lirans@il.ibm.comc163b5c2009-11-02 15:40:58 +020039 do { printf("blk_migration: " fmt, ## __VA_ARGS__); } while (0)
40#else
malcd0f2c4c2010-02-07 02:03:50 +030041#define DPRINTF(fmt, ...) \
lirans@il.ibm.comc163b5c2009-11-02 15:40:58 +020042 do { } while (0)
43#endif
44
Jan Kiszkaa55eb922009-11-30 18:21:19 +010045typedef struct BlkMigDevState {
Paolo Bonzini323920c2013-02-22 17:36:24 +010046 /* Written during setup phase. Can be read without a lock. */
Jan Kiszkaa55eb922009-11-30 18:21:19 +010047 BlockDriverState *bs;
Jan Kiszkaa55eb922009-11-30 18:21:19 +010048 int shared_base;
Jan Kiszkaa55eb922009-11-30 18:21:19 +010049 int64_t total_sectors;
Jan Kiszka5e5328b2009-11-30 18:21:20 +010050 QSIMPLEQ_ENTRY(BlkMigDevState) entry;
Paolo Bonzini323920c2013-02-22 17:36:24 +010051
52 /* Only used by migration thread. Does not need a lock. */
53 int bulk_completed;
54 int64_t cur_sector;
55 int64_t cur_dirty;
56
57 /* Protected by iothread lock. */
Marcelo Tosatti33656af2010-11-08 17:02:56 -020058 unsigned long *aio_bitmap;
Paolo Bonzini323920c2013-02-22 17:36:24 +010059 int64_t completed_sectors;
Jan Kiszkaa55eb922009-11-30 18:21:19 +010060} BlkMigDevState;
61
lirans@il.ibm.comc163b5c2009-11-02 15:40:58 +020062typedef struct BlkMigBlock {
Paolo Bonzini323920c2013-02-22 17:36:24 +010063 /* Only used by migration thread. */
lirans@il.ibm.comc163b5c2009-11-02 15:40:58 +020064 uint8_t *buf;
65 BlkMigDevState *bmds;
66 int64_t sector;
Marcelo Tosatti33656af2010-11-08 17:02:56 -020067 int nr_sectors;
lirans@il.ibm.comc163b5c2009-11-02 15:40:58 +020068 struct iovec iov;
69 QEMUIOVector qiov;
70 BlockDriverAIOCB *aiocb;
Paolo Bonzini323920c2013-02-22 17:36:24 +010071
72 /* Protected by iothread lock. */
lirans@il.ibm.comc163b5c2009-11-02 15:40:58 +020073 int ret;
Jan Kiszka5e5328b2009-11-30 18:21:20 +010074 QSIMPLEQ_ENTRY(BlkMigBlock) entry;
lirans@il.ibm.comc163b5c2009-11-02 15:40:58 +020075} BlkMigBlock;
76
77typedef struct BlkMigState {
Paolo Bonzini323920c2013-02-22 17:36:24 +010078 /* Written during setup phase. Can be read without a lock. */
lirans@il.ibm.comc163b5c2009-11-02 15:40:58 +020079 int blk_enable;
80 int shared_base;
Jan Kiszka5e5328b2009-11-30 18:21:20 +010081 QSIMPLEQ_HEAD(bmds_list, BlkMigDevState) bmds_list;
Paolo Bonzini323920c2013-02-22 17:36:24 +010082 int64_t total_sector_sum;
83
84 /* Protected by iothread lock. */
Jan Kiszka5e5328b2009-11-30 18:21:20 +010085 QSIMPLEQ_HEAD(blk_list, BlkMigBlock) blk_list;
lirans@il.ibm.comc163b5c2009-11-02 15:40:58 +020086 int submitted;
87 int read_done;
Paolo Bonzini323920c2013-02-22 17:36:24 +010088
89 /* Only used by migration thread. Does not need a lock. */
lirans@il.ibm.comc163b5c2009-11-02 15:40:58 +020090 int transferred;
Jan Kiszka01e61e22009-12-01 15:20:17 +010091 int prev_progress;
Liran Schoure970ec02010-01-26 10:31:45 +020092 int bulk_completed;
lirans@il.ibm.comc163b5c2009-11-02 15:40:58 +020093} BlkMigState;
94
Jan Kiszkad11ecd32009-11-30 18:21:20 +010095static BlkMigState block_mig_state;
lirans@il.ibm.comc163b5c2009-11-02 15:40:58 +020096
Jan Kiszka13f0b672009-11-30 18:21:21 +010097static void blk_send(QEMUFile *f, BlkMigBlock * blk)
98{
99 int len;
100
101 /* sector number and flags */
102 qemu_put_be64(f, (blk->sector << BDRV_SECTOR_BITS)
103 | BLK_MIG_FLAG_DEVICE_BLOCK);
104
105 /* device name */
106 len = strlen(blk->bmds->bs->device_name);
107 qemu_put_byte(f, len);
108 qemu_put_buffer(f, (uint8_t *)blk->bmds->bs->device_name, len);
109
110 qemu_put_buffer(f, blk->buf, BLOCK_SIZE);
111}
112
Jan Kiszka25f23642009-11-30 18:21:21 +0100113int blk_mig_active(void)
114{
115 return !QSIMPLEQ_EMPTY(&block_mig_state.bmds_list);
116}
117
118uint64_t blk_mig_bytes_transferred(void)
119{
120 BlkMigDevState *bmds;
121 uint64_t sum = 0;
122
123 QSIMPLEQ_FOREACH(bmds, &block_mig_state.bmds_list, entry) {
124 sum += bmds->completed_sectors;
125 }
126 return sum << BDRV_SECTOR_BITS;
127}
128
129uint64_t blk_mig_bytes_remaining(void)
130{
131 return blk_mig_bytes_total() - blk_mig_bytes_transferred();
132}
133
134uint64_t blk_mig_bytes_total(void)
135{
136 BlkMigDevState *bmds;
137 uint64_t sum = 0;
138
139 QSIMPLEQ_FOREACH(bmds, &block_mig_state.bmds_list, entry) {
140 sum += bmds->total_sectors;
141 }
142 return sum << BDRV_SECTOR_BITS;
143}
144
Marcelo Tosatti33656af2010-11-08 17:02:56 -0200145static int bmds_aio_inflight(BlkMigDevState *bmds, int64_t sector)
146{
147 int64_t chunk = sector / (int64_t)BDRV_SECTORS_PER_DIRTY_CHUNK;
148
Marcelo Tosatti62155e22010-11-12 16:07:50 -0200149 if ((sector << BDRV_SECTOR_BITS) < bdrv_getlength(bmds->bs)) {
Marcelo Tosatti33656af2010-11-08 17:02:56 -0200150 return !!(bmds->aio_bitmap[chunk / (sizeof(unsigned long) * 8)] &
151 (1UL << (chunk % (sizeof(unsigned long) * 8))));
152 } else {
153 return 0;
154 }
155}
156
157static void bmds_set_aio_inflight(BlkMigDevState *bmds, int64_t sector_num,
158 int nb_sectors, int set)
159{
160 int64_t start, end;
161 unsigned long val, idx, bit;
162
163 start = sector_num / BDRV_SECTORS_PER_DIRTY_CHUNK;
164 end = (sector_num + nb_sectors - 1) / BDRV_SECTORS_PER_DIRTY_CHUNK;
165
166 for (; start <= end; start++) {
167 idx = start / (sizeof(unsigned long) * 8);
168 bit = start % (sizeof(unsigned long) * 8);
169 val = bmds->aio_bitmap[idx];
170 if (set) {
Marcelo Tosatti62155e22010-11-12 16:07:50 -0200171 val |= 1UL << bit;
Marcelo Tosatti33656af2010-11-08 17:02:56 -0200172 } else {
Marcelo Tosatti62155e22010-11-12 16:07:50 -0200173 val &= ~(1UL << bit);
Marcelo Tosatti33656af2010-11-08 17:02:56 -0200174 }
175 bmds->aio_bitmap[idx] = val;
176 }
177}
178
179static void alloc_aio_bitmap(BlkMigDevState *bmds)
180{
181 BlockDriverState *bs = bmds->bs;
182 int64_t bitmap_size;
183
184 bitmap_size = (bdrv_getlength(bs) >> BDRV_SECTOR_BITS) +
185 BDRV_SECTORS_PER_DIRTY_CHUNK * 8 - 1;
186 bitmap_size /= BDRV_SECTORS_PER_DIRTY_CHUNK * 8;
187
Anthony Liguori7267c092011-08-20 22:09:37 -0500188 bmds->aio_bitmap = g_malloc0(bitmap_size);
Marcelo Tosatti33656af2010-11-08 17:02:56 -0200189}
190
lirans@il.ibm.comc163b5c2009-11-02 15:40:58 +0200191static void blk_mig_read_cb(void *opaque, int ret)
192{
193 BlkMigBlock *blk = opaque;
Jan Kiszkaa55eb922009-11-30 18:21:19 +0100194
lirans@il.ibm.comc163b5c2009-11-02 15:40:58 +0200195 blk->ret = ret;
Jan Kiszkaa55eb922009-11-30 18:21:19 +0100196
Jan Kiszka5e5328b2009-11-30 18:21:20 +0100197 QSIMPLEQ_INSERT_TAIL(&block_mig_state.blk_list, blk, entry);
Marcelo Tosatti33656af2010-11-08 17:02:56 -0200198 bmds_set_aio_inflight(blk->bmds, blk->sector, blk->nr_sectors, 0);
Jan Kiszkaa55eb922009-11-30 18:21:19 +0100199
Jan Kiszkad11ecd32009-11-30 18:21:20 +0100200 block_mig_state.submitted--;
201 block_mig_state.read_done++;
202 assert(block_mig_state.submitted >= 0);
lirans@il.ibm.comc163b5c2009-11-02 15:40:58 +0200203}
204
Luiz Capitulino539de122011-12-05 14:06:56 -0200205static int mig_save_device_bulk(QEMUFile *f, BlkMigDevState *bmds)
Jan Kiszkaa55eb922009-11-30 18:21:19 +0100206{
Jan Kiszka57cce122009-11-30 18:21:20 +0100207 int64_t total_sectors = bmds->total_sectors;
208 int64_t cur_sector = bmds->cur_sector;
lirans@il.ibm.comc163b5c2009-11-02 15:40:58 +0200209 BlockDriverState *bs = bmds->bs;
Jan Kiszka57cce122009-11-30 18:21:20 +0100210 BlkMigBlock *blk;
Jan Kiszka13f0b672009-11-30 18:21:21 +0100211 int nr_sectors;
Jan Kiszkaa55eb922009-11-30 18:21:19 +0100212
213 if (bmds->shared_base) {
Jan Kiszkab1d10852009-11-30 18:21:20 +0100214 while (cur_sector < total_sectors &&
Jan Kiszka57cce122009-11-30 18:21:20 +0100215 !bdrv_is_allocated(bs, cur_sector, MAX_IS_ALLOCATED_SEARCH,
216 &nr_sectors)) {
lirans@il.ibm.comc163b5c2009-11-02 15:40:58 +0200217 cur_sector += nr_sectors;
218 }
219 }
Jan Kiszkaa55eb922009-11-30 18:21:19 +0100220
221 if (cur_sector >= total_sectors) {
Jan Kiszka82801d82009-11-30 18:21:21 +0100222 bmds->cur_sector = bmds->completed_sectors = total_sectors;
lirans@il.ibm.comc163b5c2009-11-02 15:40:58 +0200223 return 1;
224 }
Jan Kiszkaa55eb922009-11-30 18:21:19 +0100225
Jan Kiszka82801d82009-11-30 18:21:21 +0100226 bmds->completed_sectors = cur_sector;
Jan Kiszkaa55eb922009-11-30 18:21:19 +0100227
Jan Kiszka6ea44302009-11-30 18:21:19 +0100228 cur_sector &= ~((int64_t)BDRV_SECTORS_PER_DIRTY_CHUNK - 1);
Jan Kiszkaa55eb922009-11-30 18:21:19 +0100229
Jan Kiszka6ea44302009-11-30 18:21:19 +0100230 /* we are going to transfer a full block even if it is not allocated */
231 nr_sectors = BDRV_SECTORS_PER_DIRTY_CHUNK;
Jan Kiszkaa55eb922009-11-30 18:21:19 +0100232
Jan Kiszka6ea44302009-11-30 18:21:19 +0100233 if (total_sectors - cur_sector < BDRV_SECTORS_PER_DIRTY_CHUNK) {
Jan Kiszka57cce122009-11-30 18:21:20 +0100234 nr_sectors = total_sectors - cur_sector;
lirans@il.ibm.comc163b5c2009-11-02 15:40:58 +0200235 }
Jan Kiszkaa55eb922009-11-30 18:21:19 +0100236
Anthony Liguori7267c092011-08-20 22:09:37 -0500237 blk = g_malloc(sizeof(BlkMigBlock));
238 blk->buf = g_malloc(BLOCK_SIZE);
Jan Kiszka13f0b672009-11-30 18:21:21 +0100239 blk->bmds = bmds;
240 blk->sector = cur_sector;
Marcelo Tosatti33656af2010-11-08 17:02:56 -0200241 blk->nr_sectors = nr_sectors;
Jan Kiszka13f0b672009-11-30 18:21:21 +0100242
Liran Schoure970ec02010-01-26 10:31:45 +0200243 blk->iov.iov_base = blk->buf;
244 blk->iov.iov_len = nr_sectors * BDRV_SECTOR_SIZE;
245 qemu_iovec_init_external(&blk->qiov, &blk->iov, 1);
Jan Kiszka57cce122009-11-30 18:21:20 +0100246
Paolo Bonzini13197e32013-02-22 17:36:23 +0100247 block_mig_state.submitted++;
248
Liran Schoure970ec02010-01-26 10:31:45 +0200249 blk->aiocb = bdrv_aio_readv(bs, cur_sector, &blk->qiov,
250 nr_sectors, blk_mig_read_cb, blk);
Liran Schourd76cac72010-01-26 14:04:11 +0200251
Jan Kiszka13f0b672009-11-30 18:21:21 +0100252 bdrv_reset_dirty(bs, cur_sector, nr_sectors);
253 bmds->cur_sector = cur_sector + nr_sectors;
254
lirans@il.ibm.comc163b5c2009-11-02 15:40:58 +0200255 return (bmds->cur_sector >= total_sectors);
256}
257
lirans@il.ibm.comc163b5c2009-11-02 15:40:58 +0200258static void set_dirty_tracking(int enable)
259{
260 BlkMigDevState *bmds;
Jan Kiszka5e5328b2009-11-30 18:21:20 +0100261
262 QSIMPLEQ_FOREACH(bmds, &block_mig_state.bmds_list, entry) {
Paolo Bonzini50717e92013-01-21 17:09:45 +0100263 bdrv_set_dirty_tracking(bmds->bs, enable ? BLOCK_SIZE : 0);
lirans@il.ibm.comc163b5c2009-11-02 15:40:58 +0200264 }
lirans@il.ibm.comc163b5c2009-11-02 15:40:58 +0200265}
266
Stefan Hajnoczib66460e2010-04-09 15:22:13 +0100267static void init_blk_migration_it(void *opaque, BlockDriverState *bs)
lirans@il.ibm.comc163b5c2009-11-02 15:40:58 +0200268{
Jan Kiszka5e5328b2009-11-30 18:21:20 +0100269 BlkMigDevState *bmds;
Jan Kiszka792773b2009-11-30 20:34:55 +0100270 int64_t sectors;
Jan Kiszkaa55eb922009-11-30 18:21:19 +0100271
Markus Armbrusterd2466732010-06-28 10:45:02 +0200272 if (!bdrv_is_read_only(bs)) {
Stefan Hajnoczib66460e2010-04-09 15:22:13 +0100273 sectors = bdrv_getlength(bs) >> BDRV_SECTOR_BITS;
Shahar Havivi31f54f22010-07-10 18:59:06 +0300274 if (sectors <= 0) {
Stefan Hajnoczib66460e2010-04-09 15:22:13 +0100275 return;
276 }
277
Anthony Liguori7267c092011-08-20 22:09:37 -0500278 bmds = g_malloc0(sizeof(BlkMigDevState));
Stefan Hajnoczib66460e2010-04-09 15:22:13 +0100279 bmds->bs = bs;
280 bmds->bulk_completed = 0;
281 bmds->total_sectors = sectors;
282 bmds->completed_sectors = 0;
283 bmds->shared_base = block_mig_state.shared_base;
Marcelo Tosatti33656af2010-11-08 17:02:56 -0200284 alloc_aio_bitmap(bmds);
Marcelo Tosattif48905d2011-01-26 12:12:33 -0200285 drive_get_ref(drive_get_by_blockdev(bs));
Marcelo Tosatti85916752011-01-26 12:12:35 -0200286 bdrv_set_in_use(bs, 1);
Stefan Hajnoczib66460e2010-04-09 15:22:13 +0100287
288 block_mig_state.total_sector_sum += sectors;
289
290 if (bmds->shared_base) {
Luiz Capitulino539de122011-12-05 14:06:56 -0200291 DPRINTF("Start migration for %s with shared base image\n",
292 bs->device_name);
Stefan Hajnoczib66460e2010-04-09 15:22:13 +0100293 } else {
Luiz Capitulino539de122011-12-05 14:06:56 -0200294 DPRINTF("Start full migration for %s\n", bs->device_name);
Stefan Hajnoczib66460e2010-04-09 15:22:13 +0100295 }
296
297 QSIMPLEQ_INSERT_TAIL(&block_mig_state.bmds_list, bmds, entry);
298 }
299}
300
Luiz Capitulino539de122011-12-05 14:06:56 -0200301static void init_blk_migration(QEMUFile *f)
Stefan Hajnoczib66460e2010-04-09 15:22:13 +0100302{
Jan Kiszka69d63a92009-11-30 18:21:20 +0100303 block_mig_state.submitted = 0;
304 block_mig_state.read_done = 0;
305 block_mig_state.transferred = 0;
Jan Kiszka82801d82009-11-30 18:21:21 +0100306 block_mig_state.total_sector_sum = 0;
Jan Kiszka01e61e22009-12-01 15:20:17 +0100307 block_mig_state.prev_progress = -1;
Liran Schoure970ec02010-01-26 10:31:45 +0200308 block_mig_state.bulk_completed = 0;
Jan Kiszka69d63a92009-11-30 18:21:20 +0100309
Luiz Capitulino539de122011-12-05 14:06:56 -0200310 bdrv_iterate(init_blk_migration_it, NULL);
lirans@il.ibm.comc163b5c2009-11-02 15:40:58 +0200311}
312
Luiz Capitulino539de122011-12-05 14:06:56 -0200313static int blk_mig_save_bulked_block(QEMUFile *f)
lirans@il.ibm.comc163b5c2009-11-02 15:40:58 +0200314{
Jan Kiszka82801d82009-11-30 18:21:21 +0100315 int64_t completed_sector_sum = 0;
lirans@il.ibm.comc163b5c2009-11-02 15:40:58 +0200316 BlkMigDevState *bmds;
Jan Kiszka01e61e22009-12-01 15:20:17 +0100317 int progress;
Jan Kiszka82801d82009-11-30 18:21:21 +0100318 int ret = 0;
lirans@il.ibm.comc163b5c2009-11-02 15:40:58 +0200319
Jan Kiszka5e5328b2009-11-30 18:21:20 +0100320 QSIMPLEQ_FOREACH(bmds, &block_mig_state.bmds_list, entry) {
Jan Kiszkaa55eb922009-11-30 18:21:19 +0100321 if (bmds->bulk_completed == 0) {
Luiz Capitulino539de122011-12-05 14:06:56 -0200322 if (mig_save_device_bulk(f, bmds) == 1) {
Jan Kiszka57cce122009-11-30 18:21:20 +0100323 /* completed bulk section for this device */
324 bmds->bulk_completed = 1;
lirans@il.ibm.comc163b5c2009-11-02 15:40:58 +0200325 }
Jan Kiszka82801d82009-11-30 18:21:21 +0100326 completed_sector_sum += bmds->completed_sectors;
327 ret = 1;
328 break;
329 } else {
330 completed_sector_sum += bmds->completed_sectors;
lirans@il.ibm.comc163b5c2009-11-02 15:40:58 +0200331 }
332 }
Jan Kiszkaa55eb922009-11-30 18:21:19 +0100333
Pierre Riteau8b6b2af2011-01-12 14:41:00 +0100334 if (block_mig_state.total_sector_sum != 0) {
335 progress = completed_sector_sum * 100 /
336 block_mig_state.total_sector_sum;
337 } else {
338 progress = 100;
339 }
Jan Kiszka01e61e22009-12-01 15:20:17 +0100340 if (progress != block_mig_state.prev_progress) {
341 block_mig_state.prev_progress = progress;
342 qemu_put_be64(f, (progress << BDRV_SECTOR_BITS)
343 | BLK_MIG_FLAG_PROGRESS);
Luiz Capitulino539de122011-12-05 14:06:56 -0200344 DPRINTF("Completed %d %%\r", progress);
Jan Kiszka82801d82009-11-30 18:21:21 +0100345 }
346
347 return ret;
lirans@il.ibm.comc163b5c2009-11-02 15:40:58 +0200348}
349
Liran Schourd76cac72010-01-26 14:04:11 +0200350static void blk_mig_reset_dirty_cursor(void)
lirans@il.ibm.comc163b5c2009-11-02 15:40:58 +0200351{
352 BlkMigDevState *bmds;
Jan Kiszka575a58d2009-11-30 18:21:20 +0100353
Jan Kiszka5e5328b2009-11-30 18:21:20 +0100354 QSIMPLEQ_FOREACH(bmds, &block_mig_state.bmds_list, entry) {
Liran Schourd76cac72010-01-26 14:04:11 +0200355 bmds->cur_dirty = 0;
356 }
357}
Jan Kiszkaa55eb922009-11-30 18:21:19 +0100358
Luiz Capitulino539de122011-12-05 14:06:56 -0200359static int mig_save_device_dirty(QEMUFile *f, BlkMigDevState *bmds,
360 int is_async)
Liran Schourd76cac72010-01-26 14:04:11 +0200361{
362 BlkMigBlock *blk;
363 int64_t total_sectors = bmds->total_sectors;
364 int64_t sector;
365 int nr_sectors;
Juan Quinteladcd1d222011-09-21 23:01:54 +0200366 int ret = -EIO;
Liran Schourd76cac72010-01-26 14:04:11 +0200367
368 for (sector = bmds->cur_dirty; sector < bmds->total_sectors;) {
Marcelo Tosatti62155e22010-11-12 16:07:50 -0200369 if (bmds_aio_inflight(bmds, sector)) {
Stefan Hajnoczi922453b2011-11-30 12:23:43 +0000370 bdrv_drain_all();
Marcelo Tosatti62155e22010-11-12 16:07:50 -0200371 }
Liran Schourd76cac72010-01-26 14:04:11 +0200372 if (bdrv_get_dirty(bmds->bs, sector)) {
373
374 if (total_sectors - sector < BDRV_SECTORS_PER_DIRTY_CHUNK) {
375 nr_sectors = total_sectors - sector;
376 } else {
377 nr_sectors = BDRV_SECTORS_PER_DIRTY_CHUNK;
Jan Kiszkaa55eb922009-11-30 18:21:19 +0100378 }
Anthony Liguori7267c092011-08-20 22:09:37 -0500379 blk = g_malloc(sizeof(BlkMigBlock));
380 blk->buf = g_malloc(BLOCK_SIZE);
Liran Schourd76cac72010-01-26 14:04:11 +0200381 blk->bmds = bmds;
382 blk->sector = sector;
Marcelo Tosatti33656af2010-11-08 17:02:56 -0200383 blk->nr_sectors = nr_sectors;
Liran Schourd76cac72010-01-26 14:04:11 +0200384
Liran Schour889ae392010-01-26 10:31:49 +0200385 if (is_async) {
Liran Schourd76cac72010-01-26 14:04:11 +0200386 blk->iov.iov_base = blk->buf;
387 blk->iov.iov_len = nr_sectors * BDRV_SECTOR_SIZE;
388 qemu_iovec_init_external(&blk->qiov, &blk->iov, 1);
389
390 blk->aiocb = bdrv_aio_readv(bmds->bs, sector, &blk->qiov,
391 nr_sectors, blk_mig_read_cb, blk);
Liran Schourd76cac72010-01-26 14:04:11 +0200392 block_mig_state.submitted++;
Marcelo Tosatti33656af2010-11-08 17:02:56 -0200393 bmds_set_aio_inflight(bmds, sector, nr_sectors, 1);
Liran Schourd76cac72010-01-26 14:04:11 +0200394 } else {
Juan Quinteladcd1d222011-09-21 23:01:54 +0200395 ret = bdrv_read(bmds->bs, sector, blk->buf, nr_sectors);
396 if (ret < 0) {
Liran Schourd76cac72010-01-26 14:04:11 +0200397 goto error;
398 }
399 blk_send(f, blk);
400
Anthony Liguori7267c092011-08-20 22:09:37 -0500401 g_free(blk->buf);
402 g_free(blk);
Liran Schourd76cac72010-01-26 14:04:11 +0200403 }
404
405 bdrv_reset_dirty(bmds->bs, sector, nr_sectors);
406 break;
407 }
408 sector += BDRV_SECTORS_PER_DIRTY_CHUNK;
409 bmds->cur_dirty = sector;
410 }
411
412 return (bmds->cur_dirty >= bmds->total_sectors);
413
Liran Schour889ae392010-01-26 10:31:49 +0200414error:
Luiz Capitulino539de122011-12-05 14:06:56 -0200415 DPRINTF("Error reading sector %" PRId64 "\n", sector);
Anthony Liguori7267c092011-08-20 22:09:37 -0500416 g_free(blk->buf);
417 g_free(blk);
Juan Quintela43be3a22012-08-29 21:59:22 +0200418 return ret;
Liran Schourd76cac72010-01-26 14:04:11 +0200419}
420
Juan Quintelaceb2bd02012-08-29 21:37:14 +0200421/* return value:
422 * 0: too much data for max_downtime
423 * 1: few enough data for max_downtime
424*/
Luiz Capitulino539de122011-12-05 14:06:56 -0200425static int blk_mig_save_dirty_block(QEMUFile *f, int is_async)
Liran Schourd76cac72010-01-26 14:04:11 +0200426{
427 BlkMigDevState *bmds;
Juan Quintelaceb2bd02012-08-29 21:37:14 +0200428 int ret = 1;
Liran Schourd76cac72010-01-26 14:04:11 +0200429
430 QSIMPLEQ_FOREACH(bmds, &block_mig_state.bmds_list, entry) {
Juan Quintelaceb2bd02012-08-29 21:37:14 +0200431 ret = mig_save_device_dirty(f, bmds, is_async);
Juan Quintela43be3a22012-08-29 21:59:22 +0200432 if (ret <= 0) {
Liran Schourd76cac72010-01-26 14:04:11 +0200433 break;
lirans@il.ibm.comc163b5c2009-11-02 15:40:58 +0200434 }
435 }
Jan Kiszka575a58d2009-11-30 18:21:20 +0100436
Liran Schourd76cac72010-01-26 14:04:11 +0200437 return ret;
lirans@il.ibm.comc163b5c2009-11-02 15:40:58 +0200438}
439
Juan Quintela59feec42012-08-29 20:17:13 +0200440static int flush_blks(QEMUFile *f)
lirans@il.ibm.comc163b5c2009-11-02 15:40:58 +0200441{
Jan Kiszka5e5328b2009-11-30 18:21:20 +0100442 BlkMigBlock *blk;
Juan Quintela59feec42012-08-29 20:17:13 +0200443 int ret = 0;
Jan Kiszkaa55eb922009-11-30 18:21:19 +0100444
malcd0f2c4c2010-02-07 02:03:50 +0300445 DPRINTF("%s Enter submitted %d read_done %d transferred %d\n",
Jan Kiszkad11ecd32009-11-30 18:21:20 +0100446 __FUNCTION__, block_mig_state.submitted, block_mig_state.read_done,
447 block_mig_state.transferred);
Jan Kiszkaa55eb922009-11-30 18:21:19 +0100448
Jan Kiszka5e5328b2009-11-30 18:21:20 +0100449 while ((blk = QSIMPLEQ_FIRST(&block_mig_state.blk_list)) != NULL) {
450 if (qemu_file_rate_limit(f)) {
451 break;
452 }
Jan Kiszka4b640362009-11-30 18:21:21 +0100453 if (blk->ret < 0) {
Juan Quintela59feec42012-08-29 20:17:13 +0200454 ret = blk->ret;
Jan Kiszka4b640362009-11-30 18:21:21 +0100455 break;
456 }
Jan Kiszkaa55eb922009-11-30 18:21:19 +0100457
Jan Kiszka5e5328b2009-11-30 18:21:20 +0100458 QSIMPLEQ_REMOVE_HEAD(&block_mig_state.blk_list, entry);
Paolo Bonzini13197e32013-02-22 17:36:23 +0100459 blk_send(f, blk);
460
Anthony Liguori7267c092011-08-20 22:09:37 -0500461 g_free(blk->buf);
462 g_free(blk);
Jan Kiszkaa55eb922009-11-30 18:21:19 +0100463
Jan Kiszkad11ecd32009-11-30 18:21:20 +0100464 block_mig_state.read_done--;
465 block_mig_state.transferred++;
466 assert(block_mig_state.read_done >= 0);
lirans@il.ibm.comc163b5c2009-11-02 15:40:58 +0200467 }
lirans@il.ibm.comc163b5c2009-11-02 15:40:58 +0200468
malcd0f2c4c2010-02-07 02:03:50 +0300469 DPRINTF("%s Exit submitted %d read_done %d transferred %d\n", __FUNCTION__,
Jan Kiszkad11ecd32009-11-30 18:21:20 +0100470 block_mig_state.submitted, block_mig_state.read_done,
471 block_mig_state.transferred);
Juan Quintela59feec42012-08-29 20:17:13 +0200472 return ret;
lirans@il.ibm.comc163b5c2009-11-02 15:40:58 +0200473}
474
Liran Schour889ae392010-01-26 10:31:49 +0200475static int64_t get_remaining_dirty(void)
476{
477 BlkMigDevState *bmds;
478 int64_t dirty = 0;
479
480 QSIMPLEQ_FOREACH(bmds, &block_mig_state.bmds_list, entry) {
481 dirty += bdrv_get_dirty_count(bmds->bs);
482 }
483
Paolo Bonziniacc906c2013-01-21 17:09:44 +0100484 return dirty << BDRV_SECTOR_BITS;
Liran Schour889ae392010-01-26 10:31:49 +0200485}
486
Luiz Capitulino539de122011-12-05 14:06:56 -0200487static void blk_mig_cleanup(void)
Jan Kiszka4ec7fcc2009-11-30 18:21:21 +0100488{
Jan Kiszka82801d82009-11-30 18:21:21 +0100489 BlkMigDevState *bmds;
490 BlkMigBlock *blk;
Jan Kiszka4ec7fcc2009-11-30 18:21:21 +0100491
Kevin Wolf946d58b2012-09-25 15:47:36 +0200492 bdrv_drain_all();
493
Marcelo Tosatti8f794c52011-01-26 12:12:31 -0200494 set_dirty_tracking(0);
495
Jan Kiszka82801d82009-11-30 18:21:21 +0100496 while ((bmds = QSIMPLEQ_FIRST(&block_mig_state.bmds_list)) != NULL) {
497 QSIMPLEQ_REMOVE_HEAD(&block_mig_state.bmds_list, entry);
Marcelo Tosatti85916752011-01-26 12:12:35 -0200498 bdrv_set_in_use(bmds->bs, 0);
Marcelo Tosattif48905d2011-01-26 12:12:33 -0200499 drive_put_ref(drive_get_by_blockdev(bmds->bs));
Anthony Liguori7267c092011-08-20 22:09:37 -0500500 g_free(bmds->aio_bitmap);
501 g_free(bmds);
Jan Kiszka4ec7fcc2009-11-30 18:21:21 +0100502 }
503
Jan Kiszka82801d82009-11-30 18:21:21 +0100504 while ((blk = QSIMPLEQ_FIRST(&block_mig_state.blk_list)) != NULL) {
505 QSIMPLEQ_REMOVE_HEAD(&block_mig_state.blk_list, entry);
Anthony Liguori7267c092011-08-20 22:09:37 -0500506 g_free(blk->buf);
507 g_free(blk);
Jan Kiszka4ec7fcc2009-11-30 18:21:21 +0100508 }
Jan Kiszka4ec7fcc2009-11-30 18:21:21 +0100509}
510
Juan Quintela9b5bfab2012-06-26 19:26:41 +0200511static void block_migration_cancel(void *opaque)
512{
513 blk_mig_cleanup();
514}
515
Juan Quintelad1315aa2012-06-28 15:11:57 +0200516static int block_save_setup(QEMUFile *f, void *opaque)
517{
518 int ret;
519
520 DPRINTF("Enter save live setup submitted %d transferred %d\n",
521 block_mig_state.submitted, block_mig_state.transferred);
522
523 init_blk_migration(f);
524
525 /* start track dirty blocks */
526 set_dirty_tracking(1);
527
Juan Quintela59feec42012-08-29 20:17:13 +0200528 ret = flush_blks(f);
Juan Quintelad1315aa2012-06-28 15:11:57 +0200529 blk_mig_reset_dirty_cursor();
Juan Quintelad1315aa2012-06-28 15:11:57 +0200530 qemu_put_be64(f, BLK_MIG_FLAG_EOS);
531
Paolo Bonzinid418cf52013-02-22 17:36:11 +0100532 return ret;
Juan Quintelad1315aa2012-06-28 15:11:57 +0200533}
534
Juan Quintela16310a32012-06-28 15:31:37 +0200535static int block_save_iterate(QEMUFile *f, void *opaque)
lirans@il.ibm.comc163b5c2009-11-02 15:40:58 +0200536{
Juan Quintela29757252011-10-19 15:22:18 +0200537 int ret;
Stefan Hajnoczi6aaa9da2013-02-12 10:37:15 +0100538 int64_t last_ftell = qemu_ftell(f);
Juan Quintela29757252011-10-19 15:22:18 +0200539
Juan Quintela16310a32012-06-28 15:31:37 +0200540 DPRINTF("Enter save live iterate submitted %d transferred %d\n",
541 block_mig_state.submitted, block_mig_state.transferred);
Jan Kiszkaa55eb922009-11-30 18:21:19 +0100542
Juan Quintela59feec42012-08-29 20:17:13 +0200543 ret = flush_blks(f);
Juan Quintela29757252011-10-19 15:22:18 +0200544 if (ret) {
Juan Quintela29757252011-10-19 15:22:18 +0200545 return ret;
Jan Kiszka4b640362009-11-30 18:21:21 +0100546 }
547
Liran Schourd76cac72010-01-26 14:04:11 +0200548 blk_mig_reset_dirty_cursor();
549
Juan Quintela16310a32012-06-28 15:31:37 +0200550 /* control the rate of transfer */
551 while ((block_mig_state.submitted +
552 block_mig_state.read_done) * BLOCK_SIZE <
553 qemu_file_get_rate_limit(f)) {
554 if (block_mig_state.bulk_completed == 0) {
555 /* first finish the bulk phase */
556 if (blk_mig_save_bulked_block(f) == 0) {
557 /* finished saving bulk on all devices */
558 block_mig_state.bulk_completed = 1;
Liran Schourd76cac72010-01-26 14:04:11 +0200559 }
Paolo Bonzini13197e32013-02-22 17:36:23 +0100560 ret = 0;
Juan Quintela16310a32012-06-28 15:31:37 +0200561 } else {
Juan Quintela43be3a22012-08-29 21:59:22 +0200562 ret = blk_mig_save_dirty_block(f, 1);
Paolo Bonzini13197e32013-02-22 17:36:23 +0100563 }
564 if (ret < 0) {
565 return ret;
566 }
567 if (ret != 0) {
568 /* no more dirty blocks */
569 break;
Liran Schourd76cac72010-01-26 14:04:11 +0200570 }
Jan Kiszka4b640362009-11-30 18:21:21 +0100571 }
572
Juan Quintela59feec42012-08-29 20:17:13 +0200573 ret = flush_blks(f);
Juan Quintela16310a32012-06-28 15:31:37 +0200574 if (ret) {
Juan Quintela16310a32012-06-28 15:31:37 +0200575 return ret;
lirans@il.ibm.comc163b5c2009-11-02 15:40:58 +0200576 }
Jan Kiszkaa55eb922009-11-30 18:21:19 +0100577
578 qemu_put_be64(f, BLK_MIG_FLAG_EOS);
Stefan Hajnoczi6aaa9da2013-02-12 10:37:15 +0100579 return qemu_ftell(f) - last_ftell;
Juan Quintela16310a32012-06-28 15:31:37 +0200580}
581
582static int block_save_complete(QEMUFile *f, void *opaque)
583{
584 int ret;
585
586 DPRINTF("Enter save live complete submitted %d transferred %d\n",
587 block_mig_state.submitted, block_mig_state.transferred);
588
Juan Quintela59feec42012-08-29 20:17:13 +0200589 ret = flush_blks(f);
Juan Quintela16310a32012-06-28 15:31:37 +0200590 if (ret) {
Juan Quintela16310a32012-06-28 15:31:37 +0200591 return ret;
592 }
593
594 blk_mig_reset_dirty_cursor();
595
596 /* we know for sure that save bulk is completed and
597 all async read completed */
598 assert(block_mig_state.submitted == 0);
599
Juan Quintela43be3a22012-08-29 21:59:22 +0200600 do {
601 ret = blk_mig_save_dirty_block(f, 0);
Paolo Bonzinid418cf52013-02-22 17:36:11 +0100602 if (ret < 0) {
603 return ret;
604 }
Juan Quintela43be3a22012-08-29 21:59:22 +0200605 } while (ret == 0);
606
Juan Quintela43be3a22012-08-29 21:59:22 +0200607 /* report completion */
608 qemu_put_be64(f, (100 << BDRV_SECTOR_BITS) | BLK_MIG_FLAG_PROGRESS);
Juan Quintela16310a32012-06-28 15:31:37 +0200609
610 DPRINTF("Block migration completed\n");
611
612 qemu_put_be64(f, BLK_MIG_FLAG_EOS);
613
Paolo Bonzinid418cf52013-02-22 17:36:11 +0100614 blk_mig_cleanup();
Juan Quintela16310a32012-06-28 15:31:37 +0200615 return 0;
lirans@il.ibm.comc163b5c2009-11-02 15:40:58 +0200616}
617
Juan Quintelae4ed1542012-09-21 11:18:18 +0200618static uint64_t block_save_pending(QEMUFile *f, void *opaque, uint64_t max_size)
619{
Stefan Hajnoczi6aaa9da2013-02-12 10:37:15 +0100620 /* Estimate pending number of bytes to send */
Paolo Bonzini13197e32013-02-22 17:36:23 +0100621 uint64_t pending;
622
623 pending = get_remaining_dirty() +
Stefan Hajnoczi6aaa9da2013-02-12 10:37:15 +0100624 block_mig_state.submitted * BLOCK_SIZE +
625 block_mig_state.read_done * BLOCK_SIZE;
Juan Quintelae4ed1542012-09-21 11:18:18 +0200626
Stefan Hajnoczi6aaa9da2013-02-12 10:37:15 +0100627 /* Report at least one block pending during bulk phase */
628 if (pending == 0 && !block_mig_state.bulk_completed) {
629 pending = BLOCK_SIZE;
630 }
Juan Quintelae4ed1542012-09-21 11:18:18 +0200631
Stefan Hajnoczi6aaa9da2013-02-12 10:37:15 +0100632 DPRINTF("Enter save live pending %" PRIu64 "\n", pending);
633 return pending;
Juan Quintelae4ed1542012-09-21 11:18:18 +0200634}
635
lirans@il.ibm.comc163b5c2009-11-02 15:40:58 +0200636static int block_load(QEMUFile *f, void *opaque, int version_id)
637{
Jan Kiszka01e61e22009-12-01 15:20:17 +0100638 static int banner_printed;
lirans@il.ibm.comc163b5c2009-11-02 15:40:58 +0200639 int len, flags;
640 char device_name[256];
641 int64_t addr;
Pierre Riteau77358b52011-01-21 12:42:30 +0100642 BlockDriverState *bs, *bs_prev = NULL;
lirans@il.ibm.comc163b5c2009-11-02 15:40:58 +0200643 uint8_t *buf;
Pierre Riteau77358b52011-01-21 12:42:30 +0100644 int64_t total_sectors = 0;
645 int nr_sectors;
Juan Quintela42802d42011-10-05 01:14:46 +0200646 int ret;
Jan Kiszkaa55eb922009-11-30 18:21:19 +0100647
lirans@il.ibm.comc163b5c2009-11-02 15:40:58 +0200648 do {
lirans@il.ibm.comc163b5c2009-11-02 15:40:58 +0200649 addr = qemu_get_be64(f);
Jan Kiszkaa55eb922009-11-30 18:21:19 +0100650
Jan Kiszka6ea44302009-11-30 18:21:19 +0100651 flags = addr & ~BDRV_SECTOR_MASK;
652 addr >>= BDRV_SECTOR_BITS;
Jan Kiszkaa55eb922009-11-30 18:21:19 +0100653
654 if (flags & BLK_MIG_FLAG_DEVICE_BLOCK) {
lirans@il.ibm.comc163b5c2009-11-02 15:40:58 +0200655 /* get device name */
656 len = qemu_get_byte(f);
lirans@il.ibm.comc163b5c2009-11-02 15:40:58 +0200657 qemu_get_buffer(f, (uint8_t *)device_name, len);
658 device_name[len] = '\0';
Jan Kiszkaa55eb922009-11-30 18:21:19 +0100659
lirans@il.ibm.comc163b5c2009-11-02 15:40:58 +0200660 bs = bdrv_find(device_name);
Jan Kiszka4b640362009-11-30 18:21:21 +0100661 if (!bs) {
662 fprintf(stderr, "Error unknown block device %s\n",
663 device_name);
664 return -EINVAL;
665 }
Jan Kiszkaa55eb922009-11-30 18:21:19 +0100666
Pierre Riteau77358b52011-01-21 12:42:30 +0100667 if (bs != bs_prev) {
668 bs_prev = bs;
669 total_sectors = bdrv_getlength(bs) >> BDRV_SECTOR_BITS;
670 if (total_sectors <= 0) {
Markus Armbruster6daf1942011-06-22 14:03:54 +0200671 error_report("Error getting length of block device %s",
Pierre Riteau77358b52011-01-21 12:42:30 +0100672 device_name);
673 return -EINVAL;
674 }
675 }
676
677 if (total_sectors - addr < BDRV_SECTORS_PER_DIRTY_CHUNK) {
678 nr_sectors = total_sectors - addr;
679 } else {
680 nr_sectors = BDRV_SECTORS_PER_DIRTY_CHUNK;
681 }
682
Anthony Liguori7267c092011-08-20 22:09:37 -0500683 buf = g_malloc(BLOCK_SIZE);
Jan Kiszka575a58d2009-11-30 18:21:20 +0100684
Jan Kiszkaa55eb922009-11-30 18:21:19 +0100685 qemu_get_buffer(f, buf, BLOCK_SIZE);
Pierre Riteau77358b52011-01-21 12:42:30 +0100686 ret = bdrv_write(bs, addr, buf, nr_sectors);
Jan Kiszka575a58d2009-11-30 18:21:20 +0100687
Anthony Liguori7267c092011-08-20 22:09:37 -0500688 g_free(buf);
Yoshiaki Tamurab02bea32010-07-20 18:19:00 +0900689 if (ret < 0) {
690 return ret;
691 }
Jan Kiszka01e61e22009-12-01 15:20:17 +0100692 } else if (flags & BLK_MIG_FLAG_PROGRESS) {
693 if (!banner_printed) {
694 printf("Receiving block device images\n");
695 banner_printed = 1;
696 }
697 printf("Completed %d %%%c", (int)addr,
698 (addr == 100) ? '\n' : '\r');
699 fflush(stdout);
Jan Kiszkaa55eb922009-11-30 18:21:19 +0100700 } else if (!(flags & BLK_MIG_FLAG_EOS)) {
Stefan Hajnoczid5f1f282013-02-10 23:12:44 +0100701 fprintf(stderr, "Unknown block migration flags: %#x\n", flags);
Jan Kiszka4b640362009-11-30 18:21:21 +0100702 return -EINVAL;
703 }
Juan Quintela42802d42011-10-05 01:14:46 +0200704 ret = qemu_file_get_error(f);
705 if (ret != 0) {
706 return ret;
lirans@il.ibm.comc163b5c2009-11-02 15:40:58 +0200707 }
Jan Kiszkaa55eb922009-11-30 18:21:19 +0100708 } while (!(flags & BLK_MIG_FLAG_EOS));
709
lirans@il.ibm.comc163b5c2009-11-02 15:40:58 +0200710 return 0;
711}
712
Isaku Yamahata6607ae22012-06-19 18:43:09 +0300713static void block_set_params(const MigrationParams *params, void *opaque)
lirans@il.ibm.comc163b5c2009-11-02 15:40:58 +0200714{
Isaku Yamahata6607ae22012-06-19 18:43:09 +0300715 block_mig_state.blk_enable = params->blk;
716 block_mig_state.shared_base = params->shared;
Jan Kiszkaa55eb922009-11-30 18:21:19 +0100717
lirans@il.ibm.comc163b5c2009-11-02 15:40:58 +0200718 /* shared base means that blk_enable = 1 */
Isaku Yamahata6607ae22012-06-19 18:43:09 +0300719 block_mig_state.blk_enable |= params->shared;
lirans@il.ibm.comc163b5c2009-11-02 15:40:58 +0200720}
721
Juan Quintela6bd68782012-06-27 10:59:15 +0200722static bool block_is_active(void *opaque)
723{
724 return block_mig_state.blk_enable == 1;
725}
726
Juan Quintela7908c782012-06-26 18:46:10 +0200727SaveVMHandlers savevm_block_handlers = {
728 .set_params = block_set_params,
Juan Quintelad1315aa2012-06-28 15:11:57 +0200729 .save_live_setup = block_save_setup,
Juan Quintela16310a32012-06-28 15:31:37 +0200730 .save_live_iterate = block_save_iterate,
731 .save_live_complete = block_save_complete,
Juan Quintelae4ed1542012-09-21 11:18:18 +0200732 .save_live_pending = block_save_pending,
Juan Quintela7908c782012-06-26 18:46:10 +0200733 .load_state = block_load,
Juan Quintela9b5bfab2012-06-26 19:26:41 +0200734 .cancel = block_migration_cancel,
Juan Quintela6bd68782012-06-27 10:59:15 +0200735 .is_active = block_is_active,
Juan Quintela7908c782012-06-26 18:46:10 +0200736};
737
lirans@il.ibm.comc163b5c2009-11-02 15:40:58 +0200738void blk_mig_init(void)
Jan Kiszkaa55eb922009-11-30 18:21:19 +0100739{
Jan Kiszka5e5328b2009-11-30 18:21:20 +0100740 QSIMPLEQ_INIT(&block_mig_state.bmds_list);
741 QSIMPLEQ_INIT(&block_mig_state.blk_list);
742
Juan Quintela7908c782012-06-26 18:46:10 +0200743 register_savevm_live(NULL, "block", 0, 1, &savevm_block_handlers,
744 &block_mig_state);
lirans@il.ibm.comc163b5c2009-11-02 15:40:58 +0200745}