diff mbox series

[v5,11/15] block-coroutine-wrapper.py: default to main loop aiocontext if function does not have a BlockDriverState parameter

Message ID 20221123114227.85757-12-eesposit@redhat.com (mailing list archive)
State New, archived
Headers show
Series Still more coroutine and various fixes in block layer | expand

Commit Message

Emanuele Giuseppe Esposito Nov. 23, 2022, 11:42 a.m. UTC
Basically BdrvPollCo->bs is only used by bdrv_poll_co(), and the
functions that it uses are both using bdrv_get_aio_context, that
defaults to qemu_get_aio_context() if bs is NULL.

Therefore pass NULL to BdrvPollCo to automatically generate a function
that create and runs a coroutine in the main loop.

Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
---
 scripts/block-coroutine-wrapper.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/scripts/block-coroutine-wrapper.py b/scripts/block-coroutine-wrapper.py
index 2fa3d01898..7e8f2da84b 100644
--- a/scripts/block-coroutine-wrapper.py
+++ b/scripts/block-coroutine-wrapper.py
@@ -81,8 +81,10 @@  def __init__(self, return_type: str, name: str, args: str,
             bs = 'bs'
         elif t == 'BdrvChild *':
             bs = 'child->bs'
-        else:
+        elif t == 'BlockBackend *':
             bs = 'blk_bs(blk)'
+        else:
+            bs = 'NULL'
         self.bs = bs
 
     def gen_list(self, format: str) -> str:
@@ -165,8 +167,6 @@  def create_coroutine_only(func: FuncDecl) -> 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 *',
-                                 'BlockBackend *']
 
     name = func.co_name
     struct_name = func.struct_name