From patchwork Sat Apr 13 11:11:40 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wayne Xia X-Patchwork-Id: 236327 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 1494B2C0098 for ; Sat, 13 Apr 2013 21:15:16 +1000 (EST) Received: from localhost ([::1]:38748 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UQyQM-0001cv-7Q for incoming@patchwork.ozlabs.org; Sat, 13 Apr 2013 07:15:14 -0400 Received: from eggs.gnu.org ([208.118.235.92]:50392) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UQyOZ-0007jc-3U for qemu-devel@nongnu.org; Sat, 13 Apr 2013 07:13:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UQyOY-00053j-6v for qemu-devel@nongnu.org; Sat, 13 Apr 2013 07:13:23 -0400 Received: from e23smtp03.au.ibm.com ([202.81.31.145]:53054) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UQyOX-00053O-Iv for qemu-devel@nongnu.org; Sat, 13 Apr 2013 07:13:22 -0400 Received: from /spool/local by e23smtp03.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Sat, 13 Apr 2013 21:05:47 +1000 Received: from d23dlp03.au.ibm.com (202.81.31.214) by e23smtp03.au.ibm.com (202.81.31.209) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Sat, 13 Apr 2013 21:05:45 +1000 Received: from d23relay03.au.ibm.com (d23relay03.au.ibm.com [9.190.235.21]) by d23dlp03.au.ibm.com (Postfix) with ESMTP id 5E8D4357804A for ; Sat, 13 Apr 2013 21:13:11 +1000 (EST) Received: from d23av04.au.ibm.com (d23av04.au.ibm.com [9.190.235.139]) by d23relay03.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r3DBCY0L11337988 for ; Sat, 13 Apr 2013 21:12:35 +1000 Received: from d23av04.au.ibm.com (loopback [127.0.0.1]) by d23av04.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r3DBCdHg022182 for ; Sat, 13 Apr 2013 21:12:40 +1000 Received: from RH63Wenchao (wenchaox.cn.ibm.com [9.115.122.157]) by d23av04.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id r3DBBeZh019897; Sat, 13 Apr 2013 21:12:38 +1000 From: Wenchao Xia To: qemu-devel@nongnu.org Date: Sat, 13 Apr 2013 19:11:40 +0800 Message-Id: <1365851501-3037-5-git-send-email-xiawenc@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1365851501-3037-1-git-send-email-xiawenc@linux.vnet.ibm.com> References: <1365851501-3037-1-git-send-email-xiawenc@linux.vnet.ibm.com> x-cbid: 13041311-6102-0000-0000-0000034F6041 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 202.81.31.145 Cc: kwolf@redhat.com, pbonzini@redhat.com, Wenchao Xia , dietmar@proxmox.com, stefanha@gmail.com Subject: [Qemu-devel] [PATCH V2 4/5] block: package rolling back code in qmp_transaction() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Wenchao Xia Reviewed-by: Eric Blake --- blockdev.c | 12 +++++++++--- 1 files changed, 9 insertions(+), 3 deletions(-) diff --git a/blockdev.c b/blockdev.c index 38cb7d5..3e69569 100644 --- a/blockdev.c +++ b/blockdev.c @@ -889,6 +889,14 @@ static void external_snapshot_commit(BlockdevAction *action, NULL); } +static void external_snapshot_rollback(BlockdevAction *action, + 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 @@ -943,9 +951,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_rollback(NULL, states); } exit: QSIMPLEQ_FOREACH_SAFE(states, &snap_bdrv_states, entry, next) {