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>
This commit is contained in:
Luiz Capitulino 2012-04-18 17:34:15 -03:00
parent 4559a1dbcc
commit 928059a37b
7 changed files with 78 additions and 19 deletions

21
hmp.c
View file

@ -14,6 +14,8 @@
*/
#include "hmp.h"
#include "net.h"
#include "qemu-option.h"
#include "qemu-timer.h"
#include "qmp-commands.h"
@ -969,3 +971,22 @@ void hmp_dump_guest_memory(Monitor *mon, const QDict *qdict)
&errp);
hmp_handle_error(mon, &errp);
}
void hmp_netdev_add(Monitor *mon, const QDict *qdict)
{
Error *err = NULL;
QemuOpts *opts;
opts = qemu_opts_from_qdict(qemu_find_opts("netdev"), qdict, &err);
if (error_is_set(&err)) {
goto out;
}
netdev_add(opts, &err);
if (error_is_set(&err)) {
qemu_opts_del(opts);
}
out:
hmp_handle_error(mon, &err);
}