From: Vladimir Sementsov-Ogievskiy Date: Thu, 10 Jun 2021 10:07:57 +0000 (+0300) Subject: block-coroutine-wrapper: allow non bdrv_ prefix X-Git-Tag: v6.1.0-rc0~68^2~5 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=bb43694872c344e27d498c0980c50c7effcb448a;p=thirdparty%2Fqemu.git block-coroutine-wrapper: allow non bdrv_ prefix We are going to reuse the script to generate a nbd_ function in further commit. Prepare the script now. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Eric Blake Message-Id: <20210610100802.5888-28-vsementsov@virtuozzo.com> Signed-off-by: Eric Blake --- diff --git a/scripts/block-coroutine-wrapper.py b/scripts/block-coroutine-wrapper.py index 0461fd1c459..85dbeb9ecf9 100644 --- a/scripts/block-coroutine-wrapper.py +++ b/scripts/block-coroutine-wrapper.py @@ -98,12 +98,13 @@ def snake_to_camel(func_name: str) -> str: def gen_wrapper(func: FuncDecl) -> str: - assert func.name.startswith('bdrv_') - assert not func.name.startswith('bdrv_co_') + assert not '_co_' in func.name assert func.return_type == 'int' assert func.args[0].type in ['BlockDriverState *', 'BdrvChild *'] - name = 'bdrv_co_' + func.name[5:] + subsystem, subname = func.name.split('_', 1) + + name = f'{subsystem}_co_{subname}' bs = 'bs' if func.args[0].type == 'BlockDriverState *' else 'child->bs' struct_name = snake_to_camel(name)