qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] Close the BlockDriverState when guest eject the media
@ 2014-10-18 10:02 Weidong Huang
  2014-10-20  9:41 ` Kevin Wolf
  0 siblings, 1 reply; 13+ messages in thread
From: Weidong Huang @ 2014-10-18 10:02 UTC (permalink / raw)
  To: qemu-devel@nongnu.org; +Cc: kwolf, stefanha

Hi ALL:

There are two ways to eject the cdrom tray. One is by the eject's qmp commmand(eject_device).
The another one is by the guest(bdrv_eject). They have different results.

eject_device: close the BlockDriverState(bdrv_close(bs))
bdrv_eject: don't close the BlockDriverState,

This is ambiguous. So libvirt can't handle some situations.

libvirt send eject qmp command ---> qemu send eject request to guest --->
guest respond to qemu ---> qemu emit tray_open event to libvirt --->
libvirt will not send change qmp command if media source is null. So
the media is not be replace to the null.

So close the BlockDriverState in bdrv_eject. Thanks.

diff --git a/block.c b/block.c
index d3aebeb..0be69de 100644
--- a/block.c
+++ b/block.c
@@ -5276,6 +5276,10 @@ void bdrv_eject(BlockDriverState *bs, bool eject_flag)
         qapi_event_send_device_tray_moved(bdrv_get_device_name(bs),
                                           eject_flag, &error_abort);
     }
+
+    if (eject_flag) {
+        bdrv_close(bs);
+    }
 }

^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2014-10-27  8:23 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-18 10:02 [Qemu-devel] Close the BlockDriverState when guest eject the media Weidong Huang
2014-10-20  9:41 ` Kevin Wolf
2014-10-20 11:27   ` Weidong Huang
2014-10-20 11:39     ` Kevin Wolf
2014-10-21  0:46       ` Weidong Huang
2014-10-21  5:53       ` Weidong Huang
2014-10-21  6:10         ` Gonglei
2014-10-24 18:32           ` Eric Blake
2014-10-27  8:21             ` Markus Armbruster
2014-10-20 12:12     ` Markus Armbruster
2014-10-21  5:06       ` Weidong Huang
2014-10-21  8:33         ` Markus Armbruster
2014-10-21  9:17           ` Gonglei

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).