qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] block: Fail if requested driver is not available
@ 2013-11-11 13:54 Kevin Wolf
  2013-11-11 14:11 ` Jeff Cody
  2013-11-14 13:13 ` Stefan Hajnoczi
  0 siblings, 2 replies; 3+ messages in thread
From: Kevin Wolf @ 2013-11-11 13:54 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf

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 <kwolf@redhat.com>
---
 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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] block: Fail if requested driver is not available
  2013-11-11 13:54 [Qemu-devel] [PATCH] block: Fail if requested driver is not available Kevin Wolf
@ 2013-11-11 14:11 ` Jeff Cody
  2013-11-14 13:13 ` Stefan Hajnoczi
  1 sibling, 0 replies; 3+ messages in thread
From: Jeff Cody @ 2013-11-11 14:11 UTC (permalink / raw)
  To: Kevin Wolf; +Cc: qemu-devel

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 <kwolf@redhat.com>
> ---
>  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 <jcody@redhat.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] block: Fail if requested driver is not available
  2013-11-11 13:54 [Qemu-devel] [PATCH] block: Fail if requested driver is not available Kevin Wolf
  2013-11-11 14:11 ` Jeff Cody
@ 2013-11-14 13:13 ` Stefan Hajnoczi
  1 sibling, 0 replies; 3+ messages in thread
From: Stefan Hajnoczi @ 2013-11-14 13:13 UTC (permalink / raw)
  To: Kevin Wolf; +Cc: qemu-devel

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 <kwolf@redhat.com>
> ---
>  block.c                    | 5 +++++
>  tests/qemu-iotests/051     | 7 +++++++
>  tests/qemu-iotests/051.out | 9 +++++++++
>  3 files changed, 21 insertions(+)

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-11-14 13:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-11 13:54 [Qemu-devel] [PATCH] block: Fail if requested driver is not available Kevin Wolf
2013-11-11 14:11 ` Jeff Cody
2013-11-14 13:13 ` Stefan Hajnoczi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).