[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PATCH v14 18/19] net: convert to QObjectInputVisitor for -
From: |
Daniel P. Berrange |
Subject: |
[Qemu-block] [PATCH v14 18/19] net: convert to QObjectInputVisitor for -net/-netdev parsing |
Date: |
Tue, 27 Sep 2016 14:13:20 +0100 |
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 <address@hidden>
---
net/net.c | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/net/net.c b/net/net.c
index d51cb29..af3645b 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"
@@ -1065,7 +1065,20 @@ 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, &err);
+
+ if (err) {
+ error_propagate(errp, err);
+ return -1;
+ }
{
/* Parse convenience option format ip6-net=fec0::0[/64] */
--
2.7.4
- [Qemu-block] [PATCH v14 08/19] qapi: permit scalar type conversions in QObjectInputVisitor, (continued)
- [Qemu-block] [PATCH v14 08/19] qapi: permit scalar type conversions in QObjectInputVisitor, Daniel P. Berrange, 2016/09/27
- [Qemu-block] [PATCH v14 06/19] qapi: rename QmpOutputVisitor to QObjectOutputVisitor, Daniel P. Berrange, 2016/09/27
- [Qemu-block] [PATCH v14 09/19] qapi: permit auto-creating single element lists, Daniel P. Berrange, 2016/09/27
- [Qemu-block] [PATCH v14 10/19] qapi: permit auto-creating nested structs, Daniel P. Berrange, 2016/09/27
- [Qemu-block] [PATCH v14 11/19] qapi: add integer range support for QObjectInputVisitor, Daniel P. Berrange, 2016/09/27
- [Qemu-block] [PATCH v14 13/19] qom: support non-scalar properties with -object, Daniel P. Berrange, 2016/09/27
- [Qemu-block] [PATCH v14 14/19] hmp: support non-scalar properties with object_add, Daniel P. Berrange, 2016/09/27
- [Qemu-block] [PATCH v14 12/19] qapi: allow QObjectInputVisitor to be created with QemuOpts, Daniel P. Berrange, 2016/09/27
- [Qemu-block] [PATCH v14 16/19] block: convert crypto driver to use QObjectInputVisitor, Daniel P. Berrange, 2016/09/27
- [Qemu-block] [PATCH v14 15/19] numa: convert to use QObjectInputVisitor for -numa, Daniel P. Berrange, 2016/09/27
- [Qemu-block] [PATCH v14 18/19] net: convert to QObjectInputVisitor for -net/-netdev parsing,
Daniel P. Berrange <=
- [Qemu-block] [PATCH v14 17/19] acpi: convert to QObjectInputVisitor for -acpi parsing, Daniel P. Berrange, 2016/09/27
- [Qemu-block] [PATCH v14 19/19] qapi: delete unused OptsVisitor code, Daniel P. Berrange, 2016/09/27