Re: [PATCH 19/21] block: Mark bdrv_root_unref_child() GRAPH_WRLOCK

2023-08-21 Thread Emanuele Giuseppe Esposito
y can't call functions that take it > internally. > > Signed-off-by: Kevin Wolf Reviewed-by: Emanuele Giuseppe Esposito

Re: [PATCH 20/21] block: Mark bdrv_unref_child() GRAPH_WRLOCK

2023-08-21 Thread Emanuele Giuseppe Esposito
y can't call functions that take it internally. > > Signed-off-by: Kevin Wolf Reviewed-by: Emanuele Giuseppe Esposito

Re: [PATCH 21/21] block: Mark bdrv_add/del_child() and caller GRAPH_WRLOCK

2023-08-21 Thread Emanuele Giuseppe Esposito
in Wolf Reviewed-by: Emanuele Giuseppe Esposito

Re: [PATCH 09/21] block: Mark bdrv_replace_child_tran() GRAPH_WRLOCK

2023-08-21 Thread Emanuele Giuseppe Esposito
s, the transaction > callbacks can be changed, too. > > Signed-off-by: Kevin Wolf Reviewed-by: Emanuele Giuseppe Esposito

Re: [PATCH 16/21] block: Mark bdrv_parent_cb_change_media() GRAPH_RDLOCK

2023-08-21 Thread Emanuele Giuseppe Esposito
Am 17/08/2023 um 14:50 schrieb Kevin Wolf: > The function reads the parents list, so it needs to hold the graph lock. > > Signed-off-by: Kevin Wolf Reviewed-by: Emanuele Giuseppe Esposito

Re: [PATCH 17/21] block: Take graph rdlock in bdrv_drop_intermediate()

2023-08-21 Thread Emanuele Giuseppe Esposito
Am 17/08/2023 um 14:50 schrieb Kevin Wolf: > The function reads the parents list, so it needs to hold the graph lock. > > Signed-off-by: Kevin Wolf Reviewed-by: Emanuele Giuseppe Esposito

Re: [PATCH 13/21] block: Mark bdrv_parent_perms_conflict() and callers GRAPH_RDLOCK

2023-08-21 Thread Emanuele Giuseppe Esposito
Am 17/08/2023 um 14:50 schrieb Kevin Wolf: > The function reads the parents list, so it needs to hold the graph lock. > > Signed-off-by: Kevin Wolf Reviewed-by: Emanuele Giuseppe Esposito

Re: [PATCH 07/21] block-coroutine-wrapper: Allow arbitrary parameter names

2023-08-21 Thread Emanuele Giuseppe Esposito
Am 17/08/2023 um 14:50 schrieb Kevin Wolf: > Don't assume specific parameter names like 'bs' or 'blk' in the > generated code, but use the actual name. > > Signed-off-by: Kevin Wolf Reviewed-by: Emanuele Giuseppe Esposito

Re: [PATCH 14/21] block: Mark bdrv_get_cumulative_perm() and callers GRAPH_RDLOCK

2023-08-21 Thread Emanuele Giuseppe Esposito
r callbacks for updating permissions and annotate the function > pointers with GRAPH_RDLOCK_PTR. > > Signed-off-by: Kevin Wolf Reviewed-by: Emanuele Giuseppe Esposito

Re: [PATCH 08/21] block: Mark bdrv_replace_child_noperm() GRAPH_WRLOCK

2023-08-21 Thread Emanuele Giuseppe Esposito
t they can't call functions that take it > internally. > > Signed-off-by: Kevin Wolf Reviewed-by: Emanuele Giuseppe Esposito

Re: [PATCH 04/21] block: Take AioContext lock for bdrv_append() more consistently

2023-08-21 Thread Emanuele Giuseppe Esposito
Am 17/08/2023 um 14:50 schrieb Kevin Wolf: > The documentation for bdrv_append() says that the caller must hold the > AioContext lock for bs_top. Change all callers to actually adhere to the > contract. > > Signed-off-by: Kevin Wolf Reviewed-by: Emanuele Giuseppe Esposito

Re: [PATCH 12/21] block: Mark bdrv_attach_child() GRAPH_WRLOCK

2023-08-21 Thread Emanuele Giuseppe Esposito
t they can't call functions that take it > internally. > > Signed-off-by: Kevin Wolf Reviewed-by: Emanuele Giuseppe Esposito

Re: [PATCH 18/21] block: Take graph rdlock in bdrv_change_aio_context()

2023-08-21 Thread Emanuele Giuseppe Esposito
Am 17/08/2023 um 14:50 schrieb Kevin Wolf: > The function reads the parents list, so it needs to hold the graph lock. > > Signed-off-by: Kevin Wolf Reviewed-by: Emanuele Giuseppe Esposito

Re: [PATCH 06/21] block-coroutine-wrapper: Add no_co_wrapper_bdrv_wrlock functions

2023-08-21 Thread Emanuele Giuseppe Esposito
Am 17/08/2023 um 14:50 schrieb Kevin Wolf: > Add a new wrapper type for GRAPH_WRLOCK functions that should be called > from coroutine context. > > Signed-off-by: Kevin Wolf Reviewed-by: Emanuele Giuseppe Esposito

Re: [PATCH 15/21] block: Mark bdrv_child_perm() GRAPH_RDLOCK

2023-08-21 Thread Emanuele Giuseppe Esposito
niently already hold the lock. > > Signed-off-by: Kevin Wolf Reviewed-by: Emanuele Giuseppe Esposito

Re: [PATCH 01/21] block: Remove unused BlockReopenQueueEntry.perms_checked

2023-08-21 Thread Emanuele Giuseppe Esposito
Am 17/08/2023 um 14:50 schrieb Kevin Wolf: > This field has been unused since commit 72373e40fbc ('block: > bdrv_reopen_multiple: refresh permissions on updated graph'). > Remove it. > > Signed-off-by: Kevin Wolf Reviewed-by: Emanuele Giuseppe Esposito

Re: [PATCH 02/21] preallocate: Factor out preallocate_truncate_to_real_size()

2023-08-21 Thread Emanuele Giuseppe Esposito
Am 17/08/2023 um 14:50 schrieb Kevin Wolf: > It's essentially the same code in preallocate_check_perm() and > preallocate_close(), except that the latter ignores errors. > > Signed-off-by: Kevin Wolf > --- Reviewed-by: Emanuele Giuseppe Esposito

Re: test-blockjob: intermittent CI failures in msys2-64bit job

2023-04-26 Thread Emanuele Giuseppe Esposito
Am 26/04/2023 um 10:03 schrieb Hanna Czenczek: > On 26.04.23 09:38, Emanuele Giuseppe Esposito wrote: >> >> Am 25/04/2023 um 18:48 schrieb Hanna Czenczek: >>> On 24.04.23 20:32, Vladimir Sementsov-Ogievskiy wrote: >>>> On 24.04.23 16:36, Emanuele Giuseppe

Re: test-blockjob: intermittent CI failures in msys2-64bit job

2023-04-26 Thread Emanuele Giuseppe Esposito
Am 25/04/2023 um 18:48 schrieb Hanna Czenczek: > On 24.04.23 20:32, Vladimir Sementsov-Ogievskiy wrote: >> On 24.04.23 16:36, Emanuele Giuseppe Esposito wrote: >>> >>> >>> Am 21/04/2023 um 12:13 schrieb Vladimir Sementsov-Ogievskiy: >>>> On 17.03.

Re: test-blockjob: intermittent CI failures in msys2-64bit job

2023-04-24 Thread Emanuele Giuseppe Esposito
Am 21/04/2023 um 12:13 schrieb Vladimir Sementsov-Ogievskiy: > On 17.03.23 15:35, Thomas Huth wrote: >> On 17/03/2023 11.17, Peter Maydell wrote: >>> On Mon, 6 Mar 2023 at 11:16, Peter Maydell >>> wrote: On Fri, 3 Mar 2023 at 18:36, Peter Maydell wrote: > > I've noticed

Re: [PATCH v2] block/monitor/block-hmp-cmds.c: Fix crash when execute hmp_commit

2023-04-24 Thread Emanuele Giuseppe Esposito
AIO_WAIT_WHILE(), > which crashes if the aio_context lock is not taken before. > > Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1615 > Signed-off-by: Wang Liang > Thanks! Reviewed-by: Emanuele Giuseppe Esposito

Re: [PATCH] block/monitor/block-hmp-cmds.c: Fix crash when execute hmp_commit

2023-04-24 Thread Emanuele Giuseppe Esposito
Am 24/04/2023 um 10:15 schrieb Emanuele Giuseppe Esposito: > > > Am 23/04/2023 um 13:02 schrieb wanglian...@126.com: >> From: Wang Liang >> >> We need to get the aio_context before calling the blk_is_available. >> >> Resolves: https://gitlab.com/qemu-p

Re: [PATCH] block/monitor/block-hmp-cmds.c: Fix crash when execute hmp_commit

2023-04-24 Thread Emanuele Giuseppe Esposito
Am 23/04/2023 um 13:02 schrieb wanglian...@126.com: > From: Wang Liang > > We need to get the aio_context before calling the blk_is_available. > > Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1615 > Signed-off-by: Wang Liang > Reviewed-by: Emanuele Giuseppe Esposito

Re: [PATCH] aio-wait: avoid AioContext lock in aio_wait_bh_oneshot()

2023-04-05 Thread Emanuele Giuseppe Esposito
-by: Stefan Hajnoczi > Reviewed-by: Emanuele Giuseppe Esposito

Re: [PATCH for-8.0] block/export: Fix graph locking in blk_get_geometry() call

2023-03-27 Thread Emanuele Giuseppe Esposito
) is what fixes > it). > > Fixes: 8ab8140a04cf771d63e9754d6ba6c1e676bfe507 > Reported-by: Lukáš Doktor > Signed-off-by: Kevin Wolf Reviewed-by: Emanuele Giuseppe Esposito > --- > include/block/block-io.h | 4 +++- > include/sysemu/block-backend-io.h | 5 - &g

Re: [PATCH 00/23] block: Lock the graph, part 2 (BlockDriver callbacks)

2023-02-17 Thread Emanuele Giuseppe Esposito
river callback theme), are ready and their number looks > manageable. You will still see some FIXMEs at the end of the series > that will only be addressed in future patches. Reviewed-by: Emanuele Giuseppe Esposito > > Emanuele Giuseppe Esposito (5): > block/qed: add missing gr

[PATCH] block/file-posix: don't use functions calling AIO_WAIT_WHILE in worker threads

2023-02-09 Thread Emanuele Giuseppe Esposito
thread and is not protected by any lock. Replace it with raw_co_getlength, that doesn't create a coroutine and doesn't read the BDS graph. Signed-off-by: Emanuele Giuseppe Esposito --- block/file-posix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/file

Re: rainier-bmc machine dumping core with latest qemu

2023-02-09 Thread Emanuele Giuseppe Esposito
Adding Kevin too. I can't reproduce your issue. I tried the exact steps showed in your mail, both with BLD_VERSION=20230205025034 (not anymore latest compose) and BLD_VERSION=20230209025037 (currently latest), and the VM boots till the login screen. Talking with Kevin it looks like handle_aiocb_w

[PATCH] virtio-blk: add missing AioContext lock

2023-02-08 Thread Emanuele Giuseppe Esposito
quot;:{"direct":true,"no-flush":false},"driver":"qcow2","file":"libvirt-1-storage"}' \ -device virtio-blk-pci,iothread=iothread1,drive=libvirt-1-format,id=virtio-disk0,bootindex=1,write-cache=on and observe that it will fail not manage to boot

[PATCH v5 3/4] thread-pool: use ThreadPool from the running thread

2023-02-03 Thread Emanuele Giuseppe Esposito
Use qemu_get_current_aio_context() where possible, since we always submit work to the current thread anyways. We want to also be sure that the thread submitting the work is the same as the one processing the pool, to avoid adding synchronization to the pool list. Signed-off-by: Emanuele Giuseppe

[PATCH v5 1/4] linux-aio: use LinuxAioState from the running thread

2023-02-03 Thread Emanuele Giuseppe Esposito
rk in the current thread's AioContext. Signed-off-by: Emanuele Giuseppe Esposito --- include/block/aio.h | 4 include/block/raw-aio.h | 18 -- include/sysemu/block-backend-io.h | 6 ++ block/file-posix.c| 10 +++--- block/l

[PATCH v5 2/4] io_uring: use LuringState from the running thread

2023-02-03 Thread Emanuele Giuseppe Esposito
rk in the current thread's AioContext. Signed-off-by: Emanuele Giuseppe Esposito --- include/block/aio.h | 4 include/block/raw-aio.h | 15 +++ block/file-posix.c | 12 block/io_uring.c| 23 +++ 4 files changed, 30 inserti

[PATCH v5 0/4] AioContext removal: LinuxAioState and ThreadPool

2023-02-03 Thread Emanuele Giuseppe Esposito
from thread_pool_submit* * document that functions run in current IOThread v4: * add missing aio_context removal, and fix typo v3: * remove qemu_coroutine_enter_if_inactive v2: * assertion in thread_pool * remove useless BlockDriverState * param in patch 1 and 2 * io_uring cleaned too Emanuele Giuseppe Esposi

[PATCH v5 4/4] thread-pool: avoid passing the pool parameter every time

2023-02-03 Thread Emanuele Giuseppe Esposito
e the ThreadPool function parameter. Signed-off-by: Emanuele Giuseppe Esposito --- include/block/thread-pool.h | 10 -- backends/tpm/tpm_backend.c| 4 +--- block/file-posix.c| 4 +--- block/file-win32.c| 4 +--- block/qcow2-threads.c | 3 +-- hw/9pfs/c

Re: [PATCH 00/13] block: Fix bdrv_open*() calls from coroutine context

2023-01-27 Thread Emanuele Giuseppe Esposito
k: Fix bdrv_co_create_opts_simple() to open images with > no_co_wrapper > block: Assert non-coroutine context for bdrv_open_inherit() > Apart from a small nitpick in patch 3 where the functions are not marked as coroutine_fn (but I think this is because BDS callbacks usually don&

Re: [PATCH v2 00/14] block: Move more functions to coroutines

2023-01-16 Thread Emanuele Giuseppe Esposito
n earlier. > - Since pretty much every patch was touched in this, I refrained from > picking up any Reviewed-by for v1 > Reviewed-by: Emanuele Giuseppe Esposito > Emanuele Giuseppe Esposito (14): > block-coroutine-wrapper: support void functions > block: Conve

Re: [PATCH 02/14] block: Convert bdrv_io_plug() to co_wrapper

2022-12-19 Thread Emanuele Giuseppe Esposito
Am 16/12/2022 um 17:12 schrieb Vladimir Sementsov-Ogievskiy: > On 12/13/22 11:53, Kevin Wolf wrote: >> --- a/include/block/block_int-common.h >> +++ b/include/block/block_int-common.h >> @@ -729,7 +729,7 @@ struct BlockDriver { >>   void (*bdrv_debug_event)(BlockDriverState *bs, BlkdebugEven

Re: [PATCH 06/14] block-backend: use bdrv_getlength instead of blk_getlength

2022-12-19 Thread Emanuele Giuseppe Esposito
Am 16/12/2022 um 18:22 schrieb Vladimir Sementsov-Ogievskiy: > On 12/13/22 11:53, Kevin Wolf wrote: >> From: Emanuele Giuseppe Esposito >> >> The only difference is that blk_ checks if the block is available, >> but this check is already performed above in blk_check

Re: [PATCH 02/14] block: Convert bdrv_io_plug() to co_wrapper

2022-12-19 Thread Emanuele Giuseppe Esposito
Am 16/12/2022 um 15:26 schrieb Vladimir Sementsov-Ogievskiy: > On 12/13/22 11:53, Kevin Wolf wrote: >> From: Emanuele Giuseppe Esposito >> >> BlockDriver->bdrv_io_plug is categorized as IO callback, and it >> currently doesn't run in a coroutine. We should

Re: [PATCH 00/14] block: Move more functions to coroutines

2022-12-15 Thread Emanuele Giuseppe Esposito
erting functions to coroutine_fn, and adding the locking to > them. This series does only the coroutine conversion. The locking part > will be in another series which now comes with TSA annotations and makes > the locking related changes big enough to have separate patches. > Rev

Re: [RFC PATCH] test-bdrv-drain: keep graph manipulations out of coroutines

2022-12-09 Thread Emanuele Giuseppe Esposito
Am 09/12/2022 um 13:18 schrieb Emanuele Giuseppe Esposito: > > > Am 05/12/2022 um 14:01 schrieb Kevin Wolf: >> Am 02.12.2022 um 18:22 hat Paolo Bonzini geschrieben: >>> On 12/2/22 14:42, Emanuele Giuseppe Esposito wrote: >>>> >>>> &

Re: [RFC PATCH] test-bdrv-drain: keep graph manipulations out of coroutines

2022-12-09 Thread Emanuele Giuseppe Esposito
Am 05/12/2022 um 14:01 schrieb Kevin Wolf: > Am 02.12.2022 um 18:22 hat Paolo Bonzini geschrieben: >> On 12/2/22 14:42, Emanuele Giuseppe Esposito wrote: >>> >>> >>> Am 02/12/2022 um 14:27 schrieb Paolo Bonzini: >>>> Changes to the BlockDriverStat

Re: [PATCH 00/18] block: Introduce a block graph rwlock

2022-12-07 Thread Emanuele Giuseppe Esposito
cros for shared locks > configure: Enable -Wthread-safety if present > test-bdrv-drain: Fix incorrrect drain assumptions > block: Fix locking in external_snapshot_prepare() > graph-lock: TSA annotations for lock/unlock functions > Mark assert_bdrv_graph_readable/wri

Re: [RFC PATCH] test-bdrv-drain: keep graph manipulations out of coroutines

2022-12-05 Thread Emanuele Giuseppe Esposito
Am 02/12/2022 um 18:22 schrieb Paolo Bonzini: > On 12/2/22 14:42, Emanuele Giuseppe Esposito wrote: >> >> >> Am 02/12/2022 um 14:27 schrieb Paolo Bonzini: >>> Changes to the BlockDriverState graph will have to take the >>> corresponding lock for writing,

Re: [RFC PATCH] test-bdrv-drain: keep graph manipulations out of coroutines

2022-12-02 Thread Emanuele Giuseppe Esposito
Am 02/12/2022 um 14:27 schrieb Paolo Bonzini: > Changes to the BlockDriverState graph will have to take the > corresponding lock for writing, and therefore cannot be done > inside a coroutine. Move them outside the test body. > > Signed-off-by: Paolo Bonzini > --- > tests/unit/test-bdrv-drai

[PATCH v7 13/14] block: convert bdrv_create to co_wrapper

2022-11-28 Thread Emanuele Giuseppe Esposito
This function is never called in coroutine context, therefore instead of manually creating a new coroutine, delegate it to the block-coroutine-wrapper script, defining it as co_wrapper. Signed-off-by: Emanuele Giuseppe Esposito Reviewed-by: Kevin Wolf Reviewed-by: Vladimir Sementsov-Ogievskiy

[PATCH v7 05/14] block/vmdk: add coroutine_fn annotations

2022-11-28 Thread Emanuele Giuseppe Esposito
suspend (or in other words call qemu_coroutine_yield()). Therefore we can mark such functions coroutine_fn too. Signed-off-by: Emanuele Giuseppe Esposito Reviewed-by: Paolo Bonzini Reviewed-by: Kevin Wolf Reviewed-by: Vladimir Sementsov-Ogievskiy --- block/vmdk.c | 36

[PATCH v7 12/14] block-coroutine-wrapper.py: support also basic return types

2022-11-28 Thread Emanuele Giuseppe Esposito
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-of

[PATCH v7 09/14] block: rename generated_co_wrapper in co_wrapper_mixed

2022-11-28 Thread Emanuele Giuseppe Esposito
In preparation to the incoming new function specifiers, rename g_c_w with a more meaningful name and document it. Signed-off-by: Emanuele Giuseppe Esposito Reviewed-by: Vladimir Sementsov-Ogievskiy --- docs/devel/block-coroutine-wrapper.rst | 6 +-- block/coroutines.h | 4

[PATCH v7 14/14] block/dirty-bitmap: convert coroutine-only functions to co_wrapper

2022-11-28 Thread Emanuele Giuseppe Esposito
ed to c_w. Signed-off-by: Emanuele Giuseppe Esposito Reviewed-by: Kevin Wolf Reviewed-by: Vladimir Sementsov-Ogievskiy --- include/block/block-common.h | 5 +- include/block/block-io.h | 10 +++- include/block/dirty-bitmap.h | 10 +++- block/dirty-bitmap.c

[PATCH v7 11/14] block-coroutine-wrapper.py: support functions without bs arg

2022-11-28 Thread Emanuele Giuseppe Esposito
, and default to the main loop if no BlockDriverState is passed as parameter. Signed-off-by: Emanuele Giuseppe Esposito Reviewed-by: Vladimir Sementsov-Ogievskiy --- block/block-gen.h | 6 +++--- scripts/block-coroutine-wrapper.py | 16 2 files changed, 11

[PATCH v7 06/14] block: avoid duplicating filename string in bdrv_create

2022-11-28 Thread Emanuele Giuseppe Esposito
We know that the string will stay around until the function returns, and the parameter of drv->bdrv_co_create_opts is const char*, so it must not be modified either. Suggested-by: Kevin Wolf Signed-off-by: Emanuele Giuseppe Esposito Reviewed-by: Kevin Wolf Reviewed-by: Vladimir Sement

[PATCH v7 08/14] block: bdrv_create_file is a coroutine_fn

2022-11-28 Thread Emanuele Giuseppe Esposito
It is always called in coroutine_fn callbacks, therefore it can directly call bdrv_co_create(). Rename it to bdrv_co_create_file too. Signed-off-by: Emanuele Giuseppe Esposito Reviewed-by: Kevin Wolf Reviewed-by: Vladimir Sementsov-Ogievskiy --- include/block/block-global-state.h | 3

[PATCH v7 07/14] block: distinguish between bdrv_create running in coroutine and not

2022-11-28 Thread Emanuele Giuseppe Esposito
Call two different functions depending on whether bdrv_create is in coroutine or not, following the same pattern as generated_co_wrapper functions. This allows to also call the coroutine function directly, without using CreateCo or relying in bdrv_create(). Signed-off-by: Emanuele Giuseppe

[PATCH v7 02/14] block-copy: add coroutine_fn annotations

2022-11-28 Thread Emanuele Giuseppe Esposito
suspend (or in other words call qemu_coroutine_yield()). Therefore we can mark such functions coroutine_fn too. Signed-off-by: Emanuele Giuseppe Esposito Reviewed-by: Paolo Bonzini Reviewed-by: Kevin Wolf Reviewed-by: Vladimir Sementsov-Ogievskiy --- include/block/block-copy.h | 5

[PATCH v7 01/14] block-io: introduce coroutine_fn duplicates for bdrv_common_block_status_above callers

2022-11-28 Thread Emanuele Giuseppe Esposito
ppers that take care of directly calling the same coroutine functions called in the g_c_w. Signed-off-by: Emanuele Giuseppe Esposito Reviewed-by: Kevin Wolf Reviewed-by: Vladimir Sementsov-Ogievskiy --- include/block/block-io.h | 15 +++ block/io.c

[PATCH v7 10/14] block-coroutine-wrapper.py: introduce co_wrapper

2022-11-28 Thread Emanuele Giuseppe Esposito
advantage of automating the code creation. In the future all c_w_mixed functions will be substituted by co_wrapper. Signed-off-by: Emanuele Giuseppe Esposito Reviewed-by: Vladimir Sementsov-Ogievskiy --- docs/devel/block-coroutine-wrapper.rst | 6 +- include/block/block-common.h | 8

[PATCH v7 04/14] block-backend: replace bdrv_*_above with blk_*_above

2022-11-28 Thread Emanuele Giuseppe Esposito
bdrv_co_common_block_status_above() to avoid using a g_c_w. Same applies to blk_co_is_allocated_above. Signed-off-by: Emanuele Giuseppe Esposito Reviewed-by: Vladimir Sementsov-Ogievskiy --- include/sysemu/block-backend-io.h | 9 + block/block-backend.c | 21 block/commit.c

[PATCH v7 03/14] nbd/server.c: add coroutine_fn annotations

2022-11-28 Thread Emanuele Giuseppe Esposito
in other words call qemu_coroutine_yield()). Therefore we can mark such functions coroutine_fn too. Signed-off-by: Emanuele Giuseppe Esposito Reviewed-by: Kevin Wolf Reviewed-by: Paolo Bonzini Reviewed-by: Vladimir Sementsov-Ogievskiy --- nbd/server.c | 29 - 1

[PATCH v7 00/14] Still more coroutine and various fixes in block layer

2022-11-28 Thread Emanuele Giuseppe Esposito
message in patches 2/3/6 on why we add coroutine_fn Emanuele Giuseppe Esposito (14): block-io: introduce coroutine_fn duplicates for bdrv_common_block_status_above callers block-copy: add coroutine_fn annotations nbd/server.c: add coroutine_fn annotations block-backend: replace bdrv_*_ab

Re: [PATCH v6 10/14] block-coroutine-wrapper.py: introduce co_wrapper

2022-11-28 Thread Emanuele Giuseppe Esposito
Am 25/11/2022 um 21:32 schrieb Vladimir Sementsov-Ogievskiy: > >>     class FuncDecl: >> -    def __init__(self, return_type: str, name: str, args: str) -> None: >> +    def __init__(self, return_type: str, name: str, args: str, >> + variant: str) -> None: > > I'd prefer mixed:

Re: [PATCH v6 07/14] block: distinguish between bdrv_create running in coroutine and not

2022-11-28 Thread Emanuele Giuseppe Esposito
Am 25/11/2022 um 19:03 schrieb Vladimir Sementsov-Ogievskiy: > On 11/25/22 16:35, Emanuele Giuseppe Esposito wrote: >> Call two different functions depending on whether bdrv_create >> is in coroutine or not, following the same pattern as >> generated_co_wrapper functions.

[PATCH v6 10/14] block-coroutine-wrapper.py: introduce co_wrapper

2022-11-25 Thread Emanuele Giuseppe Esposito
advantage of automating the code creation. In the future all c_w_mixed functions will be substituted by co_wrapper. Signed-off-by: Emanuele Giuseppe Esposito Reviewed-by: Kevin Wolf --- docs/devel/block-coroutine-wrapper.rst | 6 +- include/block/block-common.h | 8 +- scripts/block

[PATCH v6 06/14] block: avoid duplicating filename string in bdrv_create

2022-11-25 Thread Emanuele Giuseppe Esposito
We know that the string will stay around until the function returns, and the parameter of drv->bdrv_co_create_opts is const char*, so it must not be modified either. Suggested-by: Kevin Wolf Signed-off-by: Emanuele Giuseppe Esposito Reviewed-by: Kevin Wolf --- block.c | 7 ++- 1 f

[PATCH v6 00/14] Still more coroutine and various fixes in block layer

2022-11-25 Thread Emanuele Giuseppe Esposito
message in patches 2/3/6 on why we add coroutine_fn Emanuele Giuseppe Esposito (14): block-io: introduce coroutine_fn duplicates for bdrv_common_block_status_above callers block-copy: add missing coroutine_fn annotations nbd/server.c: add missing coroutine_fn annotations block-backend: repl

[PATCH v6 08/14] block: bdrv_create_file is a coroutine_fn

2022-11-25 Thread Emanuele Giuseppe Esposito
It is always called in coroutine_fn callbacks, therefore it can directly call bdrv_co_create(). Rename it to bdrv_co_create_file too. Signed-off-by: Emanuele Giuseppe Esposito Reviewed-by: Kevin Wolf --- block.c| 5 +++-- block/crypto.c | 2

[PATCH v6 02/14] block-copy: add missing coroutine_fn annotations

2022-11-25 Thread Emanuele Giuseppe Esposito
suspend (or in other words call qemu_coroutine_yield()). Therefore we need to mark such functions coroutine_fn too. Signed-off-by: Emanuele Giuseppe Esposito Reviewed-by: Paolo Bonzini Reviewed-by: Kevin Wolf --- block/block-copy.c | 21 - include/block/block-copy.h

[PATCH v6 05/14] block/vmdk: add missing coroutine_fn annotations

2022-11-25 Thread Emanuele Giuseppe Esposito
suspend (or in other words call qemu_coroutine_yield()). Therefore we need to mark such functions coroutine_fn too. Signed-off-by: Emanuele Giuseppe Esposito Reviewed-by: Paolo Bonzini Reviewed-by: Kevin Wolf --- block/vmdk.c | 36 +++- 1 file changed, 19 insertions

[PATCH v6 14/14] block/dirty-bitmap: convert coroutine-only functions to co_wrapper

2022-11-25 Thread Emanuele Giuseppe Esposito
ed to c_w. Signed-off-by: Emanuele Giuseppe Esposito Reviewed-by: Kevin Wolf --- block/dirty-bitmap.c | 88 +--- block/meson.build| 1 + include/block/block-common.h | 5 +- include/block/block-io.h | 10 +++- include/block/dirty-bitmap.h

[PATCH v6 03/14] nbd/server.c: add missing coroutine_fn annotations

2022-11-25 Thread Emanuele Giuseppe Esposito
in other words call qemu_coroutine_yield()). Therefore we need to mark such functions coroutine_fn too. Signed-off-by: Emanuele Giuseppe Esposito Reviewed-by: Kevin Wolf Reviewed-by: Paolo Bonzini --- nbd/server.c | 29 - 1 file changed, 16 insertions(+), 13

[PATCH v6 13/14] block: convert bdrv_create to co_wrapper

2022-11-25 Thread Emanuele Giuseppe Esposito
This function is never called in coroutine context, therefore instead of manually creating a new coroutine, delegate it to the block-coroutine-wrapper script, defining it as co_wrapper. Signed-off-by: Emanuele Giuseppe Esposito Reviewed-by: Kevin Wolf --- block.c

[PATCH v6 01/14] block-io: introduce coroutine_fn duplicates for bdrv_common_block_status_above callers

2022-11-25 Thread Emanuele Giuseppe Esposito
ppers that take care of directly calling the same coroutine functions called in the g_c_w. Signed-off-by: Emanuele Giuseppe Esposito Reviewed-by: Kevin Wolf --- block/io.c | 58 +--- include/block/block-io.h | 15 +++ 2 files changed, 70

[PATCH v6 04/14] block-backend: replace bdrv_*_above with blk_*_above

2022-11-25 Thread Emanuele Giuseppe Esposito
bdrv_co_common_block_status_above() to avoid using a g_c_w. Same applies to blk_co_is_allocated_above. Signed-off-by: Emanuele Giuseppe Esposito --- block/block-backend.c | 21 block/commit.c| 4 ++-- include/sysemu/block-backend-io.h | 9 + nbd/server.c

[PATCH v6 12/14] block-coroutine-wrapper.py: support also basic return types

2022-11-25 Thread Emanuele Giuseppe Esposito
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-of

[PATCH v6 07/14] block: distinguish between bdrv_create running in coroutine and not

2022-11-25 Thread Emanuele Giuseppe Esposito
Call two different functions depending on whether bdrv_create is in coroutine or not, following the same pattern as generated_co_wrapper functions. This allows to also call the coroutine function directly, without using CreateCo or relying in bdrv_create(). Signed-off-by: Emanuele Giuseppe

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

2022-11-25 Thread Emanuele Giuseppe Esposito
, and default to the main loop if no BlockDriverState is passed as parameter. Signed-off-by: Emanuele Giuseppe Esposito --- block/block-gen.h | 6 +++--- scripts/block-coroutine-wrapper.py | 16 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a

[PATCH v6 09/14] block: rename generated_co_wrapper in co_wrapper_mixed

2022-11-25 Thread Emanuele Giuseppe Esposito
In preparation to the incoming new function specifiers, rename g_c_w with a more meaningful name and document it. Signed-off-by: Emanuele Giuseppe Esposito --- block/coroutines.h | 4 +- docs/devel/block-coroutine-wrapper.rst | 6 +-- include/block/block-common.h

[PATCH v5 06/15] block: avoid duplicating filename string in bdrv_create

2022-11-23 Thread Emanuele Giuseppe Esposito
We know that the string will stay around until the function returns, and the parameter of drv->bdrv_co_create_opts is const char*, so it must not be modified either. Suggested-by: Kevin Wolf Signed-off-by: Emanuele Giuseppe Esposito --- block.c | 7 ++- 1 file changed, 2 insertions(+)

[PATCH v5 07/15] block: introduce QEMU_IN_COROUTINE macro

2022-11-23 Thread Emanuele Giuseppe Esposito
context. Signed-off-by: Emanuele Giuseppe Esposito --- include/block/block-common.h | 11 +++ 1 file changed, 11 insertions(+) diff --git a/include/block/block-common.h b/include/block/block-common.h index 297704c1e9..24de1d63fd 100644 --- a/include/block/block-common.h +++ b/include/block

[PATCH v5 03/15] nbd/server.c: add missing coroutine_fn annotations

2022-11-23 Thread Emanuele Giuseppe Esposito
in other words call qemu_coroutine_yield()). Therefore we need to mark such functions coroutine_fn too. Signed-off-by: Emanuele Giuseppe Esposito Reviewed-by: Kevin Wolf Reviewed-by: Paolo Bonzini --- nbd/server.c | 29 - 1 file changed, 16 insertions(+), 13

[PATCH v5 05/15] block/vmdk: add missing coroutine_fn annotations

2022-11-23 Thread Emanuele Giuseppe Esposito
suspend (or in other words call qemu_coroutine_yield()). Therefore we need to mark such functions coroutine_fn too. Signed-off-by: Emanuele Giuseppe Esposito Reviewed-by: Paolo Bonzini Reviewed-by: Kevin Wolf --- block/vmdk.c | 36 +++- 1 file changed, 19 insertions

[PATCH v5 14/15] block: convert bdrv_create to generated_co_wrapper_simple

2022-11-23 Thread Emanuele Giuseppe Esposito
This function is never called in coroutine context, therefore instead of manually creating a new coroutine, delegate it to the block-coroutine-wrapper script, defining it as g_c_w_simple. Signed-off-by: Emanuele Giuseppe Esposito Reviewed-by: Kevin Wolf --- block.c

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

2022-11-23 Thread Emanuele Giuseppe Esposito
ain loop. Signed-off-by: Emanuele Giuseppe Esposito --- scripts/block-coroutine-wrapper.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/block-coroutine-wrapper.py b/scripts/block-coroutine-wrapper.py index 2fa3d01898..7e8f2da84b 100644 --- a/scripts/bl

Re: [PATCH 00/15] Protect the block layer with a rwlock: part 3

2022-11-23 Thread Emanuele Giuseppe Esposito
Am 18/11/2022 um 11:57 schrieb Paolo Bonzini: > On 11/16/22 15:07, Emanuele Giuseppe Esposito wrote: >> Here we introduce generated_co_wrapper_simple, a simplification of >> g_c_w that >> only considers the case where the caller is not in a coroutine. >> This simplifi

[PATCH v5 15/15] block/dirty-bitmap: convert coroutine-only functions to generated_co_wrapper_simple

2022-11-23 Thread Emanuele Giuseppe Esposito
ed to g_c_w_simple. Signed-off-by: Emanuele Giuseppe Esposito Reviewed-by: Kevin Wolf --- block/dirty-bitmap.c | 88 +--- block/meson.build| 1 + include/block/block-common.h | 5 +- include/block/block-io.h | 9 +++- include/block/

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

2022-11-23 Thread Emanuele Giuseppe Esposito
, and default to the main loop if no BlockDriverState is passed as parameter. Signed-off-by: Emanuele Giuseppe Esposito --- block/block-gen.h | 6 +++--- scripts/block-coroutine-wrapper.py | 14 +++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/block

[PATCH v5 13/15] block-coroutine-wrapper.py: support also basic return types

2022-11-23 Thread Emanuele Giuseppe Esposito
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-of

[PATCH v5 09/15] block: bdrv_create_file is a coroutine_fn

2022-11-23 Thread Emanuele Giuseppe Esposito
It is always called in coroutine_fn callbacks, therefore it can directly call bdrv_co_create(). Rename it to bdrv_co_create_file too. Signed-off-by: Emanuele Giuseppe Esposito --- block.c| 5 +++-- block/crypto.c | 2 +- block/parallels.c

[PATCH v5 02/15] block-copy: add missing coroutine_fn annotations

2022-11-23 Thread Emanuele Giuseppe Esposito
suspend (or in other words call qemu_coroutine_yield()). Therefore we need to mark such functions coroutine_fn too. Signed-off-by: Emanuele Giuseppe Esposito Reviewed-by: Paolo Bonzini --- block/block-copy.c | 21 - include/block/block-copy.h | 5 +++-- 2 files

[PATCH v5 01/15] block-io: introduce coroutine_fn duplicates for bdrv_common_block_status_above callers

2022-11-23 Thread Emanuele Giuseppe Esposito
ppers that take care of directly calling the same coroutine functions called in the g_c_w. Signed-off-by: Emanuele Giuseppe Esposito --- block/io.c | 64 ++-- include/block/block-io.h | 15 ++ 2 files changed, 76 insertions(+), 3 deletion

[PATCH v5 04/15] block-backend: replace bdrv_*_above with blk_*_above

2022-11-23 Thread Emanuele Giuseppe Esposito
bdrv_co_common_block_status_above() to avoid using a g_c_w. Signed-off-by: Emanuele Giuseppe Esposito Reviewed-by: Paolo Bonzini --- block/block-backend.c | 21 block/commit.c| 4 ++-- include/sysemu/block-backend-io.h | 9 + nbd/server.c

[PATCH v5 10/15] block-coroutine-wrapper.py: introduce generated_co_wrapper_simple

2022-11-23 Thread Emanuele Giuseppe Esposito
functions will be substituted on g_c_w_simple. Signed-off-by: Emanuele Giuseppe Esposito --- include/block/block-common.h | 1 + scripts/block-coroutine-wrapper.py | 105 - 2 files changed, 75 insertions(+), 31 deletions(-) diff --git a/include/block/block

[PATCH v5 08/15] block: distinguish between bdrv_create running in coroutine and not

2022-11-23 Thread Emanuele Giuseppe Esposito
Call two different functions depending on whether bdrv_create is in coroutine or not, following the same pattern as generated_co_wrapper functions. This allows to also call the coroutine function directly, without using CreateCo or relying in bdrv_create(). Signed-off-by: Emanuele Giuseppe

[PATCH v5 00/15] Still more coroutine and various fixes in block layer

2022-11-23 Thread Emanuele Giuseppe Esposito
drain" v4: * use v2 commit messages * introduce generated_co_wrapper_simple to simplify patches v3: * Remove patch 1, base on kevin "drain semplification serie" v2: * clarified commit message in patches 2/3/6 on why we add coroutine_fn Emanuele Giuseppe Esposito (15)

Re: [PATCH v4 09/11] block: bdrv_create_file is a coroutine_fn

2022-11-22 Thread Emanuele Giuseppe Esposito
Am 22/11/2022 um 09:58 schrieb Kevin Wolf: > Am 16.11.2022 um 13:22 hat Emanuele Giuseppe Esposito geschrieben: >> It is always called in coroutine_fn callbacks, therefore >> it can directly call bdrv_co_create(). >> >> Signed-off-by: Emanuele Giuseppe E

Re: [PATCH v4 07/11] block/vmdk: add missing coroutine_fn annotations

2022-11-21 Thread Emanuele Giuseppe Esposito
Am 21/11/2022 um 17:01 schrieb Kevin Wolf: > Am 16.11.2022 um 13:22 hat Emanuele Giuseppe Esposito geschrieben: >> These functions end up calling bdrv_create() implemented as >> generated_co_wrapper >> functions. >> In addition, they also happen to be always

Re: [PATCH v4 05/11] block-coroutine-wrapper.py: default to main loop aiocontext if function does not have a BlockDriverState parameter

2022-11-21 Thread Emanuele Giuseppe Esposito
Am 21/11/2022 um 16:30 schrieb Kevin Wolf: > Am 16.11.2022 um 13:22 hat Emanuele Giuseppe Esposito geschrieben: >> 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_ge

Re: [PATCH 0/6] Protect the block layer with a rwlock: part 2

2022-11-21 Thread Emanuele Giuseppe Esposito
rotect the block layer with a rwlock: part 3 Thank you, Emanuele Am 16/11/2022 um 14:53 schrieb Emanuele Giuseppe Esposito: > Please read "Protect the block layer with a rwlock: part 1" for an additional > introduction and aim of this series. > > This second part aim

Re: [PATCH 00/15] Protect the block layer with a rwlock: part 3

2022-11-21 Thread Emanuele Giuseppe Esposito
rotect the block layer with a rwlock: part 3 Thank you, Emanuele Am 16/11/2022 um 15:07 schrieb Emanuele Giuseppe Esposito: > Please read "Protect the block layer with a rwlock: part 1" and > "Protect the block layer with a rwlock: part 2" for an > additional intro

Re: [PATCH 00/20] Protect the block layer with a rwlock: part 1

2022-11-21 Thread Emanuele Giuseppe Esposito
rotect the block layer with a rwlock: part 3 Thank you, Emanuele Am 16/11/2022 um 14:48 schrieb Emanuele Giuseppe Esposito: > This serie is the first of four series that aim to introduce and use a new > graph rwlock in the QEMU block layer. > The aim is to replace the current AioContext

  1   2   3   4   5   6   7   8   9   10   >