qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PULL 07/23] block: Introduce .bdrv_co_ioctl() driver callb


From: Kevin Wolf
Subject: [Qemu-devel] [PULL 07/23] block: Introduce .bdrv_co_ioctl() driver callback
Date: Thu, 27 Oct 2016 20:08:51 +0200

This allows drivers to implement ioctls in a coroutine-based way.

Signed-off-by: Kevin Wolf <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
---
 block/io.c                | 16 ++++++++++------
 include/block/block_int.h |  2 ++
 2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/block/io.c b/block/io.c
index 35fdcca..370c7d8 100644
--- a/block/io.c
+++ b/block/io.c
@@ -2502,17 +2502,21 @@ int bdrv_co_ioctl(BlockDriverState *bs, int req, void 
*buf)
     BlockAIOCB *acb;
 
     tracked_request_begin(&tracked_req, bs, 0, 0, BDRV_TRACKED_IOCTL);
-    if (!drv || !drv->bdrv_aio_ioctl) {
+    if (!drv || (!drv->bdrv_aio_ioctl && !drv->bdrv_co_ioctl)) {
         co.ret = -ENOTSUP;
         goto out;
     }
 
-    acb = drv->bdrv_aio_ioctl(bs, req, buf, bdrv_co_io_em_complete, &co);
-    if (!acb) {
-        co.ret = -ENOTSUP;
-        goto out;
+    if (drv->bdrv_co_ioctl) {
+        co.ret = drv->bdrv_co_ioctl(bs, req, buf);
+    } else {
+        acb = drv->bdrv_aio_ioctl(bs, req, buf, bdrv_co_io_em_complete, &co);
+        if (!acb) {
+            co.ret = -ENOTSUP;
+            goto out;
+        }
+        qemu_coroutine_yield();
     }
-    qemu_coroutine_yield();
 out:
     tracked_request_end(&tracked_req);
     return co.ret;
diff --git a/include/block/block_int.h b/include/block/block_int.h
index 3e79228..e96e9ad 100644
--- a/include/block/block_int.h
+++ b/include/block/block_int.h
@@ -244,6 +244,8 @@ struct BlockDriver {
     BlockAIOCB *(*bdrv_aio_ioctl)(BlockDriverState *bs,
         unsigned long int req, void *buf,
         BlockCompletionFunc *cb, void *opaque);
+    int coroutine_fn (*bdrv_co_ioctl)(BlockDriverState *bs,
+                                      unsigned long int req, void *buf);
 
     /* List of options for creating images, terminated by name == NULL */
     QemuOptsList *create_opts;
-- 
1.8.3.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]