From patchwork Sat Apr 13 11:11:39 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wayne Xia X-Patchwork-Id: 236328 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 367272C0087 for ; Sat, 13 Apr 2013 21:16:11 +1000 (EST) Received: from localhost ([::1]:42147 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UQyRF-0003Uc-CD for incoming@patchwork.ozlabs.org; Sat, 13 Apr 2013 07:16:09 -0400 Received: from eggs.gnu.org ([208.118.235.92]:50417) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UQyOb-0007o6-SO for qemu-devel@nongnu.org; Sat, 13 Apr 2013 07:13:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UQyOa-00054K-D2 for qemu-devel@nongnu.org; Sat, 13 Apr 2013 07:13:25 -0400 Received: from e23smtp07.au.ibm.com ([202.81.31.140]:51114) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UQyOZ-00053s-RJ for qemu-devel@nongnu.org; Sat, 13 Apr 2013 07:13:24 -0400 Received: from /spool/local by e23smtp07.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Sat, 13 Apr 2013 21:04:07 +1000 Received: from d23dlp03.au.ibm.com (202.81.31.214) by e23smtp07.au.ibm.com (202.81.31.204) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Sat, 13 Apr 2013 21:04:05 +1000 Received: from d23relay04.au.ibm.com (d23relay04.au.ibm.com [9.190.234.120]) by d23dlp03.au.ibm.com (Postfix) with ESMTP id CCAFF357804E for ; Sat, 13 Apr 2013 21:13:09 +1000 (EST) Received: from d23av04.au.ibm.com (d23av04.au.ibm.com [9.190.235.139]) by d23relay04.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r3DAxHl364815282 for ; Sat, 13 Apr 2013 20:59:18 +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 r3DBCbWh022049 for ; Sat, 13 Apr 2013 21:12:38 +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 r3DBBeZg019897; Sat, 13 Apr 2013 21:12:35 +1000 From: Wenchao Xia To: qemu-devel@nongnu.org Date: Sat, 13 Apr 2013 19:11:39 +0800 Message-Id: <1365851501-3037-4-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-0260-0000-0000-000002CD22B8 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 202.81.31.140 Cc: kwolf@redhat.com, pbonzini@redhat.com, Wenchao Xia , dietmar@proxmox.com, stefanha@gmail.com Subject: [Qemu-devel] [PATCH V2 3/5] block: package committing 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 The code is simply moved into a separate function. Signed-off-by: Wenchao Xia Reviewed-by: Eric Blake --- blockdev.c | 20 +++++++++++++------- 1 files changed, 13 insertions(+), 7 deletions(-) diff --git a/blockdev.c b/blockdev.c index 8d1faf8..38cb7d5 100644 --- a/blockdev.c +++ b/blockdev.c @@ -877,6 +877,18 @@ static int external_snapshot_prepare(BlockdevAction *action, return -1; } +static void external_snapshot_commit(BlockdevAction *action, + BlkTransactionStates *states) +{ + /* This removes our old bs from the bdrv_states, and adds the new bs */ + bdrv_append(states->new_bs, states->old_bs); + /* We don't need (or want) to use the transactional + * bdrv_reopen_multiple() across all the entries at once, because we + * don't want to abort all of them if one of them fails the reopen */ + bdrv_reopen(states->new_bs, states->new_bs->open_flags & ~BDRV_O_RDWR, + NULL); +} + /* * '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 @@ -919,13 +931,7 @@ void qmp_transaction(BlockdevActionList *dev_list, Error **errp) /* Now we are going to do the actual pivot. Everything up to this point * is reversible, but we are committed at this point */ QSIMPLEQ_FOREACH(states, &snap_bdrv_states, entry) { - /* This removes our old bs from the bdrv_states, and adds the new bs */ - bdrv_append(states->new_bs, states->old_bs); - /* We don't need (or want) to use the transactional - * bdrv_reopen_multiple() across all the entries at once, because we - * don't want to abort all of them if one of them fails the reopen */ - bdrv_reopen(states->new_bs, states->new_bs->open_flags & ~BDRV_O_RDWR, - NULL); + external_snapshot_commit(NULL, states); } /* success */