[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-block] [RFC PATCH 05/10] qcow2: Use BlockdevRef in qcow2_creat
From: |
Max Reitz |
Subject: |
Re: [Qemu-block] [RFC PATCH 05/10] qcow2: Use BlockdevRef in qcow2_create2() |
Date: |
Mon, 29 Jan 2018 18:30:53 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 |
On 2018-01-11 20:52, Kevin Wolf wrote:
> Instead of passing a separate BlockDriverState* into qcow2_create2(),
> make use of the BlockdevRef that is included in BlockdevCreateOptions.
>
> Signed-off-by: Kevin Wolf <address@hidden>
> ---
> include/block/block.h | 1 +
> block.c | 39 +++++++++++++++++++++++++++++++++++++++
> block/qcow2.c | 33 +++++++++++++++++++++------------
> 3 files changed, 61 insertions(+), 12 deletions(-)
[...]
> diff --git a/block.c b/block.c
> index a8da4f2b25..c9b0e1d6d3 100644
> --- a/block.c
> +++ b/block.c
[...]
> @@ -2405,6 +2407,43 @@ BdrvChild *bdrv_open_child(const char *filename,
> return c;
> }
>
> +/* TODO Future callers may need to specify parent/child_role in order for
> + * option inheritance to work. Existing callers use it for the root node. */
> +BlockDriverState *bdrv_open_blockdev_ref(BlockdevRef *ref, Error **errp)
> +{
> + BlockDriverState *bs = NULL;
> + Error *local_err = NULL;
> + QObject *obj = NULL;
> + QDict *qdict = NULL;
> + const char *reference = NULL;
> + Visitor *v = NULL;
> +
> + if (ref->type == QTYPE_QSTRING) {
> + reference = ref->u.reference;
> + } else {
> + BlockdevOptions *options = &ref->u.definition;
> + assert(ref->type == QTYPE_QDICT);
> +
> + v = qobject_output_visitor_new(&obj);
> + visit_type_BlockdevOptions(v, NULL, &options, &local_err);
> + if (local_err) {
> + error_propagate(errp, local_err);
> + goto fail;
> + }
> + visit_complete(v, &obj);
> +
> + qdict = qobject_to_qdict(obj);
> + qdict_flatten(qdict);
> + }
> +
> + bs = bdrv_open_inherit(NULL, reference, qdict, 0, NULL, NULL, errp);
> +
> +fail:
> + qobject_decref(obj);
I'd prefer QDECREF(qdict), myself, although I can't quite explain why.
Probably because @qdict is the object you're actually using and @obj is
just some temporary designation.
Also, doesn't bdrv_open_inherit() take ownership of @qdict and thus @obj?
Max
> + visit_free(v);
> + return bs;
> +}
> +
> static BlockDriverState *bdrv_append_temp_snapshot(BlockDriverState *bs,
> int flags,
> QDict *snapshot_options,
signature.asc
Description: OpenPGP digital signature
- Re: [Qemu-block] [RFC PATCH 02/10] block/qapi: Add qcow2 create options to schema, (continued)
- [Qemu-block] [RFC PATCH 05/10] qcow2: Use BlockdevRef in qcow2_create2(), Kevin Wolf, 2018/01/11
- [Qemu-block] [RFC PATCH 06/10] qcow2: Use QCryptoBlockCreateOptions in qcow2_create2(), Kevin Wolf, 2018/01/11
- [Qemu-block] [RFC PATCH 07/10] qcow2: Handle full/falloc preallocation in qcow2_create2(), Kevin Wolf, 2018/01/11
- [Qemu-block] [RFC PATCH 08/10] util: Add qemu_opts_to_qdict_filtered(), Kevin Wolf, 2018/01/11
- [Qemu-block] [RFC PATCH 09/10] qcow2: Use visitor for options in qcow2_create(), Kevin Wolf, 2018/01/11
- [Qemu-block] [RFC PATCH 10/10] block: x-blockdev-create QMP command, Kevin Wolf, 2018/01/11