block: Fail gracefully with missing filename

This fixes a regression introduced in commit 2a05cbe42 ('block: Allow
block devices without files'):

$ qemu-system-x86_64 -drive driver=file
qemu-system-x86_64: block.c:892: bdrv_open_common: Assertion
`!drv->bdrv_needs_filename || filename != ((void *)0)' failed.

Now the respective check must be performed not only in bdrv_file_open(),
but also in bdrv_open().

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
Kevin Wolf 2014-02-03 14:49:42 +01:00
parent 170632dbc9
commit 765003db02
3 changed files with 42 additions and 5 deletions

View file

@ -171,6 +171,18 @@ echo
run_qemu -drive file="$TEST_IMG",file.driver=file
run_qemu -drive file="$TEST_IMG",file.driver=qcow2
echo
echo === Leaving out required options ===
echo
run_qemu -drive driver=file
run_qemu -drive driver=nbd
run_qemu -drive driver=raw
run_qemu -drive file.driver=file
run_qemu -drive file.driver=nbd
run_qemu -drive file.driver=raw
run_qemu -drive foo=bar
echo
echo === Parsing protocol from file name ===
echo