Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Leap:15.5:Update
qemu.35260
block-coroutine-wrapper.py-support-also-.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File block-coroutine-wrapper.py-support-also-.patch of Package qemu.35260
From: Dario Faggioli <dfaggioli@suse.com> Date: Thu, 1 Jun 2023 16:21:03 +0200 Subject: block-coroutine-wrapper.py: support also basic return types Extend the regex to cover also return type, pointers included. This implies that the value returned by the function cannot be a simple "int" anymore, but the custom return type. Therefore remove poll_state->ret and instead use a per-function custom "ret" field. Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru> Message-Id: <20221128142337.657646-13-eesposit@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com> Git-commit: 6700dfb1b8c2828aa0c851136892c4774de87c95 References: bsc#1211000 Signed-off-by: Joao Silva <joao.silva@suse.com> Signed-off-by: Dario Faggioli <dfaggioli@suse.com> --- block/block-gen.h | 5 +---- scripts/block-coroutine-wrapper.py | 14 ++++++++------ 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/block/block-gen.h b/block/block-gen.h index f80cf4897d115fdbbef9b5128b80..8ac9d5bd4fe78b1a72135818d682 100644 --- a/block/block-gen.h +++ b/block/block-gen.h @@ -32,18 +32,15 @@ typedef struct BdrvPollCo { BlockDriverState *bs; bool in_progress; - int ret; Coroutine *co; /* Keep pointer here for debugging */ } BdrvPollCo; -static inline int bdrv_poll_co(BdrvPollCo *s) +static inline void bdrv_poll_co(BdrvPollCo *s) { assert(!qemu_in_coroutine()); bdrv_coroutine_enter(s->bs, s->co); BDRV_POLL_WHILE(s->bs, s->in_progress); - - return s->ret; } #endif /* BLOCK_BLOCK_GEN_H */ diff --git a/scripts/block-coroutine-wrapper.py b/scripts/block-coroutine-wrapper.py index 0461fd1c459cf2df41db093d5ac0..f70a59b7ad6647294e25f0c7e3f6 100644 --- a/scripts/block-coroutine-wrapper.py +++ b/scripts/block-coroutine-wrapper.py @@ -75,14 +75,15 @@ class FuncDecl: # Match wrappers declared with a generated_co_wrapper mark -func_decl_re = re.compile(r'^int\s*generated_co_wrapper\s*' +func_decl_re = re.compile(r'^(?P<return_type>[a-zA-Z][a-zA-Z0-9_]* [\*]?)' + r'\s*generated_co_wrapper\s*' r'(?P<wrapper_name>[a-z][a-z0-9_]*)' r'\((?P<args>[^)]*)\);$', re.MULTILINE) def func_decl_iter(text: str) -> Iterator: for m in func_decl_re.finditer(text): - yield FuncDecl(return_type='int', + yield FuncDecl(return_type=m.group('return_type'), name=m.group('wrapper_name'), args=m.group('args')) @@ -100,7 +101,6 @@ 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 func.return_type == 'int' assert func.args[0].type in ['BlockDriverState *', 'BdrvChild *'] name = 'bdrv_co_' + func.name[5:] @@ -114,6 +114,7 @@ def gen_wrapper(func: FuncDecl) -> str: typedef struct {struct_name} {{ BdrvPollCo poll_state; + {func.return_type} ret; { func.gen_block(' {decl};') } }} {struct_name}; @@ -121,13 +122,13 @@ static void coroutine_fn {name}_entry(void *opaque) {{ {struct_name} *s = opaque; - s->poll_state.ret = {name}({ func.gen_list('s->{name}') }); + s->ret = {name}({ func.gen_list('s->{name}') }); s->poll_state.in_progress = false; aio_wait_kick(); }} -int {func.name}({ func.gen_list('{decl}') }) +{func.return_type} {func.name}({ func.gen_list('{decl}') }) {{ if (qemu_in_coroutine()) {{ return {name}({ func.gen_list('{name}') }); @@ -141,7 +142,8 @@ int {func.name}({ func.gen_list('{decl}') }) s.poll_state.co = qemu_coroutine_create({name}_entry, &s); - return bdrv_poll_co(&s.poll_state); + bdrv_poll_co(&s.poll_state); + return s.ret; }} }}"""
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor