qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Benjamin Drung <benjamin.drung@profitbricks.com>
To: "Eric Blake" <eblake@redhat.com>,
	"Philippe Mathieu-Daudé" <f4bug@amsat.org>,
	"Samuel Thibault" <samuel.thibault@gnu.org>,
	"Jan Kiszka" <jan.kiszka@siemens.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 2/2 v2] slirp: Add classless static routes support to DHCP server
Date: Wed, 14 Mar 2018 20:07:51 +0100	[thread overview]
Message-ID: <1521054471.6268.26.camel@profitbricks.com> (raw)
In-Reply-To: <e5af8c70-e6e4-682a-bbd7-6b914b813737@redhat.com>

Am Donnerstag, den 08.03.2018, 14:21 -0600 schrieb Eric Blake:
> On 03/08/2018 02:07 PM, Benjamin Drung wrote:
> > Am Donnerstag, den 08.03.2018, 13:46 -0600 schrieb Eric Blake:
> > > On 03/08/2018 12:57 PM, Benjamin Drung wrote:
> > > >        '*dnssearch': ['String'],
> > > >        '*domainname': 'str',
> > > > +    '*route':     ['String'],
> > > 
> > > I know we've used ['String'] for previous members, but that's
> > > rather
> > > heavyweight - it transmits over QMP as:
> > > 
> > > "dnssearch": [ { "str": "foo" }, { "str": "bar" } ]
> > > 
> > > Nicer is ['str'], which transmits as:
> > > 
> > > "route": [ "foo", "bar" ]
> > > 
> > > so the question boils down to whether cross-member consistency is
> > > more
> > > important than making your additions concise.
> > 
> > Agreed that ['str'] is nicer. I will update the patch.
> 
> The problem is that ['str'] might not work easily for the command
> line 
> glue; I'm more familiar with how QMP exposes things than with the 
> command line parsing, and Markus, who is trying to improve command
> line 
> parsing to share more common infrastructure with QMP, might have
> better 
> comments on the topic, except that he's on leave for a few weeks and 
> won't respond until after 2.12 is frozen.  Using ['String'] for 
> consistency is therefore okay, if you can't get ['str'] working
> quickly.

['str'] works and was easily changeable.

> > > > @@ -1904,7 +1904,7 @@ DEF("netdev", HAS_ARG,
> > > > QEMU_OPTION_netdev,
> > > >        "         [,ipv6[=on|off]][,ipv6-net=addr[/int]][,ipv6-
> > > > host=addr]\n"
> 
> Here's an example where we made the command line smart.  ipv6-net
> takes 
> TWO pieces of information: addr/int; on the QMP side, we spelled it 
> '*ipv6-prefix':'str' + 'ipv6-prefixlen':'int'.  So somewhere in the 
> command line parsing code for --net (which I'm less familiar with), 
> there is some glue code taking the compact representation and
> splitting 
> it into the more verbose but more direct QMP representation - well,
> that 
> is, if we are converting it into QMP form at all (part of the problem
> is 
> that our command line and runtime control don't always share code, 
> although we're trying to get better at that).

The split is done net_client_init() before iterating over the options.
This is equivalent to having following command line parameter:

  [,ipv6-prefix=addr][,ipv6-prefixlen=int]

instead of

  [,ipv6-net=addr[/int]]

> > > > +    "         [,route=addr/mask[:gateway]][,tftp=dir][,bootfil
> > > > e=f]
> > > > [,hostfwd=rule][,guestfwd=rule]"
> > > 
> > > Urgh - your QMP interface HAS to be further parsed to get to the
> > > useful
> > > information.  While it's nice to have compact syntax on the
> > > command
> > > line, it is really worth thinking about making information easier
> > > to
> > > consume (that is, NO further parsing required once the
> > > information is
> > > in
> > > JSON format).  Would it be any better to send things over the
> > > wire
> > > as:
> > > 
> > > "route": [ { "addr": "...", "mask": 24, "gateway": "..." } ]
> > 
> > That's looks good.
> 
> Okay, doing that would mean using something like:
> 
> { 'struct': 'RouteEntry', 'data': { 'addr': 'str', '*mask': 'int', 
> '*gateway': 'str' } }
> ...
> 'route': [ 'RouteEntry' ]
> 
> (but reuse, rather than inventing a new type, if one of the existing
> QMP 
> types already resembles what I proposed for RouteEntry)
> 
> The command line can still use route=addr/mask:gateway syntax, parse
> it 
> down into components, then compile the QMP array of already-parsed 
> structs (rather than making QMP take a direct ['String'] that still 
> needs further parsing).  It may take more glue code, but the idea is 
> that all the glue code should live on the front end, so that the QMP 
> backend should be easy to work with.

The problem is that the opts visitor code only supports lists with a
single mandatory scalar member. Bigger changes are needed to support
splitting 'route'. I have looked into the code for several hours, but
found no simple and non-ugly way to add the splitting without major
changes to the code. I am willing to adapt the patch if someone changes
the opts visitor to support lists with multiple members.

-- 
Benjamin Drung
System Developer
Debian & Ubuntu Developer

ProfitBricks GmbH
Greifswalder Str. 207
D - 10405 Berlin

Email: benjamin.drung@profitbricks.com
URL: https://www.profitbricks.de

Sitz der Gesellschaft: Berlin
Registergericht: Amtsgericht Charlottenburg, HRB 125506 B
Geschäftsführer: Achim Weiss, Matthias Steinberg

  reply	other threads:[~2018-03-14 19:08 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-16 12:55 [Qemu-devel] [PATCH 0/1] slirp: Add domainname option to slirp's DHCP server Benjamin Drung
2018-02-16 12:55 ` [Qemu-devel] [PATCH 1/1] " Benjamin Drung
2018-02-16 15:15   ` Eric Blake
2018-02-16 15:18     ` Benjamin Drung
2018-02-16 17:55     ` [Qemu-devel] [PATCH v2] " Benjamin Drung
2018-02-16 19:23       ` Philippe Mathieu-Daudé
2018-02-16 19:32         ` Benjamin Drung
2018-02-27 16:04         ` Benjamin Drung
2018-02-27 16:06         ` [Qemu-devel] [PATCH 1/2 v4] " Benjamin Drung
2018-02-27 16:06           ` [Qemu-devel] [PATCH 2/2] slirp: Add classless static routes support to " Benjamin Drung
2018-03-04 21:06             ` Samuel Thibault
2018-03-08 18:57               ` [Qemu-devel] [PATCH 2/2 v2] " Benjamin Drung
2018-03-08 19:46                 ` Eric Blake
2018-03-08 20:07                   ` Benjamin Drung
2018-03-08 20:21                     ` Eric Blake
2018-03-14 19:07                       ` Benjamin Drung [this message]
2018-03-04 20:43           ` [Qemu-devel] [PATCH 1/2 v4] slirp: Add domainname option to slirp's " Samuel Thibault
2018-02-26 15:52     ` [Qemu-devel] [PATCH v3] " Benjamin Drung
2018-02-17 21:16 ` [Qemu-devel] [PATCH 0/1] " Samuel Thibault
2018-02-27 16:15   ` Benjamin Drung

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=1521054471.6268.26.camel@profitbricks.com \
    --to=benjamin.drung@profitbricks.com \
    --cc=eblake@redhat.com \
    --cc=f4bug@amsat.org \
    --cc=jan.kiszka@siemens.com \
    --cc=qemu-devel@nongnu.org \
    --cc=samuel.thibault@gnu.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).