Revision 765003db
b/block.c | ||
---|---|---|
832 | 832 |
filename = qdict_get_try_str(options, "filename"); |
833 | 833 |
} |
834 | 834 |
|
835 |
if (drv->bdrv_needs_filename && !filename) { |
|
836 |
error_setg(errp, "The '%s' block driver requires a file name", |
|
837 |
drv->format_name); |
|
838 |
return -EINVAL; |
|
839 |
} |
|
840 |
|
|
835 | 841 |
trace_bdrv_open_common(bs, filename ?: "", flags, drv->format_name); |
836 | 842 |
|
837 | 843 |
node_name = qdict_get_try_str(options, "node-name"); |
... | ... | |
1031 | 1037 |
goto fail; |
1032 | 1038 |
} |
1033 | 1039 |
qdict_del(options, "filename"); |
1034 |
} else if (drv->bdrv_needs_filename && !filename) { |
|
1035 |
error_setg(errp, "The '%s' block driver requires a file name", |
|
1036 |
drv->format_name); |
|
1037 |
ret = -EINVAL; |
|
1038 |
goto fail; |
|
1039 | 1040 |
} |
1040 | 1041 |
|
1041 | 1042 |
if (!drv->bdrv_file_open) { |
b/tests/qemu-iotests/051 | ||
---|---|---|
172 | 172 |
run_qemu -drive file="$TEST_IMG",file.driver=qcow2 |
173 | 173 |
|
174 | 174 |
echo |
175 |
echo === Leaving out required options === |
|
176 |
echo |
|
177 |
|
|
178 |
run_qemu -drive driver=file |
|
179 |
run_qemu -drive driver=nbd |
|
180 |
run_qemu -drive driver=raw |
|
181 |
run_qemu -drive file.driver=file |
|
182 |
run_qemu -drive file.driver=nbd |
|
183 |
run_qemu -drive file.driver=raw |
|
184 |
run_qemu -drive foo=bar |
|
185 |
|
|
186 |
echo |
|
175 | 187 |
echo === Parsing protocol from file name === |
176 | 188 |
echo |
177 | 189 |
|
b/tests/qemu-iotests/051.out | ||
---|---|---|
225 | 225 |
QEMU_PROG: -drive file=TEST_DIR/t.qcow2,file.driver=qcow2: could not open disk image TEST_DIR/t.qcow2: Block format 'qcow2' used by device '' doesn't support the option 'filename' |
226 | 226 |
|
227 | 227 |
|
228 |
=== Leaving out required options === |
|
229 |
|
|
230 |
Testing: -drive driver=file |
|
231 |
QEMU_PROG: -drive driver=file: could not open disk image ide0-hd0: The 'file' block driver requires a file name |
|
232 |
|
|
233 |
Testing: -drive driver=nbd |
|
234 |
QEMU_PROG: -drive driver=nbd: could not open disk image ide0-hd0: Could not open image: Invalid argument |
|
235 |
|
|
236 |
Testing: -drive driver=raw |
|
237 |
QEMU_PROG: -drive driver=raw: could not open disk image ide0-hd0: Can't use 'raw' as a block driver for the protocol level |
|
238 |
|
|
239 |
Testing: -drive file.driver=file |
|
240 |
QEMU_PROG: -drive file.driver=file: could not open disk image ide0-hd0: The 'file' block driver requires a file name |
|
241 |
|
|
242 |
Testing: -drive file.driver=nbd |
|
243 |
QEMU_PROG: -drive file.driver=nbd: could not open disk image ide0-hd0: Could not open image: Invalid argument |
|
244 |
|
|
245 |
Testing: -drive file.driver=raw |
|
246 |
QEMU_PROG: -drive file.driver=raw: could not open disk image ide0-hd0: Can't use 'raw' as a block driver for the protocol level |
|
247 |
|
|
248 |
Testing: -drive foo=bar |
|
249 |
QEMU_PROG: -drive foo=bar: could not open disk image ide0-hd0: Must specify either driver or file |
|
250 |
|
|
251 |
|
|
228 | 252 |
=== Parsing protocol from file name === |
229 | 253 |
|
230 | 254 |
Testing: -hda foo:bar |
Also available in: Unified diff