From patchwork Thu May 2 02:26:45 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wayne Xia X-Patchwork-Id: 240885 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 BE2A82C00A4 for ; Thu, 2 May 2013 12:31:28 +1000 (EST) Received: from localhost ([::1]:53854 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UXjIs-0007cj-V4 for incoming@patchwork.ozlabs.org; Wed, 01 May 2013 22:31:26 -0400 Received: from eggs.gnu.org ([208.118.235.92]:53359) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UXjGH-0003f5-Mp for qemu-devel@nongnu.org; Wed, 01 May 2013 22:28:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UXjGF-0002pn-LY for qemu-devel@nongnu.org; Wed, 01 May 2013 22:28:45 -0400 Received: from e23smtp02.au.ibm.com ([202.81.31.144]:39668) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UXjGE-0002oW-HI for qemu-devel@nongnu.org; Wed, 01 May 2013 22:28:43 -0400 Received: from /spool/local by e23smtp02.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 2 May 2013 12:20:34 +1000 Received: from d23dlp01.au.ibm.com (202.81.31.203) by e23smtp02.au.ibm.com (202.81.31.208) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 2 May 2013 12:20:32 +1000 Received: from d23relay05.au.ibm.com (d23relay05.au.ibm.com [9.190.235.152]) by d23dlp01.au.ibm.com (Postfix) with ESMTP id 0B8AF2CE8051 for ; Thu, 2 May 2013 12:28:37 +1000 (EST) Received: from d23av04.au.ibm.com (d23av04.au.ibm.com [9.190.235.139]) by d23relay05.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r422EixK24510508 for ; Thu, 2 May 2013 12:14:44 +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 r422SYgO011518 for ; Thu, 2 May 2013 12:28:36 +1000 Received: from RH63Wenchao (wenchaox.cn.ibm.com [9.115.122.225]) by d23av04.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id r422QrHL008158; Thu, 2 May 2013 12:28:32 +1000 From: Wenchao Xia To: qemu-devel@nongnu.org Date: Thu, 2 May 2013 10:26:45 +0800 Message-Id: <1367461606-7554-5-git-send-email-xiawenc@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1367461606-7554-1-git-send-email-xiawenc@linux.vnet.ibm.com> References: <1367461606-7554-1-git-send-email-xiawenc@linux.vnet.ibm.com> X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13050202-5490-0000-0000-0000036159F0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 202.81.31.144 Cc: kwolf@redhat.com, stefanha@gmail.com, dietmar@proxmox.com, pbonzini@redhat.com, Wenchao Xia Subject: [Qemu-devel] [PATCH V4 4/5] block: package rollback 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 | 11 ++++++++--- 1 files changed, 8 insertions(+), 3 deletions(-) diff --git a/blockdev.c b/blockdev.c index 26bc78e..77adec8 100644 --- a/blockdev.c +++ b/blockdev.c @@ -882,6 +882,13 @@ static void external_snapshot_commit(BlkTransactionStates *states) NULL); } +static void external_snapshot_rollback(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_rollback(states); } exit: QSIMPLEQ_FOREACH_SAFE(states, &snap_bdrv_states, entry, next) {