[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v3 10/21] block: Allow block devices without files
From: |
Max Reitz |
Subject: |
[Qemu-devel] [PATCH v3 10/21] block: Allow block devices without files |
Date: |
Wed, 11 Dec 2013 19:11:02 +0100 |
blkdebug and blkverify will, in order to retain compatibility, not
support the field "file" implicitly through bdrv_open(). In order to be
able to use those drivers without giving a filename anyway, it is
necessary to be able to have block devices without files implicitly
opened by bdrv_open(). This is the case, if there was neither a file
name, a reference to an existing block device to use as a file nor
options specific to the file.
Signed-off-by: Max Reitz <address@hidden>
---
block.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/block.c b/block.c
index 4a2c251..33ef995 100644
--- a/block.c
+++ b/block.c
@@ -1147,11 +1147,14 @@ int bdrv_open(BlockDriverState *bs, const char
*filename, QDict *options,
qdict_extract_subqdict(options, &file_options, "file.");
file_reference = qdict_get_try_str(options, "file");
- ret = bdrv_file_open(&file, filename, file_reference, file_options,
- bdrv_open_flags(bs, flags | BDRV_O_UNMAP),
&local_err);
- qdict_del(options, "file");
- if (ret < 0) {
- goto fail;
+ if (filename || file_reference || qdict_size(file_options)) {
+ ret = bdrv_file_open(&file, filename, file_reference, file_options,
+ bdrv_open_flags(bs, flags | BDRV_O_UNMAP),
+ &local_err);
+ qdict_del(options, "file");
+ if (ret < 0) {
+ goto fail;
+ }
}
/* Find the right image format driver */
@@ -1180,7 +1183,7 @@ int bdrv_open(BlockDriverState *bs, const char *filename,
QDict *options,
goto unlink_and_fail;
}
- if (bs->file != file) {
+ if (file && (bs->file != file)) {
bdrv_unref(file);
file = NULL;
}
--
1.8.5.1
- [Qemu-devel] [PATCH v3 01/21] blkdebug: Use errp for read_config(), (continued)
- [Qemu-devel] [PATCH v3 01/21] blkdebug: Use errp for read_config(), Max Reitz, 2013/12/11
- [Qemu-devel] [PATCH v3 02/21] blkdebug: Don't require sophisticated filename, Max Reitz, 2013/12/11
- [Qemu-devel] [PATCH v3 03/21] qdict: Add qdict_array_split(), Max Reitz, 2013/12/11
- [Qemu-devel] [PATCH v3 04/21] qapi: extend qdict_flatten() for QLists, Max Reitz, 2013/12/11
- [Qemu-devel] [PATCH v3 05/21] qemu-option: Add qemu_config_parse_qdict(), Max Reitz, 2013/12/11
- [Qemu-devel] [PATCH v3 06/21] blkdebug: Always call read_config(), Max Reitz, 2013/12/11
- [Qemu-devel] [PATCH v3 07/21] blkdebug: Use command-line in read_config(), Max Reitz, 2013/12/11
- [Qemu-devel] [PATCH v3 08/21] block: Allow reference for bdrv_file_open(), Max Reitz, 2013/12/11
- [Qemu-devel] [PATCH v3 09/21] block: Pass reference to bdrv_file_open(), Max Reitz, 2013/12/11
- [Qemu-devel] [PATCH v3 10/21] block: Allow block devices without files,
Max Reitz <=
- [Qemu-devel] [PATCH v3 11/21] block: Allow recursive "file"s, Max Reitz, 2013/12/11
- [Qemu-devel] [PATCH v3 12/21] qemu-iotests: Fix output of test 051, Max Reitz, 2013/12/11
- [Qemu-devel] [PATCH v3 13/21] blockdev: Move "file" to legacy_opts, Max Reitz, 2013/12/11
- [Qemu-devel] [PATCH v3 14/21] blkdebug: Allow command-line file configuration, Max Reitz, 2013/12/11
- [Qemu-devel] [PATCH v3 15/21] blkdebug: Make filename optional, Max Reitz, 2013/12/11
- [Qemu-devel] [PATCH v3 16/21] blkverify: Allow command-line configuration, Max Reitz, 2013/12/11
- [Qemu-devel] [PATCH v3 17/21] blkverify: Don't require protocol filename, Max Reitz, 2013/12/11
- [Qemu-devel] [PATCH v3 19/21] qapi: QMP interface for blkdebug and blkverify, Max Reitz, 2013/12/11
- [Qemu-devel] [PATCH v3 18/21] blkdebug: Alias "errno" as "error", Max Reitz, 2013/12/11
- [Qemu-devel] [PATCH v3 20/21] qemu-io: Make filename optional, Max Reitz, 2013/12/11