[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PULL 14/19] block: Factor out bdrv_open_child_bs()
From: |
Kevin Wolf |
Subject: |
[Qemu-block] [PULL 14/19] block: Factor out bdrv_open_child_bs() |
Date: |
Fri, 24 Feb 2017 19:17:05 +0100 |
This is the part of bdrv_open_child() that opens a BDS with option
inheritance, but doesn't attach it as a child to the parent yet.
Signed-off-by: Kevin Wolf <address@hidden>
Reviewed-by: Max Reitz <address@hidden>
---
block.c | 61 +++++++++++++++++++++++++++++++++++++------------------------
1 file changed, 37 insertions(+), 24 deletions(-)
diff --git a/block.c b/block.c
index 40c4dee..6987400 100644
--- a/block.c
+++ b/block.c
@@ -1546,28 +1546,12 @@ free_exit:
return ret;
}
-/*
- * Opens a disk image whose options are given as BlockdevRef in another block
- * device's options.
- *
- * If allow_none is true, no image will be opened if filename is false and no
- * BlockdevRef is given. NULL will be returned, but errp remains unset.
- *
- * bdrev_key specifies the key for the image's BlockdevRef in the options
QDict.
- * That QDict has to be flattened; therefore, if the BlockdevRef is a QDict
- * itself, all options starting with "${bdref_key}." are considered part of the
- * BlockdevRef.
- *
- * The BlockdevRef will be removed from the options QDict.
- */
-BdrvChild *bdrv_open_child(const char *filename,
- QDict *options, const char *bdref_key,
- BlockDriverState* parent,
- const BdrvChildRole *child_role,
- bool allow_none, Error **errp)
+static BlockDriverState *
+bdrv_open_child_bs(const char *filename, QDict *options, const char *bdref_key,
+ BlockDriverState *parent, const BdrvChildRole *child_role,
+ bool allow_none, Error **errp)
{
- BdrvChild *c = NULL;
- BlockDriverState *bs;
+ BlockDriverState *bs = NULL;
QDict *image_options;
char *bdref_key_dot;
const char *reference;
@@ -1594,11 +1578,40 @@ BdrvChild *bdrv_open_child(const char *filename,
goto done;
}
- c = bdrv_attach_child(parent, bs, bdref_key, child_role);
-
done:
qdict_del(options, bdref_key);
- return c;
+ return bs;
+}
+
+/*
+ * Opens a disk image whose options are given as BlockdevRef in another block
+ * device's options.
+ *
+ * If allow_none is true, no image will be opened if filename is false and no
+ * BlockdevRef is given. NULL will be returned, but errp remains unset.
+ *
+ * bdrev_key specifies the key for the image's BlockdevRef in the options
QDict.
+ * That QDict has to be flattened; therefore, if the BlockdevRef is a QDict
+ * itself, all options starting with "${bdref_key}." are considered part of the
+ * BlockdevRef.
+ *
+ * The BlockdevRef will be removed from the options QDict.
+ */
+BdrvChild *bdrv_open_child(const char *filename,
+ QDict *options, const char *bdref_key,
+ BlockDriverState *parent,
+ const BdrvChildRole *child_role,
+ bool allow_none, Error **errp)
+{
+ BlockDriverState *bs;
+
+ bs = bdrv_open_child_bs(filename, options, bdref_key, parent, child_role,
+ allow_none, errp);
+ if (bs == NULL) {
+ return NULL;
+ }
+
+ return bdrv_attach_child(parent, bs, bdref_key, child_role);
}
static BlockDriverState *bdrv_append_temp_snapshot(BlockDriverState *bs,
--
1.8.3.1
- [Qemu-block] [PULL 07/19] qemu-img: Improve documentation for PREALLOC_MODE_FALLOC, (continued)
- [Qemu-block] [PULL 07/19] qemu-img: Improve documentation for PREALLOC_MODE_FALLOC, Kevin Wolf, 2017/02/24
- [Qemu-block] [PULL 08/19] iotests: Fix another race in 030, Kevin Wolf, 2017/02/24
- [Qemu-block] [PULL 10/19] qcow2: Use BB for resizing in qcow2_amend_options(), Kevin Wolf, 2017/02/24
- [Qemu-block] [PULL 09/19] blockdev: Use BlockBackend to resize in qmp_block_resize(), Kevin Wolf, 2017/02/24
- [Qemu-block] [PULL 11/19] mirror: Resize active commit base in mirror_run(), Kevin Wolf, 2017/02/24
- [Qemu-block] [PULL 13/19] block: Attach bs->file only during .bdrv_open(), Kevin Wolf, 2017/02/24
- [Qemu-block] [PULL 12/19] block: Pass BdrvChild to bdrv_truncate(), Kevin Wolf, 2017/02/24
- [Qemu-block] [PULL 16/19] block: Factor out bdrv_open_driver(), Kevin Wolf, 2017/02/24
- [Qemu-block] [PULL 17/19] block: Add bdrv_new_open_driver(), Kevin Wolf, 2017/02/24
- [Qemu-block] [PULL 18/19] vvfat: Use opened node as backing file, Kevin Wolf, 2017/02/24
- [Qemu-block] [PULL 14/19] block: Factor out bdrv_open_child_bs(),
Kevin Wolf <=
- [Qemu-block] [PULL 15/19] block: Use BlockBackend for image probing, Kevin Wolf, 2017/02/24
- [Qemu-block] [PULL 19/19] tests: Use opened block node for block job tests, Kevin Wolf, 2017/02/24
- Re: [Qemu-block] [Qemu-devel] [PULL 00/19] Block layer patches, no-reply, 2017/02/24
- Re: [Qemu-block] [Qemu-devel] [PULL 00/19] Block layer patches, Peter Maydell, 2017/02/26