From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35828) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YGC69-0006Vm-Rb for qemu-devel@nongnu.org; Tue, 27 Jan 2015 14:46:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YGC68-00028X-Vq for qemu-devel@nongnu.org; Tue, 27 Jan 2015 14:46:53 -0500 Received: from mx1.redhat.com ([209.132.183.28]:36533) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YGC68-00028Q-Kd for qemu-devel@nongnu.org; Tue, 27 Jan 2015 14:46:52 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t0RJkpGW026754 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Tue, 27 Jan 2015 14:46:51 -0500 From: Max Reitz Date: Tue, 27 Jan 2015 14:45:52 -0500 Message-Id: <1422387983-32153-20-git-send-email-mreitz@redhat.com> In-Reply-To: <1422387983-32153-1-git-send-email-mreitz@redhat.com> References: <1422387983-32153-1-git-send-email-mreitz@redhat.com> Subject: [Qemu-devel] [PATCH RESEND 19/50] blockdev: Use BlockBackend for blockdev-backup TA List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , Fam Zheng , Jeff Cody , Markus Armbruster , Max Reitz , Stefan Hajnoczi , John Snow When preparing a blockdev-backup transaction, the BlockBackend should be used because there may be no medium associated to the BB (which would make bdrv_find() fail, whereas blk_by_name() does not). This does not make a real difference because blockdev-backup will fail without a medium anyway; however, it will have an impact on the error returned ("device not found" vs. "no medium"). Signed-off-by: Max Reitz --- blockdev.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/blockdev.c b/blockdev.c index c9e9ab9..ae1137f 100644 --- a/blockdev.c +++ b/blockdev.c @@ -1562,27 +1562,27 @@ static void blockdev_backup_prepare(BlkTransactionState *common, Error **errp) { BlockdevBackupState *state = DO_UPCAST(BlockdevBackupState, common, common); BlockdevBackup *backup; - BlockDriverState *bs, *target; + BlockBackend *blk, *target; Error *local_err = NULL; assert(common->action->kind == TRANSACTION_ACTION_KIND_BLOCKDEV_BACKUP); backup = common->action->blockdev_backup; - bs = bdrv_find(backup->device); - if (!bs) { + blk = blk_by_name(backup->device); + if (!blk) { error_set(errp, QERR_DEVICE_NOT_FOUND, backup->device); return; } - target = bdrv_find(backup->target); + target = blk_by_name(backup->target); if (!target) { error_set(errp, QERR_DEVICE_NOT_FOUND, backup->target); return; } /* AioContext is released in .clean() */ - state->aio_context = bdrv_get_aio_context(bs); - if (state->aio_context != bdrv_get_aio_context(target)) { + state->aio_context = blk_get_aio_context(blk); + if (state->aio_context != blk_get_aio_context(target)) { state->aio_context = NULL; error_setg(errp, "Backup between two IO threads is not implemented"); return; @@ -1600,7 +1600,10 @@ static void blockdev_backup_prepare(BlkTransactionState *common, Error **errp) return; } - state->bs = bs; + /* qmp_blockdev_backup() would have failed otherwise */ + assert(blk_bs(blk)); + + state->bs = blk_bs(blk); state->job = state->bs->job; } -- 2.1.0