From: Kevin Wolf Date: Mon, 15 Jun 2015 12:11:51 +0000 (+0200) Subject: block: Introduce BDS.file_child X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=1fdd69330872ef91d92482472eef79350d2f379b;p=osstest%2Fqemu.git block: Introduce BDS.file_child Store the BdrvChild for bs->file. At this point, bs->file_child->bs just duplicates the bs->file pointer. Later, it will completely replace it. Signed-off-by: Kevin Wolf Reviewed-by: Max Reitz Reviewed-by: Alberto Garcia Reviewed-by: Fam Zheng Reviewed-by: Jeff Cody Reviewed-by: Stefan Hajnoczi --- diff --git a/block.c b/block.c index 1f90b4773..75afed118 100644 --- a/block.c +++ b/block.c @@ -1487,11 +1487,17 @@ static int bdrv_open_inherit(BlockDriverState **pbs, const char *filename, assert(file == NULL); bs->open_flags = flags; - ret = bdrv_open_image(&file, filename, options, "file", - bs, &child_file, true, &local_err); - if (ret < 0) { + + bs->file_child = bdrv_open_child(filename, options, "file", bs, + &child_file, true, &local_err); + if (local_err) { + ret = -EINVAL; goto fail; } + + if (bs->file_child) { + file = bs->file_child->bs; + } } /* Image format probing */ diff --git a/include/block/block_int.h b/include/block/block_int.h index 14ad4c334..d0dd93e5a 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -381,6 +381,7 @@ struct BlockDriverState { BlockDriverState *backing_hd; BdrvChild *backing_child; BlockDriverState *file; + BdrvChild *file_child; NotifierList close_notifiers;