[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 19/31] migration/block: Convert load to BlockBackend
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 19/31] migration/block: Convert load to BlockBackend |
Date: |
Wed, 8 Jun 2016 11:16:45 +0200 |
This converts the loading part of block migration to use BlockBackend
interfaces rather than accessing the BlockDriverState directly.
Note that this takes a lazy shortcut. We should really use a separate
BlockBackend that is configured for the migration rather than for the
guest (e.g. writethrough caching is unnecessary) and holds its own
reference to the BlockDriverState, but the impact isn't that big and we
didn't have a separate migration reference before either, so it must be
good enough, I guess...
Signed-off-by: Kevin Wolf <address@hidden>
Reviewed-by: Stefan Hajnoczi <address@hidden>
---
migration/block.c | 26 ++++++++++----------------
1 file changed, 10 insertions(+), 16 deletions(-)
diff --git a/migration/block.c b/migration/block.c
index 16cc1f8..30af182 100644
--- a/migration/block.c
+++ b/migration/block.c
@@ -827,8 +827,7 @@ static int block_load(QEMUFile *f, void *opaque, int
version_id)
int len, flags;
char device_name[256];
int64_t addr;
- BlockDriverState *bs, *bs_prev = NULL;
- BlockBackend *blk;
+ BlockBackend *blk, *blk_prev = NULL;;
Error *local_err = NULL;
uint8_t *buf;
int64_t total_sectors = 0;
@@ -853,23 +852,17 @@ static int block_load(QEMUFile *f, void *opaque, int
version_id)
device_name);
return -EINVAL;
}
- bs = blk_bs(blk);
- if (!bs) {
- fprintf(stderr, "Block device %s has no medium\n",
- device_name);
- return -EINVAL;
- }
- if (bs != bs_prev) {
- bs_prev = bs;
- total_sectors = bdrv_nb_sectors(bs);
+ if (blk != blk_prev) {
+ blk_prev = blk;
+ total_sectors = blk_nb_sectors(blk);
if (total_sectors <= 0) {
error_report("Error getting length of block device %s",
device_name);
return -EINVAL;
}
- bdrv_invalidate_cache(bs, &local_err);
+ blk_invalidate_cache(blk, &local_err);
if (local_err) {
error_report_err(local_err);
return -EINVAL;
@@ -883,13 +876,14 @@ static int block_load(QEMUFile *f, void *opaque, int
version_id)
}
if (flags & BLK_MIG_FLAG_ZERO_BLOCK) {
- ret = bdrv_pwrite_zeroes(bs, addr << BDRV_SECTOR_BITS,
- nr_sectors << BDRV_SECTOR_BITS,
- BDRV_REQ_MAY_UNMAP);
+ ret = blk_pwrite_zeroes(blk, addr * BDRV_SECTOR_SIZE,
+ nr_sectors * BDRV_SECTOR_SIZE,
+ BDRV_REQ_MAY_UNMAP);
} else {
buf = g_malloc(BLOCK_SIZE);
qemu_get_buffer(f, buf, BLOCK_SIZE);
- ret = bdrv_write(bs, addr, buf, nr_sectors);
+ ret = blk_pwrite(blk, addr * BDRV_SECTOR_SIZE, buf,
+ nr_sectors * BDRV_SECTOR_SIZE, 0);
g_free(buf);
}
--
1.8.3.1
- [Qemu-devel] [PULL 06/31] iscsi: Use block size as minimum zero/discard alignment, (continued)
- [Qemu-devel] [PULL 06/31] iscsi: Use block size as minimum zero/discard alignment, Kevin Wolf, 2016/06/08
- [Qemu-devel] [PULL 02/31] qcow2: simplify logic in qcow2_co_write_zeroes, Kevin Wolf, 2016/06/08
- [Qemu-devel] [PULL 07/31] block: Track write zero limits in bytes, Kevin Wolf, 2016/06/08
- [Qemu-devel] [PULL 08/31] block: Add .bdrv_co_pwrite_zeroes(), Kevin Wolf, 2016/06/08
- [Qemu-devel] [PULL 01/31] block: split write_zeroes always, Kevin Wolf, 2016/06/08
- [Qemu-devel] [PULL 03/31] qcow2: add tracepoints for qcow2_co_write_zeroes, Kevin Wolf, 2016/06/08
- [Qemu-devel] [PULL 10/31] iscsi: Convert to bdrv_co_pwrite_zeroes(), Kevin Wolf, 2016/06/08
- [Qemu-devel] [PULL 11/31] qcow2: Convert to bdrv_co_pwrite_zeroes(), Kevin Wolf, 2016/06/08
- [Qemu-devel] [PULL 05/31] qcow2: Catch more unaligned write_zero into zero cluster, Kevin Wolf, 2016/06/08
- [Qemu-devel] [PULL 17/31] vmdk: Convert to bdrv_co_pwrite_zeroes(), Kevin Wolf, 2016/06/08
- [Qemu-devel] [PULL 19/31] migration/block: Convert load to BlockBackend,
Kevin Wolf <=
- [Qemu-devel] [PULL 09/31] block: Switch bdrv_write_zeroes() to byte interface, Kevin Wolf, 2016/06/08
- [Qemu-devel] [PULL 21/31] block: assert that bs->request_alignment is a power of 2, Kevin Wolf, 2016/06/08
- [Qemu-devel] [PULL 15/31] raw-posix: Convert to bdrv_co_pwrite_zeroes(), Kevin Wolf, 2016/06/08
- [Qemu-devel] [PULL 18/31] block: Kill bdrv_co_write_zeroes(), Kevin Wolf, 2016/06/08
- [Qemu-devel] [PULL 04/31] qemu-iotests: Test one more spot for optimizing write_zeroes, Kevin Wolf, 2016/06/08
- [Qemu-devel] [PULL 13/31] gluster: Convert to bdrv_co_pwrite_zeroes(), Kevin Wolf, 2016/06/08
- [Qemu-devel] [PULL 12/31] blkreplay: Convert to bdrv_co_pwrite_zeroes(), Kevin Wolf, 2016/06/08
- [Qemu-devel] [PULL 16/31] raw_bsd: Convert to bdrv_co_pwrite_zeroes(), Kevin Wolf, 2016/06/08
- [Qemu-devel] [PULL 14/31] qed: Convert to bdrv_co_pwrite_zeroes(), Kevin Wolf, 2016/06/08
- [Qemu-devel] [PULL 28/31] qemu-img bench: Sequential writes, Kevin Wolf, 2016/06/08