diff mbox series

[06/12] block-coroutine-wrapper.py: support BlockBackend first argument

Message ID 20211006131718.214235-7-vsementsov@virtuozzo.com (mailing list archive)
State New, archived
Headers show
Series block: 64bit blk io | expand

Commit Message

Vladimir Sementsov-Ogievskiy Oct. 6, 2021, 1:17 p.m. UTC
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 block/coroutines.h                 |  3 +++
 scripts/block-coroutine-wrapper.py | 12 ++++++++++--
 2 files changed, 13 insertions(+), 2 deletions(-)

Comments

Eric Blake Oct. 6, 2021, 4:17 p.m. UTC | #1
On Wed, Oct 06, 2021 at 03:17:12PM +0200, Vladimir Sementsov-Ogievskiy wrote:
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---
>  block/coroutines.h                 |  3 +++
>  scripts/block-coroutine-wrapper.py | 12 ++++++++++--
>  2 files changed, 13 insertions(+), 2 deletions(-)
>

Reviewed-by: Eric Blake <eblake@redhat.com>
diff mbox series

Patch

diff --git a/block/coroutines.h b/block/coroutines.h
index 514d169d23..35a6c49857 100644
--- a/block/coroutines.h
+++ b/block/coroutines.h
@@ -27,6 +27,9 @@ 
 
 #include "block/block_int.h"
 
+/* For blk_bs() in generated block/block-gen.c */
+#include "sysemu/block-backend.h"
+
 int coroutine_fn bdrv_co_check(BlockDriverState *bs,
                                BdrvCheckResult *res, BdrvCheckMode fix);
 int coroutine_fn bdrv_co_invalidate_cache(BlockDriverState *bs, Error **errp);
diff --git a/scripts/block-coroutine-wrapper.py b/scripts/block-coroutine-wrapper.py
index 85dbeb9ecf..08be813407 100644
--- a/scripts/block-coroutine-wrapper.py
+++ b/scripts/block-coroutine-wrapper.py
@@ -100,12 +100,20 @@  def snake_to_camel(func_name: str) -> str:
 def gen_wrapper(func: FuncDecl) -> str:
     assert not '_co_' in func.name
     assert func.return_type == 'int'
-    assert func.args[0].type in ['BlockDriverState *', 'BdrvChild *']
+    assert func.args[0].type in ['BlockDriverState *', 'BdrvChild *',
+                                 'BlockBackend *']
 
     subsystem, subname = func.name.split('_', 1)
 
     name = f'{subsystem}_co_{subname}'
-    bs = 'bs' if func.args[0].type == 'BlockDriverState *' else 'child->bs'
+
+    t = func.args[0].type
+    if t == 'BlockDriverState *':
+        bs = 'bs'
+    elif t == 'BdrvChild *':
+        bs = 'child->bs'
+    else:
+        bs = 'blk_bs(blk)'
     struct_name = snake_to_camel(name)
 
     return f"""\