@@ -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;
}
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@redhat.com> --- block.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)