From: Paolo Bonzini <pbonzini@redhat.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: Kevin Wolf <kwolf@redhat.com>,
eblake@redhat.com, qemu-devel@nongnu.org,
Luiz Capitulino <lcapitulino@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 4/4] qmp: add BLOCK_MEDIUM_EJECT event
Date: Fri, 17 Feb 2012 11:45:33 +0100 [thread overview]
Message-ID: <4F3E2FCD.8040501@redhat.com> (raw)
In-Reply-To: <m3zkcivdfu.fsf@blackfin.pond.sub.org>
On 02/16/2012 07:30 PM, Markus Armbruster wrote:
> 3. Physical load/eject with pass-through device
>
> The host_cdrom backend's tray handling is rudimentary. But let me
> sketch how a real implementation could work.
>
> 3a. User closes tray, or opens unlocked tray
>
> Backend gets notified, calls into block layer. Block layer notifies
> device model. Device model notifies guest OS.
>
> 3b. User presses button while tray is closed and locked
>
> Backend gets notified, calls into block layer. Block layer notifies
> device model. Device model notifies guest OS. Guest OS may command
> tray open. Goto 1.
>
> We should be able to emit suitable events in the block layer.
Here is how I had implemented it; it is similar enough:
3a. User closes tray, or opens unlocked tray
The device model polls the block layer that in turn asks the backend.
Device model notifies guest OS.
The block layer could look at the results of polling before passing them
to the device model and emit events.
3b. User presses button while tray is closed and locked
If the guest doesn't poll the device model, there is nothing to do.
If the guest polls the device model, the device model passes the request
to the block layer that in turn asks the backend. But this doesn't
generate any event unless the guest OS commands tray open. If it does,
goto 1.
> I figure Luiz's patch works. But maybe it could be simplified some by
> replacing bdrv_dev_change_media_cb() by a "open/close tray" callback
> that returns whether it moved. bdrv_dev_change_media_cb() would then
> simply open the tray, emit event if it moved, close the tray, emit event
> if it moved.
The device models' change_media_cb is already effectively an open/close
tray callback. You do not need a check in the callback, you can simply
call the is_tray_open callback. bdrv_dev_change_media_cb can stop
calling the callback unless the tray moved, and
eject_device+qmp_bdrv_open_encrypted can call bdrv_dev_change_media_cb
respectively to open and close the tray. This would also fix the wart
with no medium, IIUC.
> [*] Can happen only in the warty case. Or when the guest closes the
> tray before us. I'm not sure that works.
The guest cannot beat us to this race because the monitor and MMIO are
both protected by the global mutex.
Paolo
next prev parent reply other threads:[~2012-02-17 10:45 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-15 18:42 [Qemu-devel] [PATCH v2 0/4]: QMP: add BLOCK_MEDIUM_EJECT event Luiz Capitulino
2012-02-15 18:42 ` [Qemu-devel] [PATCH 1/4] block: Rename bdrv_mon_event() & BlockMonEventAction Luiz Capitulino
2012-02-15 18:42 ` [Qemu-devel] [PATCH 2/4] block: bdrv_eject(): Make eject_flag a real bool Luiz Capitulino
2012-02-15 18:42 ` [Qemu-devel] [PATCH 3/4] block: bdrv_eject(): Add tray_changed parameter Luiz Capitulino
2012-02-15 18:42 ` [Qemu-devel] [PATCH 4/4] qmp: add BLOCK_MEDIUM_EJECT event Luiz Capitulino
2012-02-16 9:25 ` Markus Armbruster
2012-02-16 13:14 ` Luiz Capitulino
2012-02-16 13:19 ` Luiz Capitulino
2012-02-16 13:31 ` Kevin Wolf
2012-02-16 14:10 ` Luiz Capitulino
2012-02-17 10:32 ` Paolo Bonzini
2012-02-17 11:03 ` Kevin Wolf
2012-02-17 11:48 ` Markus Armbruster
2012-02-17 12:12 ` Kevin Wolf
2012-02-17 12:43 ` Markus Armbruster
2012-02-16 18:30 ` Markus Armbruster
2012-02-16 19:08 ` Luiz Capitulino
2012-02-17 9:53 ` Kevin Wolf
2012-02-17 10:48 ` Paolo Bonzini
2012-02-17 11:50 ` Markus Armbruster
2012-02-17 11:44 ` Markus Armbruster
2012-02-17 11:56 ` Luiz Capitulino
2012-02-17 10:45 ` Paolo Bonzini [this message]
2012-02-17 11:57 ` Markus Armbruster
2012-02-17 10:49 ` [Qemu-devel] [PATCH v2 0/4]: QMP: " Paolo Bonzini
2012-02-17 11:58 ` Luiz Capitulino
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=4F3E2FCD.8040501@redhat.com \
--to=pbonzini@redhat.com \
--cc=armbru@redhat.com \
--cc=eblake@redhat.com \
--cc=kwolf@redhat.com \
--cc=lcapitulino@redhat.com \
--cc=qemu-devel@nongnu.org \
/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 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).