qemu-devel
[Top][All Lists]
Advanced

[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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]