From 65993736a094a249c2535b1bf398cbb9a40d97b5 Mon Sep 17 00:00:00 2001 From: Kevin Wolf Date: Tue, 14 Feb 2012 11:14:48 +0100 Subject: [PATCH 83/99] block: use coroutine interface for raw format RH-Author: Kevin Wolf Message-id: <1329218101-24213-84-git-send-email-kwolf@redhat.com> Patchwork-id: 37287 O-Subject: [RHEL-6.3 qemu-kvm PATCH v2 83/96] block: use coroutine interface for raw format Bugzilla: 783950 RH-Acked-by: Paolo Bonzini RH-Acked-by: Marcelo Tosatti RH-Acked-by: Laszlo Ersek From: Stefan Hajnoczi Bugzilla: 783950 The raw format delegates all operations to bs->file (the protocol). Previously this block driver exposed both sync and aio interfaces. Since the block layer now works in terms of coroutines, expose the coroutine interfaces and drop the others. This avoids unnecessary emulation of sync and aio interfaces. Signed-off-by: Stefan Hajnoczi Signed-off-by: Kevin Wolf (cherry picked from commit d8b7e0adf562277180f96ecbd7f1777a384a0308) --- block/raw.c | 32 ++++++++------------------------ 1 files changed, 8 insertions(+), 24 deletions(-) Signed-off-by: Michal Novotny --- block/raw.c | 32 ++++++++------------------------ 1 files changed, 8 insertions(+), 24 deletions(-) diff --git a/block/raw.c b/block/raw.c index 63cf2d3..5ca606b 100644 --- a/block/raw.c +++ b/block/raw.c @@ -9,30 +9,16 @@ static int raw_open(BlockDriverState *bs, int flags) return 0; } -static int raw_read(BlockDriverState *bs, int64_t sector_num, - uint8_t *buf, int nb_sectors) +static int coroutine_fn raw_co_readv(BlockDriverState *bs, int64_t sector_num, + int nb_sectors, QEMUIOVector *qiov) { - return bdrv_read(bs->file, sector_num, buf, nb_sectors); + return bdrv_co_readv(bs->file, sector_num, nb_sectors, qiov); } -static int raw_write(BlockDriverState *bs, int64_t sector_num, - const uint8_t *buf, int nb_sectors) +static int coroutine_fn raw_co_writev(BlockDriverState *bs, int64_t sector_num, + int nb_sectors, QEMUIOVector *qiov) { - return bdrv_write(bs->file, sector_num, buf, nb_sectors); -} - -static BlockDriverAIOCB *raw_aio_readv(BlockDriverState *bs, - int64_t sector_num, QEMUIOVector *qiov, int nb_sectors, - BlockDriverCompletionFunc *cb, void *opaque) -{ - return bdrv_aio_readv(bs->file, sector_num, qiov, nb_sectors, cb, opaque); -} - -static BlockDriverAIOCB *raw_aio_writev(BlockDriverState *bs, - int64_t sector_num, QEMUIOVector *qiov, int nb_sectors, - BlockDriverCompletionFunc *cb, void *opaque) -{ - return bdrv_aio_writev(bs->file, sector_num, qiov, nb_sectors, cb, opaque); + return bdrv_co_writev(bs->file, sector_num, nb_sectors, qiov); } static void raw_close(BlockDriverState *bs) @@ -129,15 +115,13 @@ static BlockDriver bdrv_raw = { .bdrv_open = raw_open, .bdrv_close = raw_close, - .bdrv_read = raw_read, - .bdrv_write = raw_write, + .bdrv_co_readv = raw_co_readv, + .bdrv_co_writev = raw_co_writev, .bdrv_flush = raw_flush, .bdrv_probe = raw_probe, .bdrv_getlength = raw_getlength, .bdrv_truncate = raw_truncate, - .bdrv_aio_readv = raw_aio_readv, - .bdrv_aio_writev = raw_aio_writev, .bdrv_aio_flush = raw_aio_flush, .bdrv_discard = raw_discard, -- 1.7.7.5