From: Pavel Butsykin <address@hidden>
This patch just adds the interface to the bdrv_co_pwritev_compressed,
which is currently not used but will be useful for safe implementation of the
bdrv_co_write_compressed callback in format drivers.
Signed-off-by: Pavel Butsykin <address@hidden>
Signed-off-by: Denis V. Lunev <address@hidden>
CC: Jeff Cody <address@hidden>
CC: Markus Armbruster <address@hidden>
CC: Eric Blake <address@hidden>
CC: John Snow <address@hidden>
CC: Stefan Hajnoczi <address@hidden>
CC: Kevin Wolf <address@hidden>
---
block/io.c | 78 +++++++++++++++++++++++++++++++++++++++++++----
include/block/block_int.h | 5 +++
qemu-img.c | 2 +-
3 files changed, 78 insertions(+), 7 deletions(-)
diff --git a/block/io.c b/block/io.c
index c5bb6ae..54cd9a4 100644
--- a/block/io.c
+++ b/block/io.c
@@ -1779,8 +1779,8 @@ int bdrv_is_allocated_above(BlockDriverState *top,
return 0;
}
-int bdrv_pwrite_compressed(BlockDriverState *bs, int64_t offset,
- const void *buf, int count)
+int coroutine_fn bdrv_co_pwritev_compressed(BlockDriverState *bs,
+ int64_t offset, unsigned int bytes, QEMUIOVector *qiov)
{
BlockDriver *drv = bs->drv;
int ret;
@@ -1788,18 +1788,84 @@ int bdrv_pwrite_compressed(BlockDriverState *bs,
int64_t offset,
if (!drv) {
return -ENOMEDIUM;
}
- if (!drv->bdrv_write_compressed) {
+
+ if (!drv->bdrv_co_write_compressed) {
return -ENOTSUP;
}
- ret = bdrv_check_byte_request(bs, offset, count);
+
+ ret = bdrv_check_byte_request(bs, offset, bytes);
if (ret < 0) {
return ret;
}
assert(QLIST_EMPTY(&bs->dirty_bitmaps));
+ assert(qemu_in_coroutine());
+
+ return drv->bdrv_co_write_compressed(bs, offset >> BDRV_SECTOR_BITS,
+ bytes >> BDRV_SECTOR_BITS, qiov);
+}
+
+typedef struct BdrvWriteCompressedCo {
+ BlockDriverState *bs;
+ int64_t offset;
+ QEMUIOVector *qiov;
+ int ret;
+} BdrvWriteCompressedCo;