[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 22/39] block: Make .bdrv_load_vmstate() vectored
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 22/39] block: Make .bdrv_load_vmstate() vectored |
Date: |
Thu, 16 Jun 2016 16:08:11 +0200 |
This brings it in line with .bdrv_save_vmstate().
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/io.c | 25 ++++++++++++++++++++-----
block/qcow2.c | 6 +++---
block/sheepdog.c | 13 ++++++++++---
include/block/block.h | 1 +
include/block/block_int.h | 4 ++--
5 files changed, 36 insertions(+), 13 deletions(-)
diff --git a/block/io.c b/block/io.c
index 72d7210..aac9b67 100644
--- a/block/io.c
+++ b/block/io.c
@@ -1871,13 +1871,28 @@ int bdrv_writev_vmstate(BlockDriverState *bs,
QEMUIOVector *qiov, int64_t pos)
int bdrv_load_vmstate(BlockDriverState *bs, uint8_t *buf,
int64_t pos, int size)
{
+ QEMUIOVector qiov;
+ struct iovec iov = {
+ .iov_base = buf,
+ .iov_len = size,
+ };
+
+ qemu_iovec_init_external(&qiov, &iov, 1);
+ return bdrv_readv_vmstate(bs, &qiov, pos);
+}
+
+int bdrv_readv_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, int64_t pos)
+{
BlockDriver *drv = bs->drv;
- if (!drv)
+
+ if (!drv) {
return -ENOMEDIUM;
- if (drv->bdrv_load_vmstate)
- return drv->bdrv_load_vmstate(bs, buf, pos, size);
- if (bs->file)
- return bdrv_load_vmstate(bs->file->bs, buf, pos, size);
+ } else if (drv->bdrv_load_vmstate) {
+ return drv->bdrv_load_vmstate(bs, qiov, pos);
+ } else if (bs->file) {
+ return bdrv_readv_vmstate(bs->file->bs, qiov, pos);
+ }
+
return -ENOTSUP;
}
diff --git a/block/qcow2.c b/block/qcow2.c
index 9de716a..362ada2 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -2926,8 +2926,8 @@ static int qcow2_save_vmstate(BlockDriverState *bs,
QEMUIOVector *qiov,
return ret;
}
-static int qcow2_load_vmstate(BlockDriverState *bs, uint8_t *buf,
- int64_t pos, int size)
+static int qcow2_load_vmstate(BlockDriverState *bs, QEMUIOVector *qiov,
+ int64_t pos)
{
BDRVQcow2State *s = bs->opaque;
bool zero_beyond_eof = bs->zero_beyond_eof;
@@ -2935,7 +2935,7 @@ static int qcow2_load_vmstate(BlockDriverState *bs,
uint8_t *buf,
BLKDBG_EVENT(bs->file, BLKDBG_VMSTATE_LOAD);
bs->zero_beyond_eof = false;
- ret = bdrv_pread(bs, qcow2_vm_state_offset(s) + pos, buf, size);
+ ret = bdrv_preadv(bs, qcow2_vm_state_offset(s) + pos, qiov);
bs->zero_beyond_eof = zero_beyond_eof;
return ret;
diff --git a/block/sheepdog.c b/block/sheepdog.c
index 23fbace..ef5d044 100644
--- a/block/sheepdog.c
+++ b/block/sheepdog.c
@@ -2784,12 +2784,19 @@ static int sd_save_vmstate(BlockDriverState *bs,
QEMUIOVector *qiov,
return ret;
}
-static int sd_load_vmstate(BlockDriverState *bs, uint8_t *data,
- int64_t pos, int size)
+static int sd_load_vmstate(BlockDriverState *bs, QEMUIOVector *qiov,
+ int64_t pos)
{
BDRVSheepdogState *s = bs->opaque;
+ void *buf;
+ int ret;
- return do_load_save_vmstate(s, data, pos, size, 1);
+ buf = qemu_blockalign(bs, qiov->size);
+ ret = do_load_save_vmstate(s, buf, pos, qiov->size, 1);
+ qemu_iovec_from_buf(qiov, 0, buf, qiov->size);
+ qemu_vfree(buf);
+
+ return ret;
}
diff --git a/include/block/block.h b/include/block/block.h
index 9c63d07..733a8ec 100644
--- a/include/block/block.h
+++ b/include/block/block.h
@@ -431,6 +431,7 @@ void path_combine(char *dest, int dest_size,
const char *base_path,
const char *filename);
+int bdrv_readv_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, int64_t pos);
int bdrv_writev_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, int64_t pos);
int bdrv_save_vmstate(BlockDriverState *bs, const uint8_t *buf,
int64_t pos, int size);
diff --git a/include/block/block_int.h b/include/block/block_int.h
index 8a4963c..f9a32cc 100644
--- a/include/block/block_int.h
+++ b/include/block/block_int.h
@@ -226,8 +226,8 @@ struct BlockDriver {
int (*bdrv_save_vmstate)(BlockDriverState *bs, QEMUIOVector *qiov,
int64_t pos);
- int (*bdrv_load_vmstate)(BlockDriverState *bs, uint8_t *buf,
- int64_t pos, int size);
+ int (*bdrv_load_vmstate)(BlockDriverState *bs, QEMUIOVector *qiov,
+ int64_t pos);
int (*bdrv_change_backing_file)(BlockDriverState *bs,
const char *backing_file, const char *backing_fmt);
--
1.8.3.1
- [Qemu-devel] [PULL 13/39] block: Byte-based bdrv_co_do_copy_on_readv(), (continued)
- [Qemu-devel] [PULL 13/39] block: Byte-based bdrv_co_do_copy_on_readv(), Kevin Wolf, 2016/06/16
- [Qemu-devel] [PULL 19/39] linux-aio: Cancel BH if not needed, Kevin Wolf, 2016/06/16
- [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 <=
- [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, 2016/06/16
- [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