[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 20/50] blockdev: Check blk_is_available() in sn-del-
From: |
Max Reitz |
Subject: |
[Qemu-devel] [PATCH 20/50] blockdev: Check blk_is_available() in sn-del-int-sync |
Date: |
Mon, 26 Jan 2015 11:02:54 -0500 |
Check whether the BlockBackend is actually available at the start of
snapshot-delete-internal-sync.
Signed-off-by: Max Reitz <address@hidden>
---
blockdev.c | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/blockdev.c b/blockdev.c
index ae1137f..858d181 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -1096,18 +1096,23 @@ SnapshotInfo
*qmp_blockdev_snapshot_delete_internal_sync(const char *device,
const char *name,
Error **errp)
{
- BlockDriverState *bs = bdrv_find(device);
+ BlockBackend *blk;
+ BlockDriverState *bs;
AioContext *aio_context;
QEMUSnapshotInfo sn;
Error *local_err = NULL;
SnapshotInfo *info = NULL;
int ret;
- if (!bs) {
+ blk = blk_by_name(device);
+ if (!blk) {
error_set(errp, QERR_DEVICE_NOT_FOUND, device);
return NULL;
}
+ aio_context = blk_get_aio_context(blk);
+ aio_context_acquire(aio_context);
+
if (!has_id) {
id = NULL;
}
@@ -1118,11 +1123,14 @@ SnapshotInfo
*qmp_blockdev_snapshot_delete_internal_sync(const char *device,
if (!id && !name) {
error_setg(errp, "Name or id must be provided");
- return NULL;
+ goto out_aio_context;
}
- aio_context = bdrv_get_aio_context(bs);
- aio_context_acquire(aio_context);
+ if (!blk_is_available(blk)) {
+ error_set(errp, QERR_DEVICE_HAS_NO_MEDIUM, device);
+ goto out_aio_context;
+ }
+ bs = blk_bs(blk);
if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_INTERNAL_SNAPSHOT_DELETE, errp)) {
goto out_aio_context;
--
2.1.0
- [Qemu-devel] [PATCH 06/50] block: Add blk_is_available(), (continued)
- [Qemu-devel] [PATCH 06/50] block: Add blk_is_available(), Max Reitz, 2015/01/26
- [Qemu-devel] [PATCH 12/50] block: Move I/O status and error actions into BB, Max Reitz, 2015/01/26
- [Qemu-devel] [PATCH 11/50] block: Move BlockAcctStats into BlockBackend, Max Reitz, 2015/01/26
- [Qemu-devel] [PATCH 07/50] block: Make bdrv_is_inserted() recursive, Max Reitz, 2015/01/26
- [Qemu-devel] [PATCH 09/50] block: Move guest_block_size into BlockBackend, Max Reitz, 2015/01/26
- [Qemu-devel] [PATCH 20/50] blockdev: Check blk_is_available() in sn-del-int-sync,
Max Reitz <=
- [Qemu-devel] [PATCH 21/50] blockdev: Check BB validity in internal snapshot TA, Max Reitz, 2015/01/26
- [Qemu-devel] [PATCH 16/50] block: Prepare remaining BB functions for NULL BDS, Max Reitz, 2015/01/26
- [Qemu-devel] [PATCH 22/50] blockdev: Check BB validity in drive-backup TA, Max Reitz, 2015/01/26
- [Qemu-devel] [PATCH 10/50] block: Remove wr_highest_offset from BlockAcctStats, Max Reitz, 2015/01/26
- [Qemu-devel] [PATCH 18/50] block: Respect empty BB in bdrv_query_info(), Max Reitz, 2015/01/26
- [Qemu-devel] [PATCH 15/50] block: Fail requests to empty BlockBackend, Max Reitz, 2015/01/26
- [Qemu-devel] [PATCH 19/50] blockdev: Use BlockBackend for blockdev-backup TA, Max Reitz, 2015/01/26
- [Qemu-devel] [PATCH 17/50] block: Respect empty BB in bdrv_lookup_bs(), Max Reitz, 2015/01/26