From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47684) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YyHvF-0005Bt-Tz for qemu-devel@nongnu.org; Fri, 29 May 2015 06:53:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YyHvE-0006x9-Q0 for qemu-devel@nongnu.org; Fri, 29 May 2015 06:53:53 -0400 From: Fam Zheng Date: Fri, 29 May 2015 18:53:18 +0800 Message-Id: <1432896805-23867-6-git-send-email-famz@redhat.com> In-Reply-To: <1432896805-23867-1-git-send-email-famz@redhat.com> References: <1432896805-23867-1-git-send-email-famz@redhat.com> Subject: [Qemu-devel] [RFC PATCH 05/12] blockdev: Lock BDS during drive-backup transaction List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , fam@euphon.net, qemu-block@nongnu.org, Jeff Cody , Stefan Hajnoczi , Paolo Bonzini To save the bs pointer for drive_backup_clean, pull the assignment to state->bs up. It will not be a problem for drive_backup_abort because state->job will still be NULL. Signed-off-by: Fam Zheng --- blockdev.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/blockdev.c b/blockdev.c index 1c3946a..517def4 100644 --- a/blockdev.c +++ b/blockdev.c @@ -1588,6 +1588,8 @@ static void drive_backup_prepare(BlkTransactionState *common, Error **errp) /* AioContext is released in .clean() */ state->aio_context = bdrv_get_aio_context(bs); aio_context_acquire(state->aio_context); + bdrv_lock(bs); + state->bs = bs; qmp_drive_backup(backup->device, backup->target, backup->has_format, backup->format, @@ -1603,7 +1605,6 @@ static void drive_backup_prepare(BlkTransactionState *common, Error **errp) return; } - state->bs = bs; state->job = state->bs->job; } @@ -1623,6 +1624,7 @@ static void drive_backup_clean(BlkTransactionState *common) DriveBackupState *state = DO_UPCAST(DriveBackupState, common, common); if (state->aio_context) { + bdrv_unlock(state->bs); aio_context_release(state->aio_context); } } -- 2.4.2