From 615e6e9c2adabbc5039e3fdbd49326eeb549f931 Mon Sep 17 00:00:00 2001 From: Kevin Wolf Date: Mon, 9 Sep 2013 14:27:55 +0200 Subject: [PATCH 04/38] block: package rollback code in qmp_transaction() RH-Author: Kevin Wolf Message-id: <1378736903-18489-5-git-send-email-kwolf@redhat.com> Patchwork-id: 54191 O-Subject: [RHEL-7.0 qemu-kvm PATCH 04/32] block: package rollback code in qmp_transaction() Bugzilla: 1005818 RH-Acked-by: Fam Zheng RH-Acked-by: Max Reitz RH-Acked-by: Miroslav Rezanina From: Wenchao Xia Bugzilla: 1005818 Signed-off-by: Wenchao Xia Reviewed-by: Kevin Wolf Reviewed-by: Stefan Hajnoczi Reviewed-by: Eric Blake Signed-off-by: Kevin Wolf (cherry picked from commit 96b86bf72de0c6eda2799201517ef32910beb340) Signed-off-by: Kevin Wolf --- blockdev.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) Signed-off-by: Miroslav Rezanina --- blockdev.c | 11 ++++++++--- 1 files changed, 8 insertions(+), 3 deletions(-) diff --git a/blockdev.c b/blockdev.c index eabb3f8..b040f0f 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.7.1