From patchwork Fri Apr 19 00:57:09 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wayne Xia X-Patchwork-Id: 237782 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 365952C01FA for ; Fri, 19 Apr 2013 11:01:50 +1000 (EST) Received: from localhost ([::1]:55214 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1USzi0-0001iU-GL for incoming@patchwork.ozlabs.org; Thu, 18 Apr 2013 21:01:48 -0400 Received: from eggs.gnu.org ([208.118.235.92]:43829) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1USzfY-0006I1-Vq for qemu-devel@nongnu.org; Thu, 18 Apr 2013 20:59:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1USzfX-0006w3-Rq for qemu-devel@nongnu.org; Thu, 18 Apr 2013 20:59:16 -0400 Received: from e28smtp02.in.ibm.com ([122.248.162.2]:47031) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1USzfX-0006vu-8U for qemu-devel@nongnu.org; Thu, 18 Apr 2013 20:59:15 -0400 Received: from /spool/local by e28smtp02.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 19 Apr 2013 06:23:51 +0530 Received: from d28dlp01.in.ibm.com (9.184.220.126) by e28smtp02.in.ibm.com (192.168.1.132) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 19 Apr 2013 06:23:48 +0530 Received: from d28relay04.in.ibm.com (d28relay04.in.ibm.com [9.184.220.61]) by d28dlp01.in.ibm.com (Postfix) with ESMTP id 7C8A0E004A for ; Fri, 19 Apr 2013 06:31:08 +0530 (IST) Received: from d28av03.in.ibm.com (d28av03.in.ibm.com [9.184.220.65]) by d28relay04.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r3J0x5hA14811424 for ; Fri, 19 Apr 2013 06:29:05 +0530 Received: from d28av03.in.ibm.com (loopback [127.0.0.1]) by d28av03.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r3J0x96F018131 for ; Fri, 19 Apr 2013 10:59:09 +1000 Received: from RH63Wenchao ([9.77.178.27]) by d28av03.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id r3J0vQaZ014233; Fri, 19 Apr 2013 10:59:07 +1000 From: Wenchao Xia To: qemu-devel@nongnu.org Date: Fri, 19 Apr 2013 08:57:09 +0800 Message-Id: <1366333030-8564-5-git-send-email-xiawenc@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1366333030-8564-1-git-send-email-xiawenc@linux.vnet.ibm.com> References: <1366333030-8564-1-git-send-email-xiawenc@linux.vnet.ibm.com> X-TM-AS-MML: No X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13041900-5816-0000-0000-0000079D40F2 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 122.248.162.2 Cc: kwolf@redhat.com, stefanha@gmail.com, dietmar@proxmox.com, pbonzini@redhat.com, Wenchao Xia Subject: [Qemu-devel] [PATCH V3 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 --- blockdev.c | 11 ++++++++--- 1 files changed, 8 insertions(+), 3 deletions(-) diff --git a/blockdev.c b/blockdev.c index 275c6f9..051be98 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) {