[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v2 0/3] block: Correct size across CD-ROM media
Re: [Qemu-devel] [PATCH v2 0/3] block: Correct size across CD-ROM media change
Wed, 30 Mar 2011 10:33:49 +0200
Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)
Stefan Hajnoczi <address@hidden> writes:
> This patch series fixes two Linux host CD-ROM pass-through bugs in QEMU.
> After applying these patches it is possible to pass-through a Linux host
> completely. The guest can eject from software or the physical eject button
> be pressed on the drive. The guest can detect this and newly inserted media
> are noticed. There is no need to issue any QEMU monitor 'eject' or 'change'
> commands because the host CD-ROM is completely "passed through".
Things can get confusing here, as "eject" is an overloaded term :)
Let me try to preempt such confusion. We have three separate actions to
consider: OS opening and closing the tray, and QEMU monitor commands
"eject" and "change", and the user inserting/removing media from a
On bare metal, OS open/close tray affects the physical tray the obvious
way. The user can insert/remove media while the tray is open.
A virtual CD-ROM is backed by a QEMU block device (the things "info
block" shows). The block device can be empty (seen by the gues OS as
"no media"), or it can be connected to a file. Monitor commands "eject"
and "change" manipulate that connection.
Guest OS open/close tray affects the virtual tray the obvious way. In
particular, if the OS opens, then closes the tray, it gets the same
media back, unless the user changed it[*].
Normally, a block device's file is an image file. Monitor commands
"eject" and "change" are seen by the guest OS as media change.
Besides image files, we can also use host block devices. This adds
another way to change media: The user can insert/remove physical media
while the physical tray is open.
Regardless, monitor commands "eject" and "change" still work, and are
still seen by the guest OS as media change.
> Patch details:
> The first is that the device size is cached even for removable devices and we
> never update it. If a host CD-ROM is changed, then the size will be stale and
> reflect that of the last medium.
> The second is that Linux host CD-ROM pass-through requires that we re-open the
> device to refresh its size. This is because the Linux CD-ROM driver only
> refreshes the size when the device is opened and furthermore has a bug that
> leads to stale sizes if the file descriptor is held across media change.
> I have also included a trace event for bdrv_set_locked() because it is useful
> information when debugging issues like these in the future.
> * Clarify cdrom_is_inserted() comment as per Juan's suggestion
I plan to give these patches a swirl to see how they affect some other
CD-ROM weirdness I'm debugging. Thanks!
[*] Used not to work, see commit 4be9762a.