[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 06/12] block-coroutine-wrapper.py: support BlockBackend first arg
From: |
Vladimir Sementsov-Ogievskiy |
Subject: |
[PATCH 06/12] block-coroutine-wrapper.py: support BlockBackend first argument |
Date: |
Wed, 6 Oct 2021 15:17:12 +0200 |
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(-)
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"""\
--
2.31.1
- [PATCH 03/12] block-backend: convert blk_co_pwritev_part to int64_t bytes, (continued)
- [PATCH 03/12] block-backend: convert blk_co_pwritev_part to int64_t bytes, Vladimir Sementsov-Ogievskiy, 2021/10/06
- [PATCH 02/12] block-backend: make blk_co_preadv() 64bit, Vladimir Sementsov-Ogievskiy, 2021/10/06
- [PATCH 04/12] block-backend: convert blk_co_pdiscard to int64_t bytes, Vladimir Sementsov-Ogievskiy, 2021/10/06
- [PATCH 12/12] block-backend: drop INT_MAX restriction from blk_check_byte_request(), Vladimir Sementsov-Ogievskiy, 2021/10/06
- [PATCH 05/12] block-backend: rename _do_ helper functions to _co_do_, Vladimir Sementsov-Ogievskiy, 2021/10/06
- [PATCH 06/12] block-coroutine-wrapper.py: support BlockBackend first argument,
Vladimir Sementsov-Ogievskiy <=
- [PATCH 08/12] block-backend: convert blk_foo wrappers to use int64_t bytes parameter, Vladimir Sementsov-Ogievskiy, 2021/10/06
- [PATCH 07/12] block-backend: drop blk_prw, use block-coroutine-wrapper, Vladimir Sementsov-Ogievskiy, 2021/10/06
- [PATCH 09/12] block-backend: convert blk_co_copy_range to int64_t bytes, Vladimir Sementsov-Ogievskiy, 2021/10/06
- [PATCH 13/12] block-backend: fix blk_co_flush prototype to mention coroutine_fn, Vladimir Sementsov-Ogievskiy, 2021/10/07
- [PATCH 14/12] block-backend: update blk_co_pwrite() and blk_co_pread() wrappers, Vladimir Sementsov-Ogievskiy, 2021/10/07