From: Eric Blake <eblake@redhat.com>
To: qemu-devel@nongnu.org
Cc: armbru@redhat.com, Jason Wang <jasowang@redhat.com>
Subject: [Qemu-devel] [PATCH v7 13/15] net: Complete qapi-fication of netdev_add
Date: Fri, 20 May 2016 16:40:22 -0600 [thread overview]
Message-ID: <1463784024-17242-14-git-send-email-eblake@redhat.com> (raw)
In-Reply-To: <1463784024-17242-1-git-send-email-eblake@redhat.com>
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 <eblake@redhat.com>
---
v7: no change
v6: don't lose qemu_opts handling
---
qapi-schema.json | 15 +++------------
include/net/net.h | 1 -
net/net.c | 6 +++---
qmp-commands.hx | 2 +-
4 files changed, 7 insertions(+), 17 deletions(-)
diff --git a/qapi-schema.json b/qapi-schema.json
index 4fee44b..fee4d07 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -2301,26 +2301,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/include/net/net.h b/include/net/net.h
index 74b32e0..8f9be98 100644
--- a/include/net/net.h
+++ b/include/net/net.h
@@ -193,7 +193,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 e159506..b93ff00 100644
--- a/net/net.c
+++ b/net/net.c
@@ -1188,7 +1188,7 @@ 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;
@@ -1199,12 +1199,12 @@ void qmp_netdev_add(QDict *qdict, QObject **ret, Error **errp)
goto out;
}
- opts = qemu_opts_from_qdict(opts_list, qdict, &local_err);
+ opts = qemu_opts_create(opts_list, netdev->id, 1, &local_err);
if (local_err) {
goto out;
}
- netdev_add(opts, &local_err);
+ net_client_init1(netdev, true, &local_err);
if (local_err) {
qemu_opts_del(opts);
goto out;
diff --git a/qmp-commands.hx b/qmp-commands.hx
index 94847e5..3804030 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -949,7 +949,7 @@ EQMP
{
.name = "netdev_add",
.args_type = "netdev:O",
- .mhandler.cmd_new = qmp_netdev_add,
+ .mhandler.cmd_new = qmp_marshal_netdev_add,
},
SQMP
--
2.5.5
next prev parent reply other threads:[~2016-05-20 22:40 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-20 22:40 [Qemu-devel] [PATCH v7 00/15] qapi netdev_add introspection (post-introspection cleanups subset F) Eric Blake
2016-05-20 22:40 ` [Qemu-devel] [PATCH v7 01/15] qapi: Consolidate object visitors Eric Blake
2016-06-14 12:35 ` Markus Armbruster
2016-06-16 14:46 ` Markus Armbruster
2016-06-16 17:20 ` Eric Blake
2016-06-17 7:39 ` Markus Armbruster
2016-05-20 22:40 ` [Qemu-devel] [PATCH v7 02/15] net: use Netdev instead of NetClientOptions in client init Eric Blake
2016-06-14 13:11 ` Markus Armbruster
2016-05-20 22:40 ` [Qemu-devel] [PATCH v7 03/15] qapi: Require all branches of flat union enum to be covered Eric Blake
2016-06-14 13:24 ` Markus Armbruster
2016-06-14 13:46 ` Eric Blake
2016-06-28 1:52 ` Eric Blake
2016-06-28 7:57 ` Markus Armbruster
2016-07-03 2:34 ` Eric Blake
2016-05-20 22:40 ` [Qemu-devel] [PATCH v7 04/15] qapi: Hide tag_name data member of variants Eric Blake
2016-06-14 13:32 ` Markus Armbruster
2016-05-20 22:40 ` [Qemu-devel] [PATCH v7 05/15] qapi: Add type.is_empty() helper Eric Blake
2016-06-14 14:01 ` Markus Armbruster
2016-05-20 22:40 ` [Qemu-devel] [PATCH v7 06/15] qapi: Plumb in 'box' to qapi generator lower levels Eric Blake
2016-06-14 14:39 ` Markus Armbruster
2016-05-20 22:40 ` [Qemu-devel] [PATCH v7 07/15] qapi: Implement boxed types for commands/events Eric Blake
2016-06-14 15:27 ` Markus Armbruster
2016-06-14 17:22 ` Eric Blake
2016-06-15 6:22 ` Markus Armbruster
2016-05-20 22:40 ` [Qemu-devel] [PATCH v7 08/15] block: Simplify block_set_io_throttle Eric Blake
2016-05-24 15:21 ` [Qemu-devel] [Qemu-block] " Alberto Garcia
2016-06-14 15:34 ` [Qemu-devel] " Markus Armbruster
2016-05-20 22:40 ` [Qemu-devel] [PATCH v7 09/15] block: Simplify drive-mirror Eric Blake
2016-06-14 15:42 ` Markus Armbruster
2016-05-20 22:40 ` [Qemu-devel] [PATCH v7 10/15] qapi-event: Reduce chance of collision with event data Eric Blake
2016-06-14 16:28 ` Markus Armbruster
2016-06-16 12:25 ` Markus Armbruster
2016-06-28 3:20 ` Eric Blake
2016-06-28 8:06 ` Markus Armbruster
2016-05-20 22:40 ` [Qemu-devel] [PATCH v7 11/15] qapi: Change Netdev into a flat union Eric Blake
2016-06-16 13:15 ` Markus Armbruster
2016-06-16 14:35 ` Eric Blake
2016-05-20 22:40 ` [Qemu-devel] [PATCH v7 12/15] net: Use correct type for bool flag Eric Blake
2016-05-20 22:40 ` Eric Blake [this message]
2016-06-16 13:40 ` [Qemu-devel] [PATCH v7 13/15] net: Complete qapi-fication of netdev_add Markus Armbruster
2016-07-02 22:58 ` Eric Blake
2016-07-04 13:46 ` Markus Armbruster
2016-05-20 22:40 ` [Qemu-devel] [PATCH v7 14/15] qapi: Allow anonymous branch types in flat union Eric Blake
2016-06-16 14:33 ` Markus Armbruster
2016-07-01 22:59 ` Eric Blake
2016-07-04 13:13 ` Markus Armbruster
2016-05-20 22:40 ` [Qemu-devel] [PATCH v7 15/15] schema: Drop pointless empty type CpuInfoOther Eric Blake
2016-05-20 22:59 ` [Qemu-devel] [PATCH v7 00/15] qapi netdev_add introspection (post-introspection cleanups subset F) Eric Blake
2016-06-16 14:57 ` Markus Armbruster
2016-06-28 18:14 ` Eric Blake
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=1463784024-17242-14-git-send-email-eblake@redhat.com \
--to=eblake@redhat.com \
--cc=armbru@redhat.com \
--cc=jasowang@redhat.com \
--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).