From: Kevin Wolf Date: Thu, 9 Jun 2016 14:36:00 +0000 (+0200) Subject: block: Introduce bdrv_preadv() X-Git-Tag: TizenStudio_2.0_p4.0~6^2~12^2~6^2~200^2~7 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f1e8474115d6be7eda14092050ffa2b031afb729;p=sdk%2Femulator%2Fqemu.git block: Introduce bdrv_preadv() We already have a byte-based bdrv_pwritev(), but the read counterpart was still missing. This commit adds it. Signed-off-by: Kevin Wolf Reviewed-by: Fam Zheng Reviewed-by: Eric Blake Reviewed-by: Stefan Hajnoczi --- diff --git a/block/io.c b/block/io.c index b3ff9be..72d7210 100644 --- a/block/io.c +++ b/block/io.c @@ -700,6 +700,18 @@ int bdrv_make_zero(BlockDriverState *bs, BdrvRequestFlags flags) } } +int bdrv_preadv(BlockDriverState *bs, int64_t offset, QEMUIOVector *qiov) +{ + int ret; + + ret = bdrv_prwv_co(bs, offset, qiov, false, 0); + if (ret < 0) { + return ret; + } + + return qiov->size; +} + int bdrv_pread(BlockDriverState *bs, int64_t offset, void *buf, int bytes) { QEMUIOVector qiov; @@ -707,19 +719,13 @@ int bdrv_pread(BlockDriverState *bs, int64_t offset, void *buf, int bytes) .iov_base = (void *)buf, .iov_len = bytes, }; - int ret; if (bytes < 0) { return -EINVAL; } qemu_iovec_init_external(&qiov, &iov, 1); - ret = bdrv_prwv_co(bs, offset, &qiov, false, 0); - if (ret < 0) { - return ret; - } - - return bytes; + return bdrv_preadv(bs, offset, &qiov); } int bdrv_pwritev(BlockDriverState *bs, int64_t offset, QEMUIOVector *qiov) diff --git a/include/block/block.h b/include/block/block.h index 9c3a62c..9c63d07 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -235,6 +235,7 @@ int bdrv_pwrite_zeroes(BlockDriverState *bs, int64_t offset, int bdrv_make_zero(BlockDriverState *bs, BdrvRequestFlags flags); int bdrv_pread(BlockDriverState *bs, int64_t offset, void *buf, int count); +int bdrv_preadv(BlockDriverState *bs, int64_t offset, QEMUIOVector *qiov); int bdrv_pwrite(BlockDriverState *bs, int64_t offset, const void *buf, int count); int bdrv_pwritev(BlockDriverState *bs, int64_t offset, QEMUIOVector *qiov);