aboutsummaryrefslogtreecommitdiff
path: root/net.c
diff options
context:
space:
mode:
authorMark McLoughlin <markmc@redhat.com>2009-10-06 12:17:13 +0100
committerAnthony Liguori <aliguori@us.ibm.com>2009-10-06 14:36:13 -0500
commit7f1c9d20eab92090650f0356d45fcdf5c190a22a (patch)
treeb2f7c339bfdd4d6156d1c2944faf6e7cfdebe83b /net.c
parent7b3fb251102b5529fa0efff6d5e06bc6ed2715f0 (diff)
Port host_net_add monitor command to QemuOpts
Here is where we rely on qemu_opts_parse() to handle an empty string. We could alternatively explicitly handle this here by using qemu_opts_create() when we're not supplied any parameters, but its cleaner this way. Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'net.c')
-rw-r--r--net.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/net.c b/net.c
index 534305ca26..1ebf147c7d 100644
--- a/net.c
+++ b/net.c
@@ -3101,13 +3101,24 @@ static int net_host_check_device(const char *device)
void net_host_device_add(Monitor *mon, const QDict *qdict)
{
const char *device = qdict_get_str(qdict, "device");
- const char *opts = qdict_get_try_str(qdict, "opts");
+ const char *opts_str = qdict_get_try_str(qdict, "opts");
+ QemuOpts *opts;
if (!net_host_check_device(device)) {
monitor_printf(mon, "invalid host network device %s\n", device);
return;
}
- if (net_client_init(mon, device, opts ? opts : "") < 0) {
+
+ opts = qemu_opts_parse(&qemu_net_opts, opts_str ? opts_str : "", NULL);
+ if (!opts) {
+ monitor_printf(mon, "parsing network options '%s' failed\n",
+ opts_str ? opts_str : "");
+ return;
+ }
+
+ qemu_opt_set(opts, "type", device);
+
+ if (net_client_init_from_opts(mon, opts) < 0) {
monitor_printf(mon, "adding host network device %s failed\n", device);
}
}