From: Kevin Wolf <kwolf@redhat.com>
To: Max Reitz <mreitz@redhat.com>
Cc: qemu-block@nongnu.org, pkrempa@redhat.com, eblake@redhat.com,
qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [RFC PATCH 05/10] qcow2: Use BlockdevRef in qcow2_create2()
Date: Mon, 29 Jan 2018 19:14:10 +0100 [thread overview]
Message-ID: <20180129181410.GR6141@localhost.localdomain> (raw)
In-Reply-To: <3a7536f1-c4af-da6c-1282-ba336e96a86c@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 2819 bytes --]
Am 29.01.2018 um 18:30 hat Max Reitz geschrieben:
> 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 <kwolf@redhat.com>
> > ---
> > 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.
Hm... If visit_type_BlockdevOptions() fails, qdict is not yet assigned.
Are we sure that obj remains NULL in this case?
qobject_decref(obj) looks more obviously correct to me.
> Also, doesn't bdrv_open_inherit() take ownership of @qdict and thus @obj?
That's a very good point...
Kevin
> Max
>
> > + visit_free(v);
> > + return bs;
> > +}
> > +
> > static BlockDriverState *bdrv_append_temp_snapshot(BlockDriverState *bs,
> > int flags,
> > QDict *snapshot_options,
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 801 bytes --]
next prev parent reply other threads:[~2018-01-29 18:14 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-11 19:52 [Qemu-devel] [RFC PATCH 00/10] x-blockdev-create for qcow2 Kevin Wolf
2018-01-11 19:52 ` [Qemu-devel] [RFC PATCH 01/10] block/qapi: Introduce BlockdevCreateOptions Kevin Wolf
2018-01-16 18:54 ` Eric Blake
2018-01-16 19:58 ` Kevin Wolf
2018-01-11 19:52 ` [Qemu-devel] [RFC PATCH 02/10] block/qapi: Add qcow2 create options to schema Kevin Wolf
2018-01-12 10:53 ` Daniel P. Berrange
2018-01-15 13:38 ` Kevin Wolf
2018-01-15 13:51 ` Daniel P. Berrange
2018-01-15 14:07 ` Kevin Wolf
2018-01-15 14:11 ` Daniel P. Berrange
2018-01-16 18:59 ` Eric Blake
2018-01-16 20:11 ` Kevin Wolf
2018-01-16 20:27 ` Eric Blake
2018-01-29 16:57 ` Max Reitz
2018-01-29 18:06 ` Kevin Wolf
2018-01-29 18:06 ` Max Reitz
2018-01-11 19:52 ` [Qemu-devel] [RFC PATCH 03/10] qcow2: Let qcow2_create() handle protocol layer Kevin Wolf
2018-01-16 19:03 ` Eric Blake
2018-01-11 19:52 ` [Qemu-devel] [RFC PATCH 04/10] qcow2: Pass BlockdevCreateOptions to qcow2_create2() Kevin Wolf
2018-01-16 19:21 ` Eric Blake
2018-01-29 17:12 ` Max Reitz
2018-01-29 18:10 ` Kevin Wolf
2018-01-29 18:11 ` Max Reitz
2018-01-11 19:52 ` [Qemu-devel] [RFC PATCH 05/10] qcow2: Use BlockdevRef in qcow2_create2() Kevin Wolf
2018-01-16 19:35 ` Eric Blake
2018-01-29 17:30 ` Max Reitz
2018-01-29 18:14 ` Kevin Wolf [this message]
2018-01-11 19:52 ` [Qemu-devel] [RFC PATCH 06/10] qcow2: Use QCryptoBlockCreateOptions " Kevin Wolf
2018-01-16 19:37 ` Eric Blake
2018-01-11 19:52 ` [Qemu-devel] [RFC PATCH 07/10] qcow2: Handle full/falloc preallocation " Kevin Wolf
2018-01-16 19:40 ` Eric Blake
2018-01-11 19:52 ` [Qemu-devel] [RFC PATCH 08/10] util: Add qemu_opts_to_qdict_filtered() Kevin Wolf
2018-01-16 19:45 ` Eric Blake
2018-01-11 19:52 ` [Qemu-devel] [RFC PATCH 09/10] qcow2: Use visitor for options in qcow2_create() Kevin Wolf
2018-01-16 19:59 ` Eric Blake
2018-01-11 19:52 ` [Qemu-devel] [RFC PATCH 10/10] block: x-blockdev-create QMP command Kevin Wolf
2018-01-16 20:06 ` Eric Blake
2018-01-17 17:50 ` Kevin Wolf
2018-01-11 20:40 ` [Qemu-devel] [RFC PATCH 00/10] x-blockdev-create for qcow2 no-reply
2018-01-11 20:40 ` no-reply
2018-01-16 10:23 ` Kevin Wolf
2018-01-29 18:23 ` Max Reitz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180129181410.GR6141@localhost.localdomain \
--to=kwolf@redhat.com \
--cc=eblake@redhat.com \
--cc=mreitz@redhat.com \
--cc=pkrempa@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.