[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH RESEND 20/50] blockdev: Check blk_is_available() in
From: |
Max Reitz |
Subject: |
[Qemu-devel] [PATCH RESEND 20/50] blockdev: Check blk_is_available() in sn-del-int-sync |
Date: |
Tue, 27 Jan 2015 14:45:53 -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 RESEND 49/50] iotests: More options for VM.add_drive(), (continued)
- [Qemu-devel] [PATCH RESEND 49/50] iotests: More options for VM.add_drive(), Max Reitz, 2015/01/27
- [Qemu-devel] [PATCH RESEND 50/50] iotests: Add test for change-related QMP commands, Max Reitz, 2015/01/27
- [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 <=
- [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, 2015/01/27
- [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