[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 4/7] net: tap/tap-win32: introduce info_dict
From: |
Miguel Di Ciurcio Filho |
Subject: |
[Qemu-devel] [PATCH 4/7] net: tap/tap-win32: introduce info_dict |
Date: |
Wed, 23 Jun 2010 12:40:00 -0300 |
Signed-off-by: Miguel Di Ciurcio Filho <address@hidden>
---
net/tap-win32.c | 7 +++++++
net/tap.c | 22 +++++++++++++++++++++-
2 files changed, 28 insertions(+), 1 deletions(-)
diff --git a/net/tap-win32.c b/net/tap-win32.c
index 74348da..5e58702 100644
--- a/net/tap-win32.c
+++ b/net/tap-win32.c
@@ -32,6 +32,8 @@
#include "net.h"
#include "sysemu.h"
#include "qemu-error.h"
+#include "qdict.h"
+#include "qstring.h"
#include <stdio.h>
#include <windows.h>
#include <winioctl.h>
@@ -693,6 +695,11 @@ static int tap_win32_init(VLANState *vlan, const char
*model,
snprintf(s->nc.info_str, sizeof(s->nc.info_str),
"tap: ifname=%s", ifname);
+ nc->info_dict = qdict_new()
+ qdict_put(nc->info_dict, "ifname", qstring_from_str(ifname));
+ qdict_put(nc->info_dict, "vhost", qbool_from_int(0));
+ qdict_put(nc->info_dict, "vnet_hdr", qbool_from_int(0));
+
s->handle = handle;
qemu_add_wait_object(s->handle->tap_semaphore, tap_win32_send, s);
diff --git a/net/tap.c b/net/tap.c
index 0147dab..f294091 100644
--- a/net/tap.c
+++ b/net/tap.c
@@ -39,6 +39,8 @@
#include "qemu-char.h"
#include "qemu-common.h"
#include "qemu-error.h"
+#include "qint.h"
+#include "qbool.h"
#include "net/tap-linux.h"
@@ -448,6 +450,11 @@ int net_init_tap(QemuOpts *opts, Monitor *mon, const char
*name, VLANState *vlan
if (qemu_opt_get(opts, "fd")) {
snprintf(s->nc.info_str, sizeof(s->nc.info_str), "fd=%d", fd);
+
+ assert(s->nc.info_dict == NULL);
+ s->nc.info_dict = qdict_new();
+ qdict_put(s->nc.info_dict, "fd", qint_from_int(fd));
+
} else {
const char *ifname, *script, *downscript;
@@ -459,12 +466,23 @@ int net_init_tap(QemuOpts *opts, Monitor *mon, const char
*name, VLANState *vlan
"ifname=%s,script=%s,downscript=%s",
ifname, script, downscript);
- if (strcmp(downscript, "no") != 0) {
+ assert(s->nc.info_dict == NULL);
+ s->nc.info_dict = qdict_new();
+ qdict_put(s->nc.info_dict, "ifname", qstring_from_str(ifname));
+
+ if (strcmp(downscript, "no") != 0 && downscript[0] != '\0') {
snprintf(s->down_script, sizeof(s->down_script), "%s", downscript);
snprintf(s->down_script_arg, sizeof(s->down_script_arg), "%s",
ifname);
+ qdict_put(s->nc.info_dict, "downscript",
qstring_from_str(downscript));
+ }
+
+ if (strcmp(script, "no") != 0 && script[0] != '\0') {
+ qdict_put(s->nc.info_dict, "script", qstring_from_str(script));
}
}
+ qdict_put(s->nc.info_dict, "vnet_hdr", qbool_from_int(s->has_vnet_hdr));
+
if (qemu_opt_get_bool(opts, "vhost", !!qemu_opt_get(opts, "vhostfd"))) {
int vhostfd, r;
if (qemu_opt_get(opts, "vhostfd")) {
@@ -473,6 +491,7 @@ int net_init_tap(QemuOpts *opts, Monitor *mon, const char
*name, VLANState *vlan
return -1;
}
vhostfd = r;
+ qdict_put(s->nc.info_dict, "vhostfd", qint_from_int(vhostfd));
} else {
vhostfd = -1;
}
@@ -486,6 +505,7 @@ int net_init_tap(QemuOpts *opts, Monitor *mon, const char
*name, VLANState *vlan
return -1;
}
+ qdict_put(s->nc.info_dict, "vhost", qbool_from_int(s->vhost_net ? 1 : 0));
return 0;
}
--
1.7.1
- [Qemu-devel] [PATCH 0/7] QMP: Introduce query-netdev, Miguel Di Ciurcio Filho, 2010/06/23
- [Qemu-devel] [PATCH 1/7] QMP: Introduce the documentation for query-netdev and info netdev, Miguel Di Ciurcio Filho, 2010/06/23
- [Qemu-devel] [PATCH 2/7] QObject API: introduce qdict_to_qstring() function, Miguel Di Ciurcio Filho, 2010/06/23
- [Qemu-devel] [PATCH 3/7] net: Introduce VLANClientState->info_dict, Miguel Di Ciurcio Filho, 2010/06/23
- [Qemu-devel] [PATCH 4/7] net: tap/tap-win32: introduce info_dict,
Miguel Di Ciurcio Filho <=
- [Qemu-devel] [PATCH 5/7] net: vde: introduce info_dict, Miguel Di Ciurcio Filho, 2010/06/23
- [Qemu-devel] [PATCH 6/7] net: slirp: introduce info_dict, Miguel Di Ciurcio Filho, 2010/06/23
- [Qemu-devel] [PATCH 7/7] monitor/net: introduce 'info netdev' with QMP support, Miguel Di Ciurcio Filho, 2010/06/23
- [Qemu-devel] Re: [PATCH 0/7] QMP: Introduce query-netdev, Luiz Capitulino, 2010/06/28