From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:58777) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UftF3-0001El-Ph for qemu-devel@nongnu.org; Fri, 24 May 2013 10:45:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UftAz-0006L6-Ri for qemu-devel@nongnu.org; Fri, 24 May 2013 10:41:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35724) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UftAz-0006Kr-Gg for qemu-devel@nongnu.org; Fri, 24 May 2013 10:41:01 -0400 From: Stefan Hajnoczi Date: Fri, 24 May 2013 16:32:20 +0200 Message-Id: <1369405947-14818-5-git-send-email-stefanha@redhat.com> In-Reply-To: <1369405947-14818-1-git-send-email-stefanha@redhat.com> References: <1369405947-14818-1-git-send-email-stefanha@redhat.com> Subject: [Qemu-devel] [PATCH 04/11] block: package rollback code in qmp_transaction() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , Anthony Liguori , Wenchao Xia From: Wenchao Xia Signed-off-by: Wenchao Xia Reviewed-by: Kevin Wolf Reviewed-by: Stefan Hajnoczi Reviewed-by: Eric Blake Signed-off-by: Kevin Wolf --- blockdev.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/blockdev.c b/blockdev.c index 76f0532..2131e13 100644 --- a/blockdev.c +++ b/blockdev.c @@ -882,6 +882,13 @@ static void external_snapshot_commit(BlkTransactionStates *states) NULL); } +static void external_snapshot_abort(BlkTransactionStates *states) +{ + if (states->new_bs) { + bdrv_delete(states->new_bs); + } +} + /* * 'Atomic' group snapshots. The snapshots are taken as a set, and if any fail * then we do not pivot any of the devices in the group, and abandon the @@ -939,9 +946,7 @@ delete_and_fail: * the original bs for all images */ QSIMPLEQ_FOREACH(states, &snap_bdrv_states, entry) { - if (states->new_bs) { - bdrv_delete(states->new_bs); - } + external_snapshot_abort(states); } exit: QSIMPLEQ_FOREACH_SAFE(states, &snap_bdrv_states, entry, next) { -- 1.8.1.4