[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v5 45/46] net: Complete qapi-fication of netdev_add
From: |
Eric Blake |
Subject: |
[Qemu-devel] [PATCH v5 45/46] net: Complete qapi-fication of netdev_add |
Date: |
Mon, 21 Sep 2015 15:58:01 -0600 |
We finally have all the required pieces for doing a type-safe
representation of netdev_add as a flat union, where the
discriminator 'type' now selects which additional members may
appear in the "arguments" JSON object sent over QMP, while
making no changes to the set of previously-valid QMP commands
that would work, and without breaking command line parsing.
Signed-off-by: Eric Blake <address@hidden>
---
include/net/net.h | 1 -
net/net.c | 25 ++-----------------------
qapi-schema.json | 15 +++------------
qmp-commands.hx | 2 +-
4 files changed, 6 insertions(+), 37 deletions(-)
diff --git a/include/net/net.h b/include/net/net.h
index 8c12eff..475f1e8 100644
--- a/include/net/net.h
+++ b/include/net/net.h
@@ -197,7 +197,6 @@ void net_cleanup(void);
void hmp_host_net_add(Monitor *mon, const QDict *qdict);
void hmp_host_net_remove(Monitor *mon, const QDict *qdict);
void netdev_add(QemuOpts *opts, Error **errp);
-void qmp_netdev_add(QDict *qdict, QObject **ret, Error **errp);
int net_hub_id_for_client(NetClientState *nc, int *id);
NetClientState *net_hub_port_find(int hub_id);
diff --git a/net/net.c b/net/net.c
index d1ec9aa..69456b2 100644
--- a/net/net.c
+++ b/net/net.c
@@ -1116,30 +1116,9 @@ void netdev_add(QemuOpts *opts, Error **errp)
net_client_init(opts, true, errp);
}
-void qmp_netdev_add(QDict *qdict, QObject **ret, Error **errp)
+void qmp_netdev_add(Netdev *netdev, Error **errp)
{
- Error *local_err = NULL;
- QemuOptsList *opts_list;
- QemuOpts *opts;
-
- opts_list = qemu_find_opts_err("netdev", &local_err);
- if (local_err) {
- goto out;
- }
-
- opts = qemu_opts_from_qdict(opts_list, qdict, &local_err);
- if (local_err) {
- goto out;
- }
-
- netdev_add(opts, &local_err);
- if (local_err) {
- qemu_opts_del(opts);
- goto out;
- }
-
-out:
- error_propagate(errp, local_err);
+ net_client_init1(netdev, true, errp);
}
void qmp_netdev_del(const char *id, Error **errp)
diff --git a/qapi-schema.json b/qapi-schema.json
index b325c42..263053d 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -2077,26 +2077,17 @@
#
# Add a network backend.
#
-# @type: the type of network backend. Current valid values are 'user', 'tap',
-# 'vde', 'socket', 'dump' and 'bridge'
+# @type: the type of network backend; determines which additional arguments
+# are valid. See Netdev documentation for more details.
#
# @id: the name of the new network backend
#
-# Additional arguments depend on the type.
-#
-# TODO This command effectively bypasses QAPI completely due to its
-# "additional arguments" business. It shouldn't have been added to
-# the schema in this form. It should be qapified properly, or
-# replaced by a properly qapified command.
-#
# Since: 0.14.0
#
# Returns: Nothing on success
# If @type is not a valid network backend, DeviceNotFound
##
-{ 'command': 'netdev_add',
- 'data': {'type': 'str', 'id': 'str'},
- 'gen': false } # so we can get the additional arguments
+{ 'command': 'netdev_add', 'data': 'Netdev', 'box': true }
##
# @netdev_del:
diff --git a/qmp-commands.hx b/qmp-commands.hx
index 66f0300..eecfa86 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -900,7 +900,7 @@ EQMP
{
.name = "netdev_add",
.args_type = "netdev:O",
- .mhandler.cmd_new = qmp_netdev_add,
+ .mhandler.cmd_new = qmp_marshal_netdev_add,
},
SQMP
--
2.4.3
- [Qemu-devel] [PATCH v5 37/46] qapi: Forbid empty unions and useless alternates, (continued)
- [Qemu-devel] [PATCH v5 37/46] qapi: Forbid empty unions and useless alternates, Eric Blake, 2015/09/21
- [Qemu-devel] [PATCH v5 39/46] qapi: Plumb in 'box' to qapi generator lower levels, Eric Blake, 2015/09/21
- [Qemu-devel] [PATCH v5 41/46] qapi: Support boxed unions, Eric Blake, 2015/09/21
- [Qemu-devel] [PATCH v5 40/46] qapi: Implement boxed structs for commands/events, Eric Blake, 2015/09/21
- [Qemu-devel] [PATCH v5 42/46] qapi: support implicit structs in OptsVisitor, Eric Blake, 2015/09/21
- [Qemu-devel] [PATCH v5 31/46] qapi: use 'type' in generated C code to match QMP union wire form, Eric Blake, 2015/09/21
- [Qemu-devel] [PATCH v5 44/46] net: Use correct type for bool flag, Eric Blake, 2015/09/21
- [Qemu-devel] [PATCH v5 46/46] qapi: Allow anonymous base for flat union, Eric Blake, 2015/09/21
- [Qemu-devel] [PATCH v5 43/46] qapi: Change Netdev into a flat union, Eric Blake, 2015/09/21
- [Qemu-devel] [PATCH v5 45/46] net: Complete qapi-fication of netdev_add,
Eric Blake <=
Re: [Qemu-devel] [PATCH v5 00/46] post-introspection cleanups, and qapi-ify netdev_add, Markus Armbruster, 2015/09/29