Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
block-coroutine-wrapper: Allow arbitrary parameter names
Don't assume specific parameter names like 'bs' or 'blk' in the
generated code, but use the actual name.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-ID: <20230911094620.45040-8-kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
  • Loading branch information
Kevin Wolf committed Sep 20, 2023
1 parent de90329 commit d218434
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions scripts/block-coroutine-wrapper.py
Expand Up @@ -105,12 +105,13 @@ def __init__(self, wrapper_type: str, return_type: str, name: str,

def gen_ctx(self, prefix: str = '') -> str:
t = self.args[0].type
name = self.args[0].name
if t == 'BlockDriverState *':
return f'bdrv_get_aio_context({prefix}bs)'
return f'bdrv_get_aio_context({prefix}{name})'
elif t == 'BdrvChild *':
return f'bdrv_get_aio_context({prefix}child->bs)'
return f'bdrv_get_aio_context({prefix}{name}->bs)'
elif t == 'BlockBackend *':
return f'blk_get_aio_context({prefix}blk)'
return f'blk_get_aio_context({prefix}{name})'
else:
return 'qemu_get_aio_context()'

Expand Down

0 comments on commit d218434

Please sign in to comment.