[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH RESEND 33/50] blockdev: Respect NULL BDS in do_drive
From: |
Max Reitz |
Subject: |
[Qemu-devel] [PATCH RESEND 33/50] blockdev: Respect NULL BDS in do_drive_del() |
Date: |
Tue, 27 Jan 2015 14:46:06 -0500 |
Signed-off-by: Max Reitz <address@hidden>
---
blockdev.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/blockdev.c b/blockdev.c
index f3091df..f82b20c 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -2019,7 +2019,6 @@ int do_drive_del(Monitor *mon, const QDict *qdict,
QObject **ret_data)
error_report("Device '%s' not found", id);
return -1;
}
- bs = blk_bs(blk);
if (!blk_legacy_dinfo(blk)) {
error_report("Deleting device added with blockdev-add"
@@ -2027,10 +2026,11 @@ int do_drive_del(Monitor *mon, const QDict *qdict,
QObject **ret_data)
return -1;
}
- aio_context = bdrv_get_aio_context(bs);
+ aio_context = blk_get_aio_context(blk);
aio_context_acquire(aio_context);
- if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_DRIVE_DEL, &local_err)) {
+ bs = blk_bs(blk);
+ if (bs && bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_DRIVE_DEL, &local_err)) {
error_report("%s", error_get_pretty(local_err));
error_free(local_err);
aio_context_release(aio_context);
@@ -2039,8 +2039,10 @@ int do_drive_del(Monitor *mon, const QDict *qdict,
QObject **ret_data)
/* quiesce block driver; prevent further io */
bdrv_drain_all();
- bdrv_flush(bs);
- bdrv_close(bs);
+ if (bs) {
+ bdrv_flush(bs);
+ bdrv_close(bs);
+ }
/* if we have a device attached to this BlockDriverState
* then we need to make the drive anonymous until the device
--
2.1.0
- Re: [Qemu-devel] [PATCH RESEND 31/50] block: Add blk_insert_bs(), (continued)
- [Qemu-devel] [PATCH RESEND 32/50] blockdev: Check BB validity in eject and change, Max Reitz, 2015/01/27
- [Qemu-devel] [PATCH RESEND 34/50] blockdev: Do not create BDS for empty drive, Max Reitz, 2015/01/27
- [Qemu-devel] [PATCH RESEND 36/50] blockdev: Allow more options for BB-less BDS tree, Max Reitz, 2015/01/27
- [Qemu-devel] [PATCH RESEND 38/50] blockdev: Add blockdev-open-tray, Max Reitz, 2015/01/27
- [Qemu-devel] [PATCH RESEND 33/50] blockdev: Respect NULL BDS in do_drive_del(),
Max Reitz <=
- [Qemu-devel] [PATCH RESEND 39/50] blockdev: Add blockdev-close-tray, Max Reitz, 2015/01/27
- [Qemu-devel] [PATCH RESEND 35/50] blockdev: Pull out blockdev option extraction, Max Reitz, 2015/01/27
- [Qemu-devel] [PATCH RESEND 41/50] blockdev: Add blockdev-insert-medium, Max Reitz, 2015/01/27
- [Qemu-devel] [PATCH RESEND 40/50] blockdev: Add blockdev-remove-medium, Max Reitz, 2015/01/27