[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 11/11] block: Fail if requested driver is not availab
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 11/11] block: Fail if requested driver is not available |
Date: |
Fri, 15 Nov 2013 18:53:19 +0100 |
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 <address@hidden>
Reviewed-by: Jeff Cody <address@hidden>
Reviewed-by: Stefan Hajnoczi <address@hidden>
---
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 38078f7..382ea71 100644
--- a/block.c
+++ b/block.c
@@ -1137,6 +1137,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 0a4971d..3a75bda 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 d351935..8769c8e 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
- [Qemu-devel] [PULL 02/11] qapi-schema: Update description for NewImageMode, (continued)
- [Qemu-devel] [PULL 02/11] qapi-schema: Update description for NewImageMode, Kevin Wolf, 2013/11/15
- [Qemu-devel] [PULL 01/11] block: Print its file name if backing file opening failed, Kevin Wolf, 2013/11/15
- [Qemu-devel] [PULL 03/11] block/drive-mirror: Check for NULL backing_hd, Kevin Wolf, 2013/11/15
- [Qemu-devel] [PULL 05/11] MAINTAINERS: add block tree repo URLs, Kevin Wolf, 2013/11/15
- [Qemu-devel] [PULL 04/11] qemu-iotests: Extend 041 for unbacked mirroring, Kevin Wolf, 2013/11/15
- [Qemu-devel] [PULL 07/11] qcow2: fix possible corruption when reading multiple clusters, Kevin Wolf, 2013/11/15
- [Qemu-devel] [PULL 06/11] qmp: access the local QemuOptsLists for drive option, Kevin Wolf, 2013/11/15
- [Qemu-devel] [PULL 08/11] qemu-iotests: Test qcow2 count_contiguous_clusters(), Kevin Wolf, 2013/11/15
- [Qemu-devel] [PULL 10/11] MAINTAINERS: add block driver sub-maintainers, Kevin Wolf, 2013/11/15
- [Qemu-devel] [PULL 09/11] qemu-img: Fix overwriting 'ret' before using, Kevin Wolf, 2013/11/15
- [Qemu-devel] [PULL 11/11] block: Fail if requested driver is not available,
Kevin Wolf <=