Patchwork [7/8] net: slirp: introduce info_dict

login
register
mail settings
Submitter Miguel Di Ciurcio Filho
Date June 10, 2010, 9:37 p.m.
Message ID <1276205825-1922-8-git-send-email-miguel.filho@gmail.com>
Download mbox | patch
Permalink /patch/55266/
State New
Headers show

Comments

Miguel Di Ciurcio Filho - June 10, 2010, 9:37 p.m.
Signed-off-by: Miguel Di Ciurcio Filho <miguel.filho@gmail.com>
---
 net/slirp.c |   17 ++++++++++++++++-
 1 files changed, 16 insertions(+), 1 deletions(-)

Patch

diff --git a/net/slirp.c b/net/slirp.c
index b41c60a..5735009 100644
--- a/net/slirp.c
+++ b/net/slirp.c
@@ -32,6 +32,10 @@ 
 #include "monitor.h"
 #include "sysemu.h"
 #include "qemu_socket.h"
+#include "qdict.h"
+#include "qbool.h"
+#include "qstring.h"
+#include "qjson.h"
 #include "slirp/libslirp.h"
 
 static int get_str_sep(char *buf, int buf_size, const char **pp, int sep)
@@ -243,6 +247,12 @@  static int net_slirp_init(VLANState *vlan, const char *model,
     snprintf(nc->info_str, sizeof(nc->info_str),
              "net=%s, restricted=%c", inet_ntoa(net), restricted ? 'y' : 'n');
 
+    assert(nc->info_dict == NULL);
+    nc->info_dict = qobject_to_qdict(qobject_from_jsonf("{'net': %s,\
+        'host': %s, 'dhcp': %s, 'dns': %s }", inet_ntoa(net), inet_ntoa(host),
+                        inet_ntoa(dhcp), inet_ntoa(dns)));
+    qdict_put(nc->info_dict, "restricted", qbool_from_int(restricted));
+
     s = DO_UPCAST(SlirpState, nc, nc);
 
     s->slirp = slirp_init(restricted, net, mask, host, vhostname,
@@ -265,8 +275,13 @@  static int net_slirp_init(VLANState *vlan, const char *model,
         smb_export = legacy_smb_export;
     }
     if (smb_export) {
-        if (slirp_smb(s, smb_export, smbsrv) < 0)
+        if (slirp_smb(s, smb_export, smbsrv) < 0) {
             goto error;
+        } else {
+            qdict_put(nc->info_dict, "smb", qstring_from_str(smb_export));
+            qdict_put(nc->info_dict, "smbserver",
+                qstring_from_str(inet_ntoa(smbsrv)));
+        }
     }
 #endif