From: Zhu Yangyang <zhuyangyan...@huawei.com> QMP may will be blocked for a long time on bdrv_drained_begin() when a network disk is configured and the network failure is just about to occur.
In theory, any command may be blocked if it calls bdrv_drained_begin(). This series add a timeout parameter for qmp_block_set_io_throttle() and qmp_block_resize() to control their execution duration. Changelog v4 --- 1. Corrected the added version of the timeout parameter from 10.0 to 10.1 2. Add a patch to add the timeout parameter for qmp_block_resize(). v3 --- Unify AIO_WAIT_WHILE_{TIMEOUT/INTERNAL} by replacing AIO_WAIT_WHILE_INTERNAL() with AIO_WAIT_WHILE_TIMEOUT(..., 0). v2 --- 1. Support 0 in BDRV_POLL_WHILE_TIMEOUT(), 0 means infinite. 2. Use uint64_t timeout_ns instead of int64 timeout to name variables. 3. Use timer_pending() to check for expiry instead of explicitly checking against the deadline for BDRV_POLL_WHILE_TIMEOUT(). 4. Add documentation for bdrv_drained_begin_timeout(), note that bdrv_drained_end() must be called when -ETIMEDOUT is returned. 5. Add a timeout parameter to the qmp_block_set_io_throttle() instead of hardcoding the timeout, and the default value is 0, mean an infinite timeout. v1 patch link: https://lore.kernel.org/qemu-devel/20250308101618.721954-1-zoudong...@huawei.com/ Zhu Yangyang (3): io/block: Refactoring the bdrv_drained_begin() function and implement a timeout mechanism. qapi/throttle: add timeout parameter for qmp_block_set_io_throttle() qapi/resize: add timeout parameter for qmp_block_resize() block/block-backend.c | 14 ++++- block/io.c | 58 +++++++++++++++++---- block/monitor/block-hmp-cmds.c | 2 +- block/qapi-system.c | 10 +++- blockdev.c | 16 +++++- include/block/aio-wait.h | 47 ++++++++++++----- include/block/block-io.h | 22 +++++++- include/system/block-backend-global-state.h | 1 + qapi/block-core.json | 11 +++- util/aio-wait.c | 5 ++ 10 files changed, 155 insertions(+), 31 deletions(-) -- 2.33.0