[Spice-devel] [PATCH 17/21] block: allow to call bdrv_open() with an opaque

Marc-André Lureau marcandre.lureau at gmail.com
Mon Nov 18 04:25:27 PST 2013


From: Marc-André Lureau <marcandre.lureau at redhat.com>

If the block driver already has a bs->opaque when calling bdrv_open(),
pass it down to the file driver.

Signed-off-by: Marc-André Lureau <marcandre.lureau at redhat.com>

Conflicts:
	block.c
---
 block.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/block.c b/block.c
index f154979..ce2427b 100644
--- a/block.c
+++ b/block.c
@@ -1131,6 +1131,7 @@ int bdrv_open(BlockDriverState *bs, const char *filename, QDict *options,
     QDict *file_options = NULL;
     const char *drvname;
     Error *local_err = NULL;
+    void *backing_opaque = NULL;
 
     /* NULL means an empty set of options */
     if (options == NULL) {
@@ -1154,6 +1155,8 @@ int bdrv_open(BlockDriverState *bs, const char *filename, QDict *options,
             goto fail;
         }
 
+        backing_opaque = bs->opaque;
+        bs->opaque = NULL;
         if (total_size == -1) {
             bs1 = bdrv_new_int("", NULL, NULL);
             ret = bdrv_open(bs1, filename, NULL, 0, drv, &local_err);
@@ -1181,7 +1184,8 @@ int bdrv_open(BlockDriverState *bs, const char *filename, QDict *options,
 
     ret = bdrv_file_open_int(&file, filename, file_options,
                              bdrv_open_flags(bs, flags | BDRV_O_UNMAP),
-                             bs, NULL, &local_err);
+                             bs, bs->opaque, &local_err);
+    bs->opaque = NULL;
     if (ret < 0) {
         goto fail;
     }
@@ -1217,7 +1221,8 @@ int bdrv_open(BlockDriverState *bs, const char *filename, QDict *options,
         QDict *backing_options;
 
         qdict_extract_subqdict(options, &backing_options, "backing.");
-        ret = bdrv_open_backing_file_int(bs, backing_options, NULL, &local_err);
+        ret = bdrv_open_backing_file_int(bs, backing_options,
+                                         backing_opaque, &local_err);
         if (ret < 0) {
             goto close_and_fail;
         }
-- 
1.8.3.1



More information about the Spice-devel mailing list