return ret;
}
+static int coroutine_fn
+bdrv_driver_pwritev_compressed(BlockDriverState *bs, uint64_t offset,
+ uint64_t bytes, QEMUIOVector *qiov)
+{
+ BlockDriver *drv = bs->drv;
+
+ if (!drv->bdrv_co_pwritev_compressed) {
+ return -ENOTSUP;
+ }
+
+ assert(QLIST_EMPTY(&bs->dirty_bitmaps));
+ return drv->bdrv_co_pwritev_compressed(bs, offset, bytes, qiov);
+}
+
static int coroutine_fn bdrv_co_do_copy_on_readv(BlockDriverState *bs,
int64_t offset, unsigned int bytes, QEMUIOVector *qiov)
{
bytes = ROUND_UP(bytes, align);
}
- ret = bdrv_aligned_pwritev(bs, &req, offset, bytes, align,
- use_local_qiov ? &local_qiov : qiov,
- flags);
+ if (flags & BDRV_REQ_WRITE_COMPRESSED) {
+ ret = bdrv_driver_pwritev_compressed(
+ bs, offset, bytes, use_local_qiov ? &local_qiov : qiov);
+ } else {
+ ret = bdrv_aligned_pwritev(bs, &req, offset, bytes, align,
+ use_local_qiov ? &local_qiov : qiov,
+ flags);
+ }
fail:
return 0;
}
-int bdrv_pwrite_compressed(BlockDriverState *bs, int64_t offset,
- const void *buf, int bytes)
-{
- BlockDriver *drv = bs->drv;
- int ret;
-
- if (!drv) {
- return -ENOMEDIUM;
- }
- if (!drv->bdrv_write_compressed) {
- return -ENOTSUP;
- }
- ret = bdrv_check_byte_request(bs, offset, bytes);
- if (ret < 0) {
- return ret;
- }
-
- assert(QLIST_EMPTY(&bs->dirty_bitmaps));
- assert((offset & (BDRV_SECTOR_SIZE - 1)) == 0);
- assert((bytes & (BDRV_SECTOR_SIZE - 1)) == 0);
-
- return drv->bdrv_write_compressed(bs, offset >> BDRV_SECTOR_BITS, buf,
- bytes >> BDRV_SECTOR_BITS);
-}
-
typedef struct BdrvVmstateCo {
BlockDriverState *bs;
QEMUIOVector *qiov;