diff options
author | Luiz Capitulino <lcapitulino@redhat.com> | 2012-04-18 17:34:15 -0300 |
---|---|---|
committer | Luiz Capitulino <lcapitulino@redhat.com> | 2012-06-04 13:49:35 -0300 |
commit | 928059a37b8e1f152962431fb846f39597b63c36 (patch) | |
tree | 4cd8ab47ebd78c1756406e1dde5075609beb301c /net.c | |
parent | 4559a1dbcc15a10482de822e2839645a1819ef6f (diff) | |
download | qemu-928059a37b8e1f152962431fb846f39597b63c36.tar.gz qemu-928059a37b8e1f152962431fb846f39597b63c36.tar.bz2 qemu-928059a37b8e1f152962431fb846f39597b63c36.zip |
qapi: convert netdev_add
This is not a full QAPI conversion, but an intermediate step.
In essence, do_netdev_add() is split into three functions:
1. netdev_add(): performs the actual work. This function is fully
converted to Error (thus, it's "qapi-friendly")
2. qmp_netdev_add(): the QMP front-end for netdev_add(). This is
coded by hand and not auto-generated (gen=no in the schema). The
reason for this it's a lot easier and simpler to with QemuOpts
this way
3. hmp_netdev_add(): HMP front-end.
This design was suggested by Paolo Bonzini.
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-By: Laszlo Ersek <lersek@redhat.com>
Diffstat (limited to 'net.c')
-rw-r--r-- | net.c | 36 |
1 files changed, 24 insertions, 12 deletions
@@ -1234,27 +1234,39 @@ void net_host_device_remove(Monitor *mon, const QDict *qdict) qemu_del_vlan_client(vc); } -int do_netdev_add(Monitor *mon, const QDict *qdict, QObject **ret_data) +void netdev_add(QemuOpts *opts, Error **errp) +{ + net_client_init(opts, 1, errp); +} + +int qmp_netdev_add(Monitor *mon, const QDict *qdict, QObject **ret) { Error *local_err = NULL; + QemuOptsList *opts_list; QemuOpts *opts; - int res; - opts = qemu_opts_from_qdict(qemu_find_opts("netdev"), qdict, &local_err); - if (!opts) { - qerror_report_err(local_err); - error_free(local_err); - return -1; + opts_list = qemu_find_opts_err("netdev", &local_err); + if (error_is_set(&local_err)) { + goto exit_err; } - res = net_client_init(opts, 1, &local_err); - if (res < 0) { - qerror_report_err(local_err); - error_free(local_err); + opts = qemu_opts_from_qdict(opts_list, qdict, &local_err); + if (error_is_set(&local_err)) { + goto exit_err; + } + + netdev_add(opts, &local_err); + if (error_is_set(&local_err)) { qemu_opts_del(opts); + goto exit_err; } - return res; + return 0; + +exit_err: + qerror_report_err(local_err); + error_free(local_err); + return -1; } int do_netdev_del(Monitor *mon, const QDict *qdict, QObject **ret_data) |