[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 05/19] block: Add bdrv_default_refresh_protocol_file
From: |
Max Reitz |
Subject: |
[Qemu-devel] [PATCH 05/19] block: Add bdrv_default_refresh_protocol_filename |
Date: |
Tue, 26 Apr 2016 23:32:04 +0200 |
Split off the default code for protocol BDS from bdrv_refresh_filename()
into an own function, just as it has been done for format BDS.
Signed-off-by: Max Reitz <address@hidden>
---
block.c | 58 +++++++++++++++++++++++++++++++++-------------------------
1 file changed, 33 insertions(+), 25 deletions(-)
diff --git a/block.c b/block.c
index 447468c..511a0b1 100644
--- a/block.c
+++ b/block.c
@@ -3922,6 +3922,38 @@ static void
bdrv_default_refresh_format_filename(BlockDriverState *bs)
}
}
+static void bdrv_default_refresh_protocol_filename(BlockDriverState *bs)
+{
+ BlockDriver *drv = bs->drv;
+ QDict *opts;
+
+ /* There is no underlying file BDS (at least referenced by BDS.file),
+ * so the full options QDict should be equal to the options given
+ * specifically for this block device when it was opened (plus the
+ * driver specification).
+ * Because those options don't change, there is no need to update
+ * full_open_options when it's already set. */
+
+ opts = qdict_new();
+ append_open_options(opts, bs);
+ qdict_put_obj(opts, "driver",
+ QOBJECT(qstring_from_str(drv->format_name)));
+
+ if (bs->exact_filename[0]) {
+ /* This may not work for all block protocol drivers (some may
+ * require this filename to be parsed), but we have to find some
+ * default solution here, so just include it. If some block driver
+ * does not support pure options without any filename at all or
+ * needs some special format of the options QDict, it needs to
+ * implement the driver-specific bdrv_refresh_filename() function.
+ */
+ qdict_put_obj(opts, "filename",
+ QOBJECT(qstring_from_str(bs->exact_filename)));
+ }
+
+ bs->full_open_options = opts;
+}
+
/* Updates the following BDS fields:
* - exact_filename: A filename which may be used for opening a block device
* which (mostly) equals the given BDS (even without any
@@ -3967,31 +3999,7 @@ void bdrv_refresh_filename(BlockDriverState *bs)
/* Try to reconstruct valid information from the underlying file */
bdrv_default_refresh_format_filename(bs);
} else if (!bs->full_open_options && qdict_size(bs->options)) {
- /* There is no underlying file BDS (at least referenced by BDS.file),
- * so the full options QDict should be equal to the options given
- * specifically for this block device when it was opened (plus the
- * driver specification).
- * Because those options don't change, there is no need to update
- * full_open_options when it's already set. */
-
- opts = qdict_new();
- append_open_options(opts, bs);
- qdict_put_obj(opts, "driver",
- QOBJECT(qstring_from_str(drv->format_name)));
-
- if (bs->exact_filename[0]) {
- /* This may not work for all block protocol drivers (some may
- * require this filename to be parsed), but we have to find some
- * default solution here, so just include it. If some block driver
- * does not support pure options without any filename at all or
- * needs some special format of the options QDict, it needs to
- * implement the driver-specific bdrv_refresh_filename() function.
- */
- qdict_put_obj(opts, "filename",
- QOBJECT(qstring_from_str(bs->exact_filename)));
- }
-
- bs->full_open_options = opts;
+ bdrv_default_refresh_protocol_filename(bs);
}
if (bs->exact_filename[0]) {
--
2.8.0
- [Qemu-devel] [PATCH 00/19] block: Fix some filename generation issues, Max Reitz, 2016/04/26
- [Qemu-devel] [PATCH 02/19] block: Add BDS.backing_overridden, Max Reitz, 2016/04/26
- [Qemu-devel] [PATCH 01/19] block: Use children list in bdrv_refresh_filename, Max Reitz, 2016/04/26
- [Qemu-devel] [PATCH 04/19] block: Add bdrv_default_refresh_format_filename, Max Reitz, 2016/04/26
- [Qemu-devel] [PATCH 03/19] block: Respect backing bs in bdrv_refresh_filename, Max Reitz, 2016/04/26
- [Qemu-devel] [PATCH 05/19] block: Add bdrv_default_refresh_protocol_filename,
Max Reitz <=
- [Qemu-devel] [PATCH 09/19] block: bdrv_get_full_backing_filename_from_...'s ret. val., Max Reitz, 2016/04/26
- [Qemu-devel] [PATCH 06/19] block: Make bdrv_default_refresh_format_filename public, Max Reitz, 2016/04/26
- [Qemu-devel] [PATCH 07/19] qcow2: Implement bdrv_refresh_filename(), Max Reitz, 2016/04/26
- [Qemu-devel] [PATCH 10/19] block: bdrv_get_full_backing_filename's ret. val., Max Reitz, 2016/04/26
- [Qemu-devel] [PATCH 12/19] block: Fix bdrv_find_backing_image(), Max Reitz, 2016/04/26
- [Qemu-devel] [PATCH 08/19] block: Make path_combine() return the path, Max Reitz, 2016/04/26
- [Qemu-devel] [PATCH 15/19] quorum: Make bdrv_dirname() return NULL, Max Reitz, 2016/04/26
- [Qemu-devel] [PATCH 11/19] block: Add bdrv_make_absolute_filename(), Max Reitz, 2016/04/26
- [Qemu-devel] [PATCH 13/19] block: Add bdrv_dirname(), Max Reitz, 2016/04/26
- [Qemu-devel] [PATCH 14/19] blkverify: Make bdrv_dirname() return NULL, Max Reitz, 2016/04/26