qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH v3 08/38] block: Invoke change media CB before NULLi


From: Max Reitz
Subject: [Qemu-devel] [PATCH v3 08/38] block: Invoke change media CB before NULLing drv
Date: Wed, 3 Jun 2015 21:43:49 +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>
---
 block.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/block.c b/block.c
index d6479e6..f9596e3 100644
--- a/block.c
+++ b/block.c
@@ -1724,6 +1724,10 @@ void bdrv_close(BlockDriverState *bs)
     bdrv_drain_all(); /* 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) {
         if (bs->backing_hd) {
             BlockDriverState *backing_hd = bs->backing_hd;
@@ -1753,10 +1757,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.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]