@@ -100,6 +100,10 @@ bdrv_open_blockdev_ref(BlockdevRef *ref, Error **errp);
BlockDriverState * coroutine_fn no_co_wrapper
bdrv_co_open_blockdev_ref(BlockdevRef *ref, Error **errp);
+BlockDriverState * no_coroutine_fn
+bdrv_open_blockdev_ref_file(BlockdevRef *ref, BlockDriverState *parent,
+ Error **errp);
+
int bdrv_set_backing_hd(BlockDriverState *bs, BlockDriverState *backing_hd,
Error **errp);
int GRAPH_WRLOCK
@@ -3847,7 +3847,11 @@ int bdrv_open_file_child(const char *filename,
* TODO Future callers may need to specify parent/child_class in order for
* option inheritance to work. Existing callers use it for the root node.
*/
-BlockDriverState *bdrv_open_blockdev_ref(BlockdevRef *ref, Error **errp)
+static BlockDriverState * no_coroutine_fn
+bdrv_open_blockdev_ref_common(BlockdevRef *ref, BlockDriverState *parent,
+ const BdrvChildClass *child_class,
+ BdrvChildRole child_role, bool parse_filename,
+ Error **errp)
{
BlockDriverState *bs = NULL;
QObject *obj = NULL;
@@ -3880,14 +3884,34 @@ BlockDriverState *bdrv_open_blockdev_ref(BlockdevRef *ref, Error **errp)
}
- bs = bdrv_open_inherit(NULL, reference, qdict, 0, NULL, NULL, 0, false,
- errp);
+ bs = bdrv_open_inherit(NULL, reference, qdict, 0, parent, child_class,
+ child_role, parse_filename, errp);
obj = NULL;
qobject_unref(obj);
visit_free(v);
return bs;
}
+BlockDriverState *bdrv_open_blockdev_ref_file(BlockdevRef *ref,
+ BlockDriverState *parent,
+ Error **errp)
+{
+ BdrvChildRole role;
+
+ /* commit_top and mirror_top don't use this function */
+ assert(!parent->drv->filtered_child_is_backing);
+ role = parent->drv->is_filter ?
+ (BDRV_CHILD_FILTERED | BDRV_CHILD_PRIMARY) : BDRV_CHILD_IMAGE;
+
+ return bdrv_open_blockdev_ref_common(ref, parent, &child_of_bds, role,
+ true, errp);
+}
+
+BlockDriverState *bdrv_open_blockdev_ref(BlockdevRef *ref, Error **errp)
+{
+ return bdrv_open_blockdev_ref_common(ref, NULL, NULL, 0, false, errp);
+}
+
static BlockDriverState *bdrv_append_temp_snapshot(BlockDriverState *bs,
int flags,
QDict *snapshot_options,
This is the equivalent of bdrv_open_file_child() to be used in cases where the caller is QAPI based and has a BlockdevRef rather than a filename and an options QDict. Signed-off-by: Kevin Wolf <kwolf@redhat.com> --- include/block/block-global-state.h | 4 ++++ block.c | 30 +++++++++++++++++++++++++++--- 2 files changed, 31 insertions(+), 3 deletions(-)