All of lore.kernel.org
 help / color / mirror / Atom feed
From: Weidong Huang <hwd@huawei.com>
To: "qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Cc: kwolf@redhat.com, stefanha@redhat.com
Subject: [Qemu-devel] Close the BlockDriverState when guest eject the media
Date: Sat, 18 Oct 2014 18:02:49 +0800	[thread overview]
Message-ID: <54423AC9.2030302@huawei.com> (raw)

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);
+    }
 }

             reply	other threads:[~2014-10-18 10:03 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-18 10:02 Weidong Huang [this message]
2014-10-20  9:41 ` [Qemu-devel] Close the BlockDriverState when guest eject the media 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=54423AC9.2030302@huawei.com \
    --to=hwd@huawei.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.