From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46370) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aHIc7-0007i1-1e for qemu-devel@nongnu.org; Thu, 07 Jan 2016 17:00:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aHIc2-0001n1-26 for qemu-devel@nongnu.org; Thu, 07 Jan 2016 17:00:58 -0500 References: <1452200608-524-1-git-send-email-mreitz@redhat.com> <1452200608-524-2-git-send-email-mreitz@redhat.com> From: Max Reitz Message-ID: <568EE010.1080006@redhat.com> Date: Thu, 7 Jan 2016 23:00:48 +0100 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="7vbMsHcrXsCQ5umifraXWQUo8Pw3sXw8x" Subject: Re: [Qemu-devel] [PATCH 1/2] hw/sd: Add medium insertion status List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: Markus Armbruster , QEMU Developers , Stefan Hajnoczi , qemu-stable This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --7vbMsHcrXsCQ5umifraXWQUo8Pw3sXw8x Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 07.01.2016 22:45, Peter Maydell wrote: > On 7 January 2016 at 21:03, Max Reitz wrote: >> Right now, the change_media_cb (sd_cardchange()) completely ignores it= s >> @load parameter. This means that issuing a blockdev-open-tray command >> will actually not have any effect. >> >> Fix this by keeping track of the medium insertion status in the SDStat= e >> and updating it in sd_init() and sd_cardchange(). >> >> Cc: qemu-stable >> Signed-off-by: Max Reitz >> --- >> hw/sd/sd.c | 16 ++++++++++------ >> 1 file changed, 10 insertions(+), 6 deletions(-) >> >> diff --git a/hw/sd/sd.c b/hw/sd/sd.c >> index 1a9935c..0751ba2 100644 >> --- a/hw/sd/sd.c >> +++ b/hw/sd/sd.c >> @@ -114,6 +114,7 @@ struct SDState { >> uint8_t *buf; >> >> bool enable; >> + bool medium_inserted; >=20 > When would this be different from blk_is_inserted(sd->blk) ? First, whenever you use a host CD-ROM drive for an SD card. But I highly doubt this worked before, because the device model is actually never notified if the medium in the host drive is exchanged. For any other medium, blk_is_inserted() should generally be always true. Second, whenever the change_media_cb is called with @load set to false. This means that the medium is to be unloaded, which was completely ignored by sd.c so far (see commit message). It just interpreted a call to sd_cardchange() as a notification that the medium might have changed, but this is wrong. > I don't see why we need a separate flag here rather > than querying the block layer. Because of the second case. > If we do need a flag, why doesn't it need to be migrated? Oh, yes, you're right, it probably should. Max --7vbMsHcrXsCQ5umifraXWQUo8Pw3sXw8x 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 iQEcBAEBCAAGBQJWjuAQAAoJEDuxQgLoOKytKCQH/RjtA9i1zp29MkwL4LEqXHGW J0WnXD7zQSr5gjcV3/OvF1NC2b3Zr3gZSwKO2kwJdIjZsSe28EuoCUEsdDNkvZLn YfLlSKXV7iM0FWtygIvYEJZnfjRt+82h3JAiUbSDu8S/9usVAahreR6vpRkILdpW pl6a5T32or6RsPMhEesM8pVKhbmOJstvJ7elomn/eLIpq7ZYsZIPbIH3tmOUyKdM DRN9eI5d6/rS+TJdk9xyLvhHpYYeIp6MDlhiL8WZ02TgaJFrkzByRZwZWtLd6bfU FqvoShusPWnvEIlSDSTCA3+pijkuK3sntjHjHV90PQX+IptRJBiwLVKWJ6+Jtx4= =tKrw -----END PGP SIGNATURE----- --7vbMsHcrXsCQ5umifraXWQUo8Pw3sXw8x--