From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59942) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YwCap-0000pi-9J for qemu-devel@nongnu.org; Sat, 23 May 2015 12:48:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YwCak-0000ta-Iq for qemu-devel@nongnu.org; Sat, 23 May 2015 12:48:11 -0400 Message-ID: <5560AF04.7060100@redhat.com> Date: Sat, 23 May 2015 18:47:00 +0200 From: Max Reitz MIME-Version: 1.0 References: <1432102576-6637-1-git-send-email-famz@redhat.com> <1432102576-6637-11-git-send-email-famz@redhat.com> In-Reply-To: <1432102576-6637-11-git-send-email-famz@redhat.com> Content-Type: text/plain; charset=iso-8859-15; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v5 10/13] blockdev: Block device IO during drive-backup transaction List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Fam Zheng , qemu-devel@nongnu.org Cc: Kevin Wolf , qemu-block@nongnu.org, jcody@redhat.com, armbru@redhat.com, Stefan Hajnoczi , amit.shah@redhat.com, pbonzini@redhat.com On 20.05.2015 08:16, Fam Zheng wrote: > Signed-off-by: Fam Zheng > --- > blockdev.c | 9 ++++++++- > 1 file changed, 8 insertions(+), 1 deletion(-) > > diff --git a/blockdev.c b/blockdev.c > index 923fc90..ae52d27 100644 > --- a/blockdev.c > +++ b/blockdev.c > @@ -1575,6 +1575,7 @@ typedef struct DriveBackupState { > BlockDriverState *bs; > AioContext *aio_context; > BlockJob *job; > + Error *blocker; > } DriveBackupState; > > static void drive_backup_prepare(BlkTransactionState *common, Error **errp) > @@ -1599,6 +1600,9 @@ static void drive_backup_prepare(BlkTransactionState *common, Error **errp) > state->aio_context = bdrv_get_aio_context(bs); > aio_context_acquire(state->aio_context); > > + state->bs = bs; > + error_setg(&state->blocker, "drive-backup in progress"); > + bdrv_op_block(bs, BLOCK_OP_TYPE_DEVICE_IO, state->blocker); > qmp_drive_backup(backup->device, backup->target, > backup->has_format, backup->format, > backup->sync, > @@ -1613,7 +1617,6 @@ static void drive_backup_prepare(BlkTransactionState *common, Error **errp) > return; > } > > - state->bs = bs; > state->job = state->bs->job; > } Okay, pulling that up works here, because drive_backup_abort() checks that bs->job is set, and that bs->job == state->job (which cannot be true if qmp_drive_backup() failed). Reviewed-by: Max Reitz > @@ -1632,6 +1635,10 @@ static void drive_backup_clean(BlkTransactionState *common) > { > DriveBackupState *state = DO_UPCAST(DriveBackupState, common, common); > > + if (state->bs) { > + bdrv_op_unblock(state->bs, BLOCK_OP_TYPE_DEVICE_IO, state->blocker); > + error_free(state->blocker); > + } > if (state->aio_context) { > aio_context_release(state->aio_context); > }