Patchwork [18/22] net: slirp: replace qemu_format_nic_info_str by qemu_format_nic_info_dict

login
register
mail settings
Submitter Miguel Di Ciurcio Filho
Date April 8, 2010, 8:16 p.m.
Message ID <1270757799-31891-19-git-send-email-miguel.filho@gmail.com>
Download mbox | patch
Permalink /patch/49762/
State New
Headers show

Comments

Miguel Di Ciurcio Filho - April 8, 2010, 8:16 p.m.
Signed-off-by: Miguel Di Ciurcio Filho <miguel.filho@gmail.com>
---
 net/slirp.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)
Luiz Capitulino - April 9, 2010, 5:42 p.m.
On Thu,  8 Apr 2010 17:16:35 -0300
Miguel Di Ciurcio Filho <miguel.filho@gmail.com> wrote:

> Signed-off-by: Miguel Di Ciurcio Filho <miguel.filho@gmail.com>
> ---
>  net/slirp.c |    7 +++++--
>  1 files changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/net/slirp.c b/net/slirp.c
> index b41c60a..4036b92 100644
> --- a/net/slirp.c
> +++ b/net/slirp.c
> @@ -32,6 +32,8 @@
>  #include "monitor.h"
>  #include "sysemu.h"
>  #include "qemu_socket.h"
> +#include "qdict.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 +242,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", qstring_from_str( restricted ? "y" : "n"));

 Better to use qbool here.

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

Patch

diff --git a/net/slirp.c b/net/slirp.c
index b41c60a..4036b92 100644
--- a/net/slirp.c
+++ b/net/slirp.c
@@ -32,6 +32,8 @@ 
 #include "monitor.h"
 #include "sysemu.h"
 #include "qemu_socket.h"
+#include "qdict.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 +242,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", qstring_from_str( restricted ? "y" : "n"));
 
     s = DO_UPCAST(SlirpState, nc, nc);