From patchwork Fri Sep 30 14:45:43 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= X-Patchwork-Id: 677086 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3slvpL1r7yz9ryn for ; Sat, 1 Oct 2016 01:03:38 +1000 (AEST) Received: from localhost ([::1]:45089 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bpzLb-0002nf-3v for incoming@patchwork.ozlabs.org; Fri, 30 Sep 2016 11:03:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48945) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bpz5c-0004nX-Dy for qemu-devel@nongnu.org; Fri, 30 Sep 2016 10:47:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bpz5X-0003Vu-1J for qemu-devel@nongnu.org; Fri, 30 Sep 2016 10:47:03 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54978) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bpz5Q-0003Qh-A1; Fri, 30 Sep 2016 10:46:52 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C21B47F74B; Fri, 30 Sep 2016 14:46:51 +0000 (UTC) Received: from t530wlan.home.berrange.com.com (vpn1-6-125.ams2.redhat.com [10.36.6.125]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u8UEjolr014070; Fri, 30 Sep 2016 10:46:49 -0400 From: "Daniel P. Berrange" To: qemu-devel@nongnu.org Date: Fri, 30 Sep 2016 15:45:43 +0100 Message-Id: <1475246744-29302-21-git-send-email-berrange@redhat.com> In-Reply-To: <1475246744-29302-1-git-send-email-berrange@redhat.com> References: <1475246744-29302-1-git-send-email-berrange@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Fri, 30 Sep 2016 14:46:51 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v14 20/21] net: convert to QObjectInputVisitor for -net/-netdev parsing X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-block@nongnu.org, Markus Armbruster , Max Reitz , Paolo Bonzini , =?UTF-8?q?Andreas=20F=C3=A4rber?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" The -net/-netdev command line parsing code uses OptsVisitor for parsing options to populate NetLegacy or NetDev struct respectively. Although those structs have nesting, the OptsVisitor flattens them, so we must enable compatibility options to auto-create structs. This allows the legacy syntax -net tap,id=net0,vlan=3,fd=3,script=/bin/ifup-qemu to be treated as equivalent to the modern QAPI based syntax -net id=net0,vlan=3,opts.type=tap,opts.data.fd=3,opts.data.script=/bin/ifup-qemu Signed-off-by: Daniel P. Berrange --- net/net.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/net/net.c b/net/net.c index ec984bf..de6bf8e 100644 --- a/net/net.c +++ b/net/net.c @@ -43,7 +43,7 @@ #include "qemu/iov.h" #include "qemu/main-loop.h" #include "qapi-visit.h" -#include "qapi/opts-visitor.h" +#include "qapi/qobject-input-visitor.h" #include "sysemu/sysemu.h" #include "net/filter.h" #include "qapi/string-output-visitor.h" @@ -1069,7 +1069,21 @@ int net_client_init(QemuOpts *opts, bool is_netdev, Error **errp) void *object = NULL; Error *err = NULL; int ret = -1; - Visitor *v = opts_visitor_new(opts); + /* + * Needs autocreate_lists=true in order support existing + * syntax for list options where the bare key is repeated + * + * Needs autocreate_struct_levels=3 in order to deal with + * 3 level nesting in NetLegacy option args, which was + * exposed as a flat namespace with OptVisitor + */ + Visitor *v = qobject_input_visitor_new_opts(opts, true, 3, false, true, + &err); + + if (err) { + error_propagate(errp, err); + return -1; + } { /* Parse convenience option format ip6-net=fec0::0[/64] */