[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH RESEND 22/50] blockdev: Check BB validity in drive-b
From: |
Max Reitz |
Subject: |
[Qemu-devel] [PATCH RESEND 22/50] blockdev: Check BB validity in drive-backup TA |
Date: |
Tue, 27 Jan 2015 14:45:55 -0500 |
In the drive-backup transaction, call blk_is_available() before using
blk_bs() to obtain the root BlockDriverState behind the BlockBackend.
Signed-off-by: Max Reitz <address@hidden>
---
blockdev.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/blockdev.c b/blockdev.c
index 012c603..5f7eef5 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -1507,23 +1507,28 @@ typedef struct DriveBackupState {
static void drive_backup_prepare(BlkTransactionState *common, Error **errp)
{
DriveBackupState *state = DO_UPCAST(DriveBackupState, common, common);
- BlockDriverState *bs;
+ BlockBackend *blk;
DriveBackup *backup;
Error *local_err = NULL;
assert(common->action->kind == TRANSACTION_ACTION_KIND_DRIVE_BACKUP);
backup = common->action->drive_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;
}
/* AioContext is released in .clean() */
- state->aio_context = bdrv_get_aio_context(bs);
+ state->aio_context = blk_get_aio_context(blk);
aio_context_acquire(state->aio_context);
+ if (!blk_is_available(blk)) {
+ error_set(errp, QERR_DEVICE_HAS_NO_MEDIUM, backup->device);
+ return;
+ }
+
qmp_drive_backup(backup->device, backup->target,
backup->has_format, backup->format,
backup->sync,
@@ -1537,7 +1542,7 @@ static void drive_backup_prepare(BlkTransactionState
*common, Error **errp)
return;
}
- state->bs = bs;
+ state->bs = blk_bs(blk);
state->job = state->bs->job;
}
--
2.1.0
- [Qemu-devel] [PATCH RESEND 48/50] hmp: Add read-only option to change command, (continued)
- [Qemu-devel] [PATCH RESEND 48/50] hmp: Add read-only option to change command, Max Reitz, 2015/01/27
- [Qemu-devel] [PATCH RESEND 03/50] hw/block/fdc: Implement tray status, Max Reitz, 2015/01/27
- [Qemu-devel] [PATCH RESEND 17/50] block: Respect empty BB in bdrv_lookup_bs(), Max Reitz, 2015/01/27
- [Qemu-devel] [PATCH RESEND 37/50] block: Add blk_remove_bs(), Max Reitz, 2015/01/27
- [Qemu-devel] [PATCH RESEND 20/50] blockdev: Check blk_is_available() in sn-del-int-sync, Max Reitz, 2015/01/27
- [Qemu-devel] [PATCH RESEND 14/50] block: Make some BB functions fall back to BBRS, Max Reitz, 2015/01/27
- [Qemu-devel] [PATCH RESEND 01/50] blockdev: Allow creation of BDS trees without BB, Max Reitz, 2015/01/27
- [Qemu-devel] [PATCH RESEND 22/50] blockdev: Check BB validity in drive-backup TA,
Max Reitz <=
- [Qemu-devel] [PATCH RESEND 13/50] block: Add BlockBackendRootState, Max Reitz, 2015/01/27
- [Qemu-devel] [PATCH RESEND 24/50] blockdev: Check BB validity in block-stream, Max Reitz, 2015/01/27