From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54815) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VfsDU-00060O-Gn for qemu-devel@nongnu.org; Mon, 11 Nov 2013 09:11:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VfsDO-0001rT-H0 for qemu-devel@nongnu.org; Mon, 11 Nov 2013 09:11:48 -0500 Received: from mx1.redhat.com ([209.132.183.28]:44377) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VfsDO-0001rM-8H for qemu-devel@nongnu.org; Mon, 11 Nov 2013 09:11:42 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id rABEBe2L020363 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 11 Nov 2013 09:11:41 -0500 Date: Mon, 11 Nov 2013 09:11:39 -0500 From: Jeff Cody Message-ID: <20131111141139.GA5203@localhost.localdomain> References: <1384178099-11022-1-git-send-email-kwolf@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1384178099-11022-1-git-send-email-kwolf@redhat.com> Subject: Re: [Qemu-devel] [PATCH] block: Fail if requested driver is not available List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf Cc: qemu-devel@nongnu.org On Mon, Nov 11, 2013 at 02:54:59PM +0100, Kevin Wolf wrote: > If an explicit driver option is present, but doesn't specify a valid > driver, then bdrv_open() should fail instead of probing the format. > > Signed-off-by: Kevin Wolf > --- > block.c | 5 +++++ > tests/qemu-iotests/051 | 7 +++++++ > tests/qemu-iotests/051.out | 9 +++++++++ > 3 files changed, 21 insertions(+) > > diff --git a/block.c b/block.c > index d7de89d..6256b09 100644 > --- a/block.c > +++ b/block.c > @@ -1130,6 +1130,11 @@ int bdrv_open(BlockDriverState *bs, const char *filename, QDict *options, > if (drvname) { > drv = bdrv_find_format(drvname); > qdict_del(options, "driver"); > + if (!drv) { > + error_setg(errp, "Invalid driver: '%s'", drvname); > + ret = -EINVAL; > + goto unlink_and_fail; > + } > } > > if (!drv) { > diff --git a/tests/qemu-iotests/051 b/tests/qemu-iotests/051 > index b1480a8..4df8058 100755 > --- a/tests/qemu-iotests/051 > +++ b/tests/qemu-iotests/051 > @@ -78,6 +78,13 @@ run_qemu -drive file="$TEST_IMG",format=qcow2,unknown_opt=1234 > run_qemu -drive file="$TEST_IMG",format=qcow2,unknown_opt=foo > > echo > +echo === Invalid format === > +echo > + > +run_qemu -drive file="$TEST_IMG",format=foo > +run_qemu -drive file="$TEST_IMG",driver=foo > + > +echo > echo === Overriding backing file === > echo > > diff --git a/tests/qemu-iotests/051.out b/tests/qemu-iotests/051.out > index 1ee010d..088735a 100644 > --- a/tests/qemu-iotests/051.out > +++ b/tests/qemu-iotests/051.out > @@ -17,6 +17,15 @@ Testing: -drive file=TEST_DIR/t.qcow2,format=qcow2,unknown_opt=foo > QEMU_PROG: -drive file=TEST_DIR/t.qcow2,format=qcow2,unknown_opt=foo: could not open disk image TEST_DIR/t.qcow2: Block format 'qcow2' used by device 'ide0-hd0' doesn't support the option 'unknown_opt' > > > +=== Invalid format === > + > +Testing: -drive file=TEST_DIR/t.qcow2,format=foo > +QEMU_PROG: -drive file=TEST_DIR/t.qcow2,format=foo: 'foo' invalid format > + > +Testing: -drive file=TEST_DIR/t.qcow2,driver=foo > +QEMU_PROG: -drive file=TEST_DIR/t.qcow2,driver=foo: could not open disk image TEST_DIR/t.qcow2: Invalid driver: 'foo' > + > + > === Overriding backing file === > > Testing: -drive file=TEST_DIR/t.qcow2,driver=qcow2,backing.file.filename=TEST_DIR/t.qcow2.orig -nodefaults > -- > 1.8.1.4 > > Reviewed-by: Jeff Cody