[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v4 08/38] block: Invoke change media CB before NULLi
From: |
Max Reitz |
Subject: |
[Qemu-devel] [PATCH v4 08/38] block: Invoke change media CB before NULLing drv |
Date: |
Mon, 20 Jul 2015 19:45:35 +0200 |
In order to handle host device passthrough, some guest device models
may call blk_is_inserted() to check whether the medium is inserted on
the host, when checking the guest tray status.
This tray status is inquired by blk_dev_change_media_cb(); because
bdrv_is_inserted() (invoked by blk_is_inserted()) always returns 0 for
BDS with drv set to NULL, blk_dev_change_media_cb() should therefore be
called before drv is set to NULL.
Signed-off-by: Max Reitz <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Reviewed-by: Alberto Garcia <address@hidden>
---
block.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/block.c b/block.c
index 1d27b6a..e08fe5c 100644
--- a/block.c
+++ b/block.c
@@ -1900,6 +1900,10 @@ void bdrv_close(BlockDriverState *bs)
bdrv_drain(bs); /* in case flush left pending I/O */
notifier_list_notify(&bs->close_notifiers, bs);
+ if (bs->blk) {
+ blk_dev_change_media_cb(bs->blk, false);
+ }
+
if (bs->drv) {
BdrvChild *child, *next;
@@ -1942,10 +1946,6 @@ void bdrv_close(BlockDriverState *bs)
}
}
- if (bs->blk) {
- blk_dev_change_media_cb(bs->blk, false);
- }
-
/*throttling disk I/O limits*/
if (bs->io_limits_enabled) {
bdrv_io_limits_disable(bs);
--
2.4.6
- [Qemu-devel] [PATCH v4 00/38] blockdev: BlockBackend and media, Max Reitz, 2015/07/20
- [Qemu-devel] [PATCH v4 01/38] block: Remove host floppy support, Max Reitz, 2015/07/20
- [Qemu-devel] [PATCH v4 02/38] blockdev: Allow creation of BDS trees without BB, Max Reitz, 2015/07/20
- [Qemu-devel] [PATCH v4 03/38] iotests: Only create BB if necessary, Max Reitz, 2015/07/20
- [Qemu-devel] [PATCH v4 05/38] block: Add blk_is_available(), Max Reitz, 2015/07/20
- [Qemu-devel] [PATCH v4 06/38] block: Make bdrv_is_inserted() recursive, Max Reitz, 2015/07/20
- [Qemu-devel] [PATCH v4 04/38] block: Make bdrv_is_inserted() return a bool, Max Reitz, 2015/07/20
- [Qemu-devel] [PATCH v4 07/38] block/quorum: Implement bdrv_is_inserted(), Max Reitz, 2015/07/20
- [Qemu-devel] [PATCH v4 08/38] block: Invoke change media CB before NULLing drv,
Max Reitz <=
- [Qemu-devel] [PATCH v4 10/38] hw/usb-storage: Check whether BB is inserted, Max Reitz, 2015/07/20
- [Qemu-devel] [PATCH v4 09/38] hw/block/fdc: Implement tray status, Max Reitz, 2015/07/20
- [Qemu-devel] [PATCH v4 11/38] block: Fix BB AIOCB AioContext without BDS, Max Reitz, 2015/07/20
- [Qemu-devel] [PATCH v4 12/38] block: Move guest_block_size into BlockBackend, Max Reitz, 2015/07/20
- [Qemu-devel] [PATCH v4 13/38] block: Remove wr_highest_sector from BlockAcctStats, Max Reitz, 2015/07/20
- [Qemu-devel] [PATCH v4 14/38] block: Move BlockAcctStats into BlockBackend, Max Reitz, 2015/07/20
- [Qemu-devel] [PATCH v4 16/38] block: Add BlockBackendRootState, Max Reitz, 2015/07/20
- [Qemu-devel] [PATCH v4 15/38] block: Move I/O status and error actions into BB, Max Reitz, 2015/07/20
- [Qemu-devel] [PATCH v4 17/38] block: Make some BB functions fall back to BBRS, Max Reitz, 2015/07/20
- [Qemu-devel] [PATCH v4 18/38] block: Fail requests to empty BlockBackend, Max Reitz, 2015/07/20