From 85c5bd4a41fec70482b634ae2d3bb3c56631e337 Mon Sep 17 00:00:00 2001 From: Kevin Wolf Date: Tue, 4 Feb 2025 22:13:56 +0100 Subject: [PATCH 11/22] block: Don't attach inactive child to active node RH-Author: Kevin Wolf RH-MergeRequest: 340: QMP command for block device reactivation after migration RH-Jira: RHEL-54670 RH-Acked-by: Eric Blake RH-Acked-by: Stefan Hajnoczi RH-Commit: [11/22] 7148d3e16eeda8a6142aedeab245a88b879b37b8 (kmwolf/centos-qemu-kvm) An active node makes unrestricted use of its children and would possibly run into assertion failures when it operates on an inactive child node. Signed-off-by: Kevin Wolf Acked-by: Fabiano Rosas Reviewed-by: Eric Blake Reviewed-by: Stefan Hajnoczi Message-ID: <20250204211407.381505-6-kwolf@redhat.com> Signed-off-by: Kevin Wolf (cherry picked from commit 9b81361aedcc47905de5e91f68221de89c6f5467) Signed-off-by: Kevin Wolf --- block.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/block.c b/block.c index a2aa454312..41e72e6965 100644 --- a/block.c +++ b/block.c @@ -3183,6 +3183,11 @@ bdrv_attach_child_noperm(BlockDriverState *parent_bs, child_bs->node_name, child_name, parent_bs->node_name); return NULL; } + if (bdrv_is_inactive(child_bs) && !bdrv_is_inactive(parent_bs)) { + error_setg(errp, "Inactive '%s' can't be a %s child of active '%s'", + child_bs->node_name, child_name, parent_bs->node_name); + return NULL; + } bdrv_get_cumulative_perm(parent_bs, &perm, &shared_perm); bdrv_child_perm(parent_bs, child_bs, NULL, child_role, NULL, -- 2.39.3