From patchwork Wed May 6 11:23:39 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fam Zheng X-Patchwork-Id: 468877 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 85CD714028F for ; Wed, 6 May 2015 21:28:35 +1000 (AEST) Received: from localhost ([::1]:44196 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YpxVB-00037r-IU for incoming@patchwork.ozlabs.org; Wed, 06 May 2015 07:28:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54924) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YpxRC-0005f1-0I for qemu-devel@nongnu.org; Wed, 06 May 2015 07:24:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YpxRB-0003Vk-74 for qemu-devel@nongnu.org; Wed, 06 May 2015 07:24:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50775) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YpxR5-0003UE-0Z; Wed, 06 May 2015 07:24:19 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id AC86BC12FF; Wed, 6 May 2015 11:24:18 +0000 (UTC) Received: from ad.nay.redhat.com (dhcp-14-137.nay.redhat.com [10.66.14.137]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t46BNgga019707; Wed, 6 May 2015 07:24:14 -0400 From: Fam Zheng To: qemu-devel@nongnu.org Date: Wed, 6 May 2015 19:23:39 +0800 Message-Id: <1430911419-8256-8-git-send-email-famz@redhat.com> In-Reply-To: <1430911419-8256-1-git-send-email-famz@redhat.com> References: <1430911419-8256-1-git-send-email-famz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , qemu-block@nongnu.org, jcody@redhat.com, armbru@redhat.com, mreitz@redhat.com, Stefan Hajnoczi , pbonzini@redhat.com Subject: [Qemu-devel] [RFC PATCH 7/7] blockdev: Add "device IO" op blocker during snapshot 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: Fam Zheng --- blockdev.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/blockdev.c b/blockdev.c index 5eaf77e..859fa2e 100644 --- a/blockdev.c +++ b/blockdev.c @@ -1398,6 +1398,7 @@ typedef struct ExternalSnapshotState { BlockDriverState *old_bs; BlockDriverState *new_bs; AioContext *aio_context; + Error *blocker; } ExternalSnapshotState; static void external_snapshot_prepare(BlkTransactionState *common, @@ -1519,6 +1520,9 @@ static void external_snapshot_prepare(BlkTransactionState *common, if (ret != 0) { error_propagate(errp, local_err); } + + error_setg(&state->blocker, "snapshot in progress"); + bdrv_op_block(state->old_bs, BLOCK_OP_TYPE_DEVICE_IO, state->blocker); } static void external_snapshot_commit(BlkTransactionState *common) @@ -1536,6 +1540,9 @@ static void external_snapshot_commit(BlkTransactionState *common) bdrv_reopen(state->new_bs, state->new_bs->open_flags & ~BDRV_O_RDWR, NULL); + bdrv_op_unblock(state->old_bs, BLOCK_OP_TYPE_DEVICE_IO, state->blocker); + error_free(state->blocker); + aio_context_release(state->aio_context); }