From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54666) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VR3B2-0000hc-Hf for qemu-devel@nongnu.org; Tue, 01 Oct 2013 12:52:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VR3Aw-0000N6-AO for qemu-devel@nongnu.org; Tue, 01 Oct 2013 12:52:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:29339) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VR3Aw-0000N0-2R for qemu-devel@nongnu.org; Tue, 01 Oct 2013 12:51:54 -0400 Message-ID: <524AFDA2.7030702@redhat.com> Date: Tue, 01 Oct 2013 10:51:46 -0600 From: Eric Blake MIME-Version: 1.0 References: <1380633619-12213-1-git-send-email-kwolf@redhat.com> <1380633619-12213-14-git-send-email-kwolf@redhat.com> In-Reply-To: <1380633619-12213-14-git-send-email-kwolf@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="rExEcuFiTTXUQG6iFG2ME2CTH3GwBIQQr" Subject: Re: [Qemu-devel] [PATCH v2 13/17] blockdev: Remove IF_* check for read-only blockdev_init List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf Cc: benoit.canet@irqsave.net, armbru@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com, stefanha@redhat.com, xiawenc@linux.vnet.ibm.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --rExEcuFiTTXUQG6iFG2ME2CTH3GwBIQQr Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 10/01/2013 07:20 AM, Kevin Wolf wrote: > IF_NONE allows read-only, which makes forbidding it in this place > for other types pretty much pointless. >=20 > Instead, make sure that all devices for which the check would have > errored out check in their init function that they don't get a read-onl= y > BlockDriverState. This catches even cases where IF_NONE and -device is > used. >=20 > Signed-off-by: Kevin Wolf > --- > blockdev.c | 6 ------ > hw/block/m25p80.c | 5 +++++ > hw/block/xen_disk.c | 5 +++++ > hw/sd/milkymist-memcard.c | 4 ++++ > hw/sd/omap_mmc.c | 6 ++++++ > hw/sd/pl181.c | 4 ++++ > hw/sd/pxa2xx_mmci.c | 3 +++ > hw/sd/sd.c | 5 +++++ > hw/sd/sdhci.c | 3 +++ > hw/sd/ssi-sd.c | 3 +++ > tests/qemu-iotests/051.out | 5 ++++- > 11 files changed, 42 insertions(+), 7 deletions(-) > +++ b/hw/sd/omap_mmc.c > @@ -593,6 +593,9 @@ struct omap_mmc_s *omap_mmc_init(hwaddr base, > =20 > /* Instantiate the storage */ > s->card =3D sd_init(bd, false); > + if (s->card =3D=3D NULL) { > + exit(1); No error message about why the exit? Also, is it worth using EXIT_FAILURE instead of a magic number? > +++ b/hw/sd/sd.c > @@ -494,6 +494,11 @@ SDState *sd_init(BlockDriverState *bs, bool is_spi= ) > { > SDState *sd; > =20 > + if (bdrv_is_read_only(bs)) { > + fprintf(stderr, "sd_init: Cannot use read-only drive\n"); > + return NULL; Oh, I guess there IS an error message before exit. And you're not the first person to not use EXIT_FAILURE. So I can live with the patch as-is. Reviewed-by: Eric Blake --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --rExEcuFiTTXUQG6iFG2ME2CTH3GwBIQQr Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.14 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJSSv2iAAoJEKeha0olJ0NqQ1IH/06MGhmCjQzeGWRkYr4Xb3rY esXnj+3HMrE4+TGVSbkLGhqddBLsxuWEs5TCOQVwVkLTVVtZX1wL1qcq9MC2fv3N eBbOSgw1sbK05owt3xuIZRdNKyye2R8zbkqNhljMRqT5AxdosnQECbEU5fVET3T5 i2rGH4wz8puiWjdSENJNQ4512nXoKXRRtADAXiiAfNsQXmxuM/AbMGtSk0UaIo6v oXTWTvMHwB3yonV1ZIf8thSif2j+1Rf/vJVwa2J5oqCzPBJg06wdkRYFBUSngPMv Wa6JNaZl9eV4uWQMZXCN89+XedNG21yLls/OM0fHejrps/0PbR4AXqwCNdK82tk= =XAoU -----END PGP SIGNATURE----- --rExEcuFiTTXUQG6iFG2ME2CTH3GwBIQQr--