From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:45400) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UQmne-00087u-Vn for qemu-devel@nongnu.org; Fri, 12 Apr 2013 18:50:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UQmnd-00051r-Jn for qemu-devel@nongnu.org; Fri, 12 Apr 2013 18:50:30 -0400 Received: from mx1.redhat.com ([209.132.183.28]:7214) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UQmnd-00051Y-Bd for qemu-devel@nongnu.org; Fri, 12 Apr 2013 18:50:29 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r3CMoSBp011697 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 12 Apr 2013 18:50:28 -0400 Message-ID: <51688FB3.4000102@redhat.com> Date: Fri, 12 Apr 2013 16:50:27 -0600 From: Eric Blake MIME-Version: 1.0 References: <1365799688-19918-1-git-send-email-kwolf@redhat.com> <1365799688-19918-2-git-send-email-kwolf@redhat.com> In-Reply-To: <1365799688-19918-2-git-send-email-kwolf@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="----enig2BEVAHHCXOILOCQWTJEHV" Subject: Re: [Qemu-devel] [PATCH 01/15] block: Fail gracefully when using a format driver on protocol level List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf Cc: qemu-devel@nongnu.org, stefanha@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) ------enig2BEVAHHCXOILOCQWTJEHV Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 04/12/2013 02:47 PM, Kevin Wolf wrote: > Specifying the wrong driver could fail an assertion: >=20 > $ qemu-system-x86_64 -drive file.driver=3Dqcow2,file=3Dx > qemu-system-x86_64: block.c:721: bdrv_open_common: Assertion `file !=3D= > ((void *)0)' failed. >=20 > Signed-off-by: Kevin Wolf > --- > block.c | 7 +++++++ > tests/qemu-iotests/051 | 7 +++++++ > tests/qemu-iotests/051.out | 10 ++++++++++ > 3 files changed, 24 insertions(+) >=20 > diff --git a/block.c b/block.c > index 602d8a4..f23bdcc 100644 > --- a/block.c > +++ b/block.c > @@ -718,6 +718,13 @@ static int bdrv_open_common(BlockDriverState *bs, = BlockDriverState *file, > assert(drv->bdrv_parse_filename || filename !=3D NULL); > ret =3D drv->bdrv_file_open(bs, filename, options, open_flags)= ; > } else { > + if (file =3D=3D NULL) { > + qerror_report(ERROR_CLASS_GENERIC_ERROR, "The '%s' block d= river is " > + "not suitable for the bottom level", > + drv->format_name); > + ret =3D -EINVAL; > + goto free_and_fail; > + } > assert(file !=3D NULL); Is it really necessary to leave the assert in place, now that you have a check for NULL followed by unconditional goto? Just reading that error message, I'm not quite sure what you meant by "not suitable for the bottom level". I guess the intent is that file.driver specifies the protocol, and that both raw and qcow2 are formats possible on the file protocol, rather than qcow2 being a file protocol itself. > +Testing: -drive file=3DTEST_DIR/t.qcow2,file.driver=3Dqcow2 > +qemu: -drive file=3DTEST_DIR/t.qcow2,file.driver=3Dqcow2: The 'qcow2' = block driver is not suitable for the bottom level > +qemu: -drive file=3DTEST_DIR/t.qcow2,file.driver=3Dqcow2: could not op= en disk image TEST_DIR/t.qcow2: Invalid argument Maybe a better error message would be this? Attempt to use format driver 'qcow2' where a protocol driver was expected= --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org ------enig2BEVAHHCXOILOCQWTJEHV 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.13 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJRaI+zAAoJEKeha0olJ0Nq410H+QHSBA1RboSRx+Y+/94N0UP5 yFUxs9HocVeTkZVWsph5bOz61m8RPNacQ9JB32zzXyAsM9mBXShT42J4785h0e58 gGfjLVYUenTNYZPJors77WsmXm3K3hi3FSXnUJfQINF7cKXCpRzScgea3ggS7+ue NJurkAbR9I1F3BRkTujkI6/3NrD3E205nD3PIoTRE1hT5Qu72tTd0T6pKWyGyq++ htiqV2RZFjjzaQjFzuU0oDb23/oj5bC1aeOaG6FjI+8Vsu4OxiJUM9APRSU/QPtt INmY5REy1Prdy40c/0DcBh8h/HD+Ti1EWs4EMZ7M2HsdvvpIkoOIm7ZIhxJOra4= =BrZn -----END PGP SIGNATURE----- ------enig2BEVAHHCXOILOCQWTJEHV--