From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44986) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aHGxA-0000XH-Uj for qemu-devel@nongnu.org; Thu, 07 Jan 2016 15:14:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aHGx9-0004kX-Uf for qemu-devel@nongnu.org; Thu, 07 Jan 2016 15:14:36 -0500 References: <1447164580-31094-1-git-send-email-kwolf@redhat.com> <1447164580-31094-11-git-send-email-kwolf@redhat.com> <568EBE85.2040608@redhat.com> From: Max Reitz Message-ID: <568EC721.3000009@redhat.com> Date: Thu, 7 Jan 2016 21:14:25 +0100 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="CtPUPMSdP8u9htvhBjB4gN3isDdxKQj91" Subject: Re: [Qemu-devel] [PULL v2 10/40] blockdev: Implement change with basic operations List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: Kevin Wolf , Peter Crosthwaite , QEMU Developers , Qemu-block This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --CtPUPMSdP8u9htvhBjB4gN3isDdxKQj91 Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: quoted-printable On 07.01.2016 20:56, Peter Maydell wrote: > On 7 January 2016 at 19:37, Max Reitz 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 wou= ld >> 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: Fo= r >> 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. >=20 > 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 --CtPUPMSdP8u9htvhBjB4gN3isDdxKQj91 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJWjschAAoJEDuxQgLoOKytTNQIAKFSo/iCiNRgxGZu6yTf5XC3 sUJQngqqu5gpeXw6FJ6Xd/QHrAYpwpbdd0xO9DNbIwMSeHXLRqeS0EsXhyRBq3+B vzFDc0vOckeS6RR/f62tvYOGr1MQeVh9Yz0Ye5wMhO4XKCrVa7F3enMEM/YhMDyb 2vkAmLIT3XIHU7t7jggjqpNrqq8kWbR+IilwMxoYVv7DqYYvRN6er1BBRpR5Dbtk LSyMqRZHmaDwCsU8vKCfSfGIyVvGFgnFUHfrTv1CHrHJu4EIdTha1DAJ8Ep4OV7h QuuwyEZgbVZboX1WJSFQwkbTHtIt5t9IN/1Co2Mlsp5PFG6EJ/XmA7EyY2HRWjw= =5iaM -----END PGP SIGNATURE----- --CtPUPMSdP8u9htvhBjB4gN3isDdxKQj91--