[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH RESEND 25/50] blockdev: Check BB validity in block-c
From: |
Max Reitz |
Subject: |
[Qemu-devel] [PATCH RESEND 25/50] blockdev: Check BB validity in block-commit |
Date: |
Tue, 27 Jan 2015 14:45:58 -0500 |
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 | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/blockdev.c b/blockdev.c
index 74d26a6..431afcd 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -2213,6 +2213,7 @@ void qmp_block_commit(const char *device,
bool has_speed, int64_t speed,
Error **errp)
{
+ BlockBackend *blk;
BlockDriverState *bs;
BlockDriverState *base_bs, *top_bs;
AioContext *aio_context;
@@ -2231,15 +2232,21 @@ void qmp_block_commit(const char *device,
* live commit feature versions; for this to work, we must make sure to
* perform the device lookup before any generic errors that may occur in a
* scenario in which all optional arguments are omitted. */
- bs = bdrv_find(device);
- if (!bs) {
+ blk = blk_by_name(device);
+ if (!blk) {
error_set(errp, QERR_DEVICE_NOT_FOUND, device);
return;
}
- aio_context = bdrv_get_aio_context(bs);
+ aio_context = blk_get_aio_context(blk);
aio_context_acquire(aio_context);
+ if (!blk_is_available(blk)) {
+ error_set(errp, QERR_DEVICE_HAS_NO_MEDIUM, device);
+ goto out;
+ }
+ bs = blk_bs(blk);
+
/* drain all i/o before commits */
bdrv_drain_all();
--
2.1.0
- Re: [Qemu-devel] [PATCH RESEND 16/50] block: Prepare remaining BB functions for NULL BDS, (continued)
- [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, 2015/01/27
- [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 <=
- [Qemu-devel] [PATCH RESEND 26/50] blockdev: Check BB validity in drive-backup, Max Reitz, 2015/01/27
- [Qemu-devel] [PATCH RESEND 27/50] blockdev: Check BB validity in blockdev-backup, Max Reitz, 2015/01/27
- [Qemu-devel] [PATCH RESEND 29/50] blockdev: Check BB validity in find_block_job(), Max Reitz, 2015/01/27
- [Qemu-devel] [PATCH RESEND 23/50] blockdev: Catch NULL BDS in block_set_io_throttle, Max Reitz, 2015/01/27
- [Qemu-devel] [PATCH RESEND 30/50] blockdev: Check BB validity in change-backing-file, Max Reitz, 2015/01/27