Commit e07d2e16a2 for qemu.org
commit e07d2e16a236209d560187a9c6365fde6adb5d87
Author: Denis V. Lunev <den@openvz.org>
Date: Thu Nov 5 21:37:51 2026 +0100
block: add bdrv_child_notify_resize() to notify a single parent
bdrv_co_parent_cb_resize() calls the resize hook of every parent of a
node. bdrv_replace_child_bs() needs to call it for one BdrvChild, and
from outside a coroutine.
Move the call into bdrv_co_child_notify_resize(), make the loop use it,
and add a co_wrapper for callers outside a coroutine.
No functional change.
Suggested-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Denis V. Lunev <den@openvz.org>
Cc: Kevin Wolf <kwolf@redhat.com>
Cc: Hanna Reitz <hreitz@redhat.com>
Cc: Eric Blake <eblake@redhat.com>
Cc: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Message-ID: <20261105203752.3169635-3-den@openvz.org>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
diff --git a/block/io.c b/block/io.c
index 0f81b7e6bb..e4568d4d24 100644
--- a/block/io.c
+++ b/block/io.c
@@ -3636,6 +3636,16 @@ int coroutine_fn bdrv_co_copy_range(BdrvChild *src, int64_t src_offset,
bytes, read_flags, write_flags);
}
+void coroutine_fn bdrv_co_child_notify_resize(BdrvChild *c)
+{
+ IO_CODE();
+ assert_bdrv_graph_readable();
+
+ if (c->klass->resize) {
+ c->klass->resize(c);
+ }
+}
+
void coroutine_fn bdrv_co_parent_cb_resize(BlockDriverState *bs)
{
BdrvChild *c;
@@ -3644,9 +3654,7 @@ void coroutine_fn bdrv_co_parent_cb_resize(BlockDriverState *bs)
assert_bdrv_graph_readable();
QLIST_FOREACH(c, &bs->parents, next_parent) {
- if (c->klass->resize) {
- c->klass->resize(c);
- }
+ bdrv_co_child_notify_resize(c);
}
}
diff --git a/include/block/block_int-io.h b/include/block/block_int-io.h
index 95d0dd7a05..3cb72fecd4 100644
--- a/include/block/block_int-io.h
+++ b/include/block/block_int-io.h
@@ -197,6 +197,15 @@ void bdrv_bsc_fill(BlockDriverState *bs, int64_t offset, int64_t bytes);
void coroutine_fn GRAPH_RDLOCK
bdrv_co_parent_cb_resize(BlockDriverState *bs);
+/*
+ * Notify the parent behind @c that the size of its child changed.
+ */
+void coroutine_fn GRAPH_RDLOCK
+bdrv_co_child_notify_resize(BdrvChild *c);
+
+void co_wrapper_bdrv_rdlock
+bdrv_child_notify_resize(BdrvChild *c);
+
void co_wrapper_bdrv_rdlock
bdrv_parent_cb_resize(BlockDriverState *bs);