[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH RESEND 19/50] blockdev: Use BlockBackend for blockde
From: |
Max Reitz |
Subject: |
[Qemu-devel] [PATCH RESEND 19/50] blockdev: Use BlockBackend for blockdev-backup TA |
Date: |
Tue, 27 Jan 2015 14:45:52 -0500 |
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 <address@hidden>
---
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
- Re: [Qemu-devel] [PATCH RESEND 11/50] block: Move BlockAcctStats into BlockBackend, (continued)
- [Qemu-devel] [PATCH RESEND 12/50] block: Move I/O status and error actions into BB, Max Reitz, 2015/01/27
- [Qemu-devel] [PATCH RESEND 09/50] block: Move guest_block_size into BlockBackend, Max Reitz, 2015/01/27
- [Qemu-devel] [PATCH RESEND 18/50] block: Respect empty BB in bdrv_query_info(), Max Reitz, 2015/01/27
- [Qemu-devel] [PATCH RESEND 16/50] block: Prepare remaining BB functions for NULL BDS, Max Reitz, 2015/01/27
- [Qemu-devel] [PATCH RESEND 10/50] block: Remove wr_highest_offset from BlockAcctStats, Max Reitz, 2015/01/27
- [Qemu-devel] [PATCH RESEND 19/50] blockdev: Use BlockBackend for blockdev-backup TA,
Max Reitz <=
- [Qemu-devel] [PATCH RESEND 15/50] block: Fail requests to empty BlockBackend, Max Reitz, 2015/01/27
- [Qemu-devel] [PATCH RESEND 21/50] blockdev: Check BB validity in internal snapshot TA, Max Reitz, 2015/01/27
- [Qemu-devel] [PATCH RESEND 25/50] blockdev: Check BB validity in block-commit, Max Reitz, 2015/01/27
- [Qemu-devel] [PATCH RESEND 26/50] blockdev: Check BB validity in drive-backup, Max Reitz, 2015/01/27