qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PULL v2 10/40] blockdev: Implement change with basic o


From: Max Reitz
Subject: Re: [Qemu-devel] [PULL v2 10/40] blockdev: Implement change with basic operations
Date: Thu, 7 Jan 2016 21:14:25 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.0

On 07.01.2016 20:56, Peter Maydell wrote:
> On 7 January 2016 at 19:37, Max Reitz <address@hidden> wrote:
>> Compare floppy disks, for which we now have a "virtual" tray status:
>> Whenever a medium is inserted, the "tray" is considered closed.
>> Otherwise, it is open. This works pretty much like a physical tray would
>> work; whenever the tray is closed, you cannot exchange the medium, but
>> when it is open, you can.
>>
>> There is only one difference to devices which actually have a tray: For
>> floppy disks, you cannot have a closed tray without a medium in it.
>>
>> Anyway, we can implement the same model for SD cards. I'll see to it.
> 
> It looks like sd.c is the only one which implements a change_media_cb
> but no is_tray_open, but it would be nice if we could implement this
> in the default blk_dev_is_tray_open() method rather than in the
> sd and floppy models (ie if I don't implement tray-open then the
> tray is closed if there's a medium attached, and the block backend
> ought to know if there's a medium attached itself already).

That would be nice, but there's a difference between "there's a medium
attached" (tray can be both open and closed) and "the medium is
accessible by the guest" (tray must be closed). The BlockBackend does
not know this difference, only the guest devices does.

It gets told of when to open/close the tray by invocation of the
change_media_cb() (the @load parameter set to false or true,
respectively), and we could track this state in the BlockBackend instead
of in the SDState. But that looks like the wrong place to me.

Right now, sd.c completely ignores the @load parameter of
change_media_cb(), which seems wrong; this means that "opening the tray"
keeps the medium accessible for the guest. In the past that was fine,
because eject closed the associated BDS (the medium) right afterwards,
so it actually wasn't accessible any more. The new
blockdev-open-tray no longer does that, so now we need to respect the
value of @load and no longer rely on blk_is_inserted() alone any more.

Therefore, I believe we need to track the medium insertion state in
SDState, because this fixes the issue of having ignored @load (which
kept the SD card accessible to the guest even after blockdev-open-tray).

We can then use this tracked state to fix this issue here, by
implementing a trivial is_tray_open() which simply returns false iff
there is a medium inserted into the slot.

Max

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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