Patchwork [v3,05/12] net: slirp: use info_dict instead of info_str

login
register
mail settings
Submitter Miguel Di Ciurcio Filho
Date April 15, 2010, 2:07 p.m.
Message ID <1271340427-12579-6-git-send-email-miguel.filho@gmail.com>
Download mbox | patch
Permalink /patch/50274/
State New
Headers show

Comments

Miguel Di Ciurcio Filho - April 15, 2010, 2:07 p.m.
Signed-off-by: Miguel Di Ciurcio Filho <miguel.filho@gmail.com>
---
 net/slirp.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
Luiz Capitulino - April 23, 2010, 9:06 p.m.
On Thu, 15 Apr 2010 11:07:00 -0300
Miguel Di Ciurcio Filho <miguel.filho@gmail.com> wrote:

> Signed-off-by: Miguel Di Ciurcio Filho <miguel.filho@gmail.com>
> ---
>  net/slirp.c |    8 ++++++--
>  1 files changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/net/slirp.c b/net/slirp.c
> index b41c60a..eb9d261 100644
> --- a/net/slirp.c
> +++ b/net/slirp.c
> @@ -32,6 +32,9 @@
>  #include "monitor.h"
>  #include "sysemu.h"
>  #include "qemu_socket.h"
> +#include "qdict.h"
> +#include "qbool.h"
> +#include "qstring.h"
>  #include "slirp/libslirp.h"
>  
>  static int get_str_sep(char *buf, int buf_size, const char **pp, int sep)
> @@ -240,8 +243,9 @@ static int net_slirp_init(VLANState *vlan, const char *model,
>  
>      nc = qemu_new_net_client(&net_slirp_info, vlan, NULL, model, name);
>  
> -    snprintf(nc->info_str, sizeof(nc->info_str),
> -             "net=%s, restricted=%c", inet_ntoa(net), restricted ? 'y' : 'n');
> +    nc->info_dict = qdict_new();
> +    qdict_put(nc->info_dict, "net", qstring_from_str(inet_ntoa(net)));
> +    qdict_put(nc->info_dict, "restricted", qbool_from_int(restricted));

 This is going to be freed by qemu_del_vlan_client(), right?

>  
>      s = DO_UPCAST(SlirpState, nc, nc);
>

Patch

diff --git a/net/slirp.c b/net/slirp.c
index b41c60a..eb9d261 100644
--- a/net/slirp.c
+++ b/net/slirp.c
@@ -32,6 +32,9 @@ 
 #include "monitor.h"
 #include "sysemu.h"
 #include "qemu_socket.h"
+#include "qdict.h"
+#include "qbool.h"
+#include "qstring.h"
 #include "slirp/libslirp.h"
 
 static int get_str_sep(char *buf, int buf_size, const char **pp, int sep)
@@ -240,8 +243,9 @@  static int net_slirp_init(VLANState *vlan, const char *model,
 
     nc = qemu_new_net_client(&net_slirp_info, vlan, NULL, model, name);
 
-    snprintf(nc->info_str, sizeof(nc->info_str),
-             "net=%s, restricted=%c", inet_ntoa(net), restricted ? 'y' : 'n');
+    nc->info_dict = qdict_new();
+    qdict_put(nc->info_dict, "net", qstring_from_str(inet_ntoa(net)));
+    qdict_put(nc->info_dict, "restricted", qbool_from_int(restricted));
 
     s = DO_UPCAST(SlirpState, nc, nc);