[Spice-devel] [PATCH 11/12] block: allow to call bdrv_open() with an opaque
Marc-André Lureau
marcandre.lureau at gmail.com
Thu Jun 20 10:46:10 PDT 2013
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>
---
block.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/block.c b/block.c
index bdffb42..ff9cb0b 100644
--- a/block.c
+++ b/block.c
@@ -1041,6 +1041,7 @@ int bdrv_open(BlockDriverState *bs, const char *filename, QDict *options,
int ret;
BlockDriverState *file = NULL;
QDict *file_options = NULL;
+ void *backing_opaque = NULL;
/* NULL means an empty set of options */
if (options == NULL) {
@@ -1064,6 +1065,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);
@@ -1088,7 +1091,8 @@ int bdrv_open(BlockDriverState *bs, const char *filename, QDict *options,
extract_subqdict(options, &file_options, "file.");
ret = bdrv_file_open_int(&file, filename, file_options,
- bdrv_open_flags(bs, flags), bs, NULL);
+ bdrv_open_flags(bs, flags), bs, bs->opaque);
+ bs->opaque = NULL;
if (ret < 0) {
goto fail;
}
@@ -1118,7 +1122,7 @@ int bdrv_open(BlockDriverState *bs, const char *filename, QDict *options,
QDict *backing_options;
extract_subqdict(options, &backing_options, "backing.");
- ret = bdrv_open_backing_file_int(bs, backing_options, NULL);
+ ret = bdrv_open_backing_file_int(bs, backing_options, backing_opaque);
if (ret < 0) {
goto close_and_fail;
}
--
1.8.3.rc1.49.g8d97506
More information about the Spice-devel
mailing list