[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 25/39] qcow2: Let vmstate call qcow2_co_preadv/pwrite
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 25/39] qcow2: Let vmstate call qcow2_co_preadv/pwrite directly |
Date: |
Thu, 16 Jun 2016 16:08:14 +0200 |
We don't really want to go through the block layer in order to read from
or write to the vmstate in a qcow2 image. Doing so required a few ugly
hacks like saving and restoring the old image size (because writing to
vmstate offsets would increase the image size) or disabling the "reads
after EOF = zeroes" logic. When calling the right functions directly,
these hacks aren't necessary any more.
Note that .bdrv_vmstate_load/save() return 0 instead of the number of
bytes in case of success now.
Signed-off-by: Kevin Wolf <address@hidden>
Reviewed-by: Fam Zheng <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Reviewed-by: Stefan Hajnoczi <address@hidden>
---
block/qcow2.c | 24 ++++--------------------
1 file changed, 4 insertions(+), 20 deletions(-)
diff --git a/block/qcow2.c b/block/qcow2.c
index 362ada2..4718f82 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -2909,36 +2909,20 @@ static int qcow2_save_vmstate(BlockDriverState *bs,
QEMUIOVector *qiov,
int64_t pos)
{
BDRVQcow2State *s = bs->opaque;
- int64_t total_sectors = bs->total_sectors;
- bool zero_beyond_eof = bs->zero_beyond_eof;
- int ret;
BLKDBG_EVENT(bs->file, BLKDBG_VMSTATE_SAVE);
- bs->zero_beyond_eof = false;
- ret = bdrv_pwritev(bs, qcow2_vm_state_offset(s) + pos, qiov);
- bs->zero_beyond_eof = zero_beyond_eof;
-
- /* bdrv_co_do_writev will have increased the total_sectors value to include
- * the VM state - the VM state is however not an actual part of the block
- * device, therefore, we need to restore the old value. */
- bs->total_sectors = total_sectors;
-
- return ret;
+ return bs->drv->bdrv_co_pwritev(bs, qcow2_vm_state_offset(s) + pos,
+ qiov->size, qiov, 0);
}
static int qcow2_load_vmstate(BlockDriverState *bs, QEMUIOVector *qiov,
int64_t pos)
{
BDRVQcow2State *s = bs->opaque;
- bool zero_beyond_eof = bs->zero_beyond_eof;
- int ret;
BLKDBG_EVENT(bs->file, BLKDBG_VMSTATE_LOAD);
- bs->zero_beyond_eof = false;
- ret = bdrv_preadv(bs, qcow2_vm_state_offset(s) + pos, qiov);
- bs->zero_beyond_eof = zero_beyond_eof;
-
- return ret;
+ return bs->drv->bdrv_co_preadv(bs, qcow2_vm_state_offset(s) + pos,
+ qiov->size, qiov, 0);
}
/*
--
1.8.3.1
- [Qemu-devel] [PULL 20/39] doc: Fix mailing list address in tests/qemu-iotests/README, (continued)
- [Qemu-devel] [PULL 20/39] doc: Fix mailing list address in tests/qemu-iotests/README, Kevin Wolf, 2016/06/16
- [Qemu-devel] [PULL 16/39] raw-posix: Switch to bdrv_co_* interfaces, Kevin Wolf, 2016/06/16
- [Qemu-devel] [PULL 18/39] block: Don't enforce 512 byte minimum alignment, Kevin Wolf, 2016/06/16
- [Qemu-devel] [PULL 21/39] block: Introduce bdrv_preadv(), Kevin Wolf, 2016/06/16
- [Qemu-devel] [PULL 24/39] block: Make bdrv_load/save_vmstate coroutine_fns, Kevin Wolf, 2016/06/16
- [Qemu-devel] [PULL 17/39] raw-posix: Implement .bdrv_co_preadv/pwritev, Kevin Wolf, 2016/06/16
- [Qemu-devel] [PULL 23/39] block: Allow .bdrv_load/save_vmstate() to return 0/-errno, Kevin Wolf, 2016/06/16
- [Qemu-devel] [PULL 30/39] block: Prevent sleeping jobs from resuming if they have been paused, Kevin Wolf, 2016/06/16
- [Qemu-devel] [PULL 22/39] block: Make .bdrv_load_vmstate() vectored, Kevin Wolf, 2016/06/16
- [Qemu-devel] [PULL 29/39] block: use the block job list in qmp_query_block_jobs(), Kevin Wolf, 2016/06/16
- [Qemu-devel] [PULL 25/39] qcow2: Let vmstate call qcow2_co_preadv/pwrite directly,
Kevin Wolf <=
- [Qemu-devel] [PULL 27/39] block: Fix snapshot=on with aio=native, Kevin Wolf, 2016/06/16
- [Qemu-devel] [PULL 28/39] block: use the block job list in bdrv_drain_all(), Kevin Wolf, 2016/06/16
- [Qemu-devel] [PULL 26/39] block: Remove bs->zero_beyond_eof, Kevin Wolf, 2016/06/16
- [Qemu-devel] [PULL 31/39] block: Create the commit block job before reopening any image, Kevin Wolf, 2016/06/16
- [Qemu-devel] [PULL 34/39] block: Allow replacement of a BDS by its overlay, Kevin Wolf, 2016/06/16
- [Qemu-devel] [PULL 37/39] iotests: Add test for post-mirror backing chains, Kevin Wolf, 2016/06/16
- [Qemu-devel] [PULL 36/39] block/null: Implement bdrv_refresh_filename(), Kevin Wolf, 2016/06/16
- [Qemu-devel] [PULL 32/39] iotests: 095: Clean up QEMU before showing image info, Kevin Wolf, 2016/06/16
- [Qemu-devel] [PULL 35/39] block/mirror: Fix target backing BDS, Kevin Wolf, 2016/06/16
- [Qemu-devel] [PULL 38/39] iotests: Add test for oVirt-like storage migration, Kevin Wolf, 2016/06/16