block: extract bdrv_setup_io_funcs()
authorStefan Hajnoczi <stefanha@redhat.com>
Tue, 28 Apr 2015 13:27:51 +0000 (14:27 +0100)
committerKevin Wolf <kwolf@redhat.com>
Tue, 28 Apr 2015 13:36:17 +0000 (15:36 +0200)
Move the code to install coroutine and aio emulation function pointers
in a BlockDriver to its own function.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block.c
include/block/block_int.h

diff --git a/block.c b/block.c
index 3b865ee123f4148e578ca37f2a9ccb0604a6bb83..954d78392c0afdb0decc6351869807c99925254c 100644 (file)
--- 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);
 }
index 5ad20b2e10ceed04d8d2f770accdafc1e2fe8947..db29b7424e1343a25f63232cdb0614ccf0f152a2 100644 (file)
@@ -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,