qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: "Daniel P. Berrange" <berrange@redhat.com>
Cc: qemu-block@nongnu.org, Markus Armbruster <armbru@redhat.com>,
	qemu-devel@nongnu.org, Luiz Capitulino <lcapitulino@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Max Reitz <mreitz@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v2 00/16] qapi: Allow blockdev-add for NBD
Date: Tue, 1 Mar 2016 11:12:54 +0100	[thread overview]
Message-ID: <20160301101254.GB4250@noname.str.redhat.com> (raw)
In-Reply-To: <20160301100035.GC26728@redhat.com>

Am 01.03.2016 um 11:00 hat Daniel P. Berrange geschrieben:
> On Tue, Mar 01, 2016 at 12:37:14AM +0100, Max Reitz wrote:
> > On 01.03.2016 00:24, Eric Blake wrote:
> > > On 02/29/2016 04:19 PM, Max Reitz wrote:
> > >> Turns out NBD is not so simple to do if you do it right. Anyway, this
> > >> series adds blockdev-add support for NBD clients.
> > >>
> > >> Patches 1 and 2 add one less and one more complicated QDict function,
> > >> respectively, which I needed in later NBD patches: Patch 1 for handling
> > >> legacy options (move "host" to "address.data.host" etc.) and patch 2
> > >> because I'd like to use the input visitor for transforming the NBD
> > >> options into a SocketAddress. Unfortunately, the block layer uses
> > >> flattened QDicts everywhere, so we'll have to unflatten (erect?) them
> > >> before we can use that visitor.
> > > 
> > > Dan had a patch proposal that called the operation "crumple"; I need to
> > > review both proposals and see which one I like.
> > > https://lists.gnu.org/archive/html/qemu-devel/2016-02/msg04618.html
> > 
> > Well, here I go again, not looking at patches on the list...
> > 
> > Looking at the design, I like his idea of having an escape sequence;
> > also, his qdict_crumple() can return boths lists and dicts where my
> > qdict_unflatten() only returns dicts (then again, this is what
> > qdict_flatten() always works on). And his patch doesn't suffer from as
> > much indentation as mine does.
> 
> The escape sequence is critical to support for my use case, because
> sadly some object properties have '.' in their name :-(
> 
> > What I like more about my patch, however, is that I'm reusing
> > qdict_array_split() and qdict_array_entries(). That is mostly because my
> > function modifies the given QDict, where Dan's does not.
> 
> The reason for that is that the use context in which I need to call
> qdict_crumple() has a const QDict, so modifying the original QDict
> was not an option.

You can always clone and modify if modifying an existing QDict turns out
to be nicer to implement.

> Second, for error handling, if there is a problem we can't resolve
> half way through the unflattening process, then if you're modifying
> the original QDict you end up with a QDict that is a hybrid between
> the flat & unflat forms. I think it is pretty bad practice for API
> design / behaviour to leave inputs in such a state on error. ie if
> the code isn't capable of rolling back to the original state it
> should not be modifying the input arg.

I think we generally abort the whole action in such error cases. Then
it doesn't really matter in what state the to be freed QDict is.

Kevin

      reply	other threads:[~2016-03-01 10:13 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-29 23:19 [Qemu-devel] [PATCH v2 00/16] qapi: Allow blockdev-add for NBD Max Reitz
2016-02-29 23:19 ` [Qemu-devel] [PATCH v2 01/16] qdict: Add qdict_change_key() Max Reitz
2016-02-29 23:19 ` [Qemu-devel] [PATCH v2 02/16] qdict: Add qdict_unflatten() Max Reitz
2016-02-29 23:19 ` [Qemu-devel] [PATCH v2 03/16] check-qdict: Add a test for qdict_unflatten() Max Reitz
2016-02-29 23:19 ` [Qemu-devel] [PATCH v2 04/16] block/nbd: Drop trailing "." in error messages Max Reitz
2016-02-29 23:19 ` [Qemu-devel] [PATCH v2 05/16] block/nbd: Reject port parameter without host Max Reitz
2016-02-29 23:19 ` [Qemu-devel] [PATCH v2 06/16] block/nbd: Default port in nbd_refresh_filename() Max Reitz
2016-02-29 23:19 ` [Qemu-devel] [PATCH v2 07/16] block/nbd: Use qdict_put() Max Reitz
2016-02-29 23:19 ` [Qemu-devel] [PATCH v2 08/16] block/nbd: Add nbd_has_filename_options_conflict() Max Reitz
2016-02-29 23:19 ` [Qemu-devel] [PATCH v2 09/16] block/nbd: "address" in nbd_refresh_filename() Max Reitz
2016-02-29 23:19 ` [Qemu-devel] [PATCH v2 10/16] block/nbd: Accept SocketAddress Max Reitz
2016-02-29 23:19 ` [Qemu-devel] [PATCH v2 11/16] block/nbd: Use SocketAddress options Max Reitz
2016-02-29 23:19 ` [Qemu-devel] [PATCH v2 12/16] qapi: Allow blockdev-add for NBD Max Reitz
2016-02-29 23:19 ` [Qemu-devel] [PATCH v2 13/16] iotests.py: Add qemu_nbd function Max Reitz
2016-02-29 23:19 ` [Qemu-devel] [PATCH v2 14/16] iotests.py: Allow concurrent qemu instances Max Reitz
2016-02-29 23:19 ` [Qemu-devel] [PATCH v2 15/16] socket_scm_helper: Accept fd directly Max Reitz
2016-02-29 23:19 ` [Qemu-devel] [PATCH v2 16/16] iotests: Add test for NBD's blockdev-add interface Max Reitz
2016-02-29 23:24 ` [Qemu-devel] [PATCH v2 00/16] qapi: Allow blockdev-add for NBD Eric Blake
2016-02-29 23:37   ` Max Reitz
2016-03-01 10:00     ` Daniel P. Berrange
2016-03-01 10:12       ` Kevin Wolf [this message]

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=20160301101254.GB4250@noname.str.redhat.com \
    --to=kwolf@redhat.com \
    --cc=armbru@redhat.com \
    --cc=berrange@redhat.com \
    --cc=lcapitulino@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=pbonzini@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).