From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60154) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yn5YY-000336-MP for qemu-devel@nongnu.org; Tue, 28 Apr 2015 09:28:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Yn5YX-0006EK-BB for qemu-devel@nongnu.org; Tue, 28 Apr 2015 09:28:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:32804) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yn5YX-0006Dr-5a for qemu-devel@nongnu.org; Tue, 28 Apr 2015 09:28:09 -0400 From: Stefan Hajnoczi Date: Tue, 28 Apr 2015 14:27:51 +0100 Message-Id: <1430227672-7670-4-git-send-email-stefanha@redhat.com> In-Reply-To: <1430227672-7670-1-git-send-email-stefanha@redhat.com> References: <1430227672-7670-1-git-send-email-stefanha@redhat.com> Subject: [Qemu-devel] [PATCH v4 3/4] block: extract bdrv_setup_io_funcs() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , Alberto Garcia , Stefan Hajnoczi Move the code to install coroutine and aio emulation function pointers in a BlockDriver to its own function. Signed-off-by: Stefan Hajnoczi --- block.c | 7 ++++++- include/block/block_int.h | 8 ++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/block.c b/block.c index 3b865ee..954d783 100644 --- a/block.c +++ b/block.c @@ -349,7 +349,7 @@ void bdrv_get_full_backing_filename(BlockDriverState *bs, char *dest, size_t sz, dest, sz, errp); } -void bdrv_register(BlockDriver *bdrv) +void bdrv_setup_io_funcs(BlockDriver *bdrv) { /* Block drivers without coroutine functions need emulation */ if (!bdrv->bdrv_co_readv) { @@ -365,6 +365,11 @@ void bdrv_register(BlockDriver *bdrv) bdrv->bdrv_aio_writev = bdrv_aio_writev_em; } } +} + +void bdrv_register(BlockDriver *bdrv) +{ + bdrv_setup_io_funcs(bdrv); QLIST_INSERT_HEAD(&bdrv_drivers, bdrv, list); } diff --git a/include/block/block_int.h b/include/block/block_int.h index 5ad20b2..db29b74 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -439,6 +439,14 @@ extern BlockDriver bdrv_file; extern BlockDriver bdrv_raw; extern BlockDriver bdrv_qcow2; +/** + * bdrv_setup_io_funcs: + * + * Prepare a #BlockDriver for I/O request processing by populating + * unimplemented coroutine and AIO interfaces with generic wrapper functions + * that fall back to implemented interfaces. + */ +void bdrv_setup_io_funcs(BlockDriver *bdrv); int get_tmp_filename(char *filename, int size); BlockDriver *bdrv_probe_all(const uint8_t *buf, int buf_size, -- 2.1.0