From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52005) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YRG3q-0004Wq-Vb for qemu-devel@nongnu.org; Fri, 27 Feb 2015 03:14:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YRG3m-0006Bo-19 for qemu-devel@nongnu.org; Fri, 27 Feb 2015 03:14:14 -0500 Received: from smtp3.mundo-r.com ([212.51.32.191]:5844 helo=smtp4.mundo-r.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YRG3l-0006B5-QA for qemu-devel@nongnu.org; Fri, 27 Feb 2015 03:14:09 -0500 From: Alberto Garcia Date: Fri, 27 Feb 2015 10:13:49 +0200 Message-Id: <1425024829-1246-1-git-send-email-berto@igalia.com> Subject: [Qemu-devel] [PATCH] block: Ensure correct order when dropping intermediate images List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , Alberto Garcia , Stefan Hajnoczi Given a chain of images like [A] <- [B] <- [C] <- [D] <- [E], where [E] is the active (topmost) image, if we want to remove [B] and [C] we have to do it before linking [A] and [D]. When [A] is set as the backing image of [D] all its operations are blocked, but removing [B] afterwards would undo those changes, since [B] would still be connected to [A]. This would result in a situation where the backing image [A] has all its operations unblocked. Signed-off-by: Alberto Garcia --- block.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/block.c b/block.c index 9b707e3..2c36351 100644 --- a/block.c +++ b/block.c @@ -2624,13 +2624,14 @@ int bdrv_drop_intermediate(BlockDriverState *active, BlockDriverState *top, if (ret) { goto exit; } - bdrv_set_backing_hd(new_top_bs, base_bs); + bdrv_set_backing_hd(new_top_bs, NULL); QSIMPLEQ_FOREACH_SAFE(intermediate_state, &states_to_delete, entry, next) { /* so that bdrv_close() does not recursively close the chain */ bdrv_set_backing_hd(intermediate_state->bs, NULL); bdrv_unref(intermediate_state->bs); } + bdrv_set_backing_hd(new_top_bs, base_bs); ret = 0; exit: -- 2.1.4