All of lore.kernel.org
 help / color / mirror / Atom feed
From: Luiz Capitulino <lcapitulino@redhat.com>
To: Miguel Di Ciurcio Filho <miguel.filho@gmail.com>
Cc: qemu-devel@nongnu.org, armbru@redhat.com
Subject: [Qemu-devel] Re: [PATCH 19/22] net: socket: replace qemu_format_nic_info_str by qemu_format_nic_info_dict
Date: Fri, 9 Apr 2010 14:47:53 -0300	[thread overview]
Message-ID: <20100409144753.2f249d27@redhat.com> (raw)
In-Reply-To: <1270757799-31891-20-git-send-email-miguel.filho@gmail.com>

On Thu,  8 Apr 2010 17:16:36 -0300
Miguel Di Ciurcio Filho <miguel.filho@gmail.com> wrote:

> Signed-off-by: Miguel Di Ciurcio Filho <miguel.filho@gmail.com>
> ---
>  net/socket.c |   47 ++++++++++++++++++++++++++++++++++-------------
>  1 files changed, 34 insertions(+), 13 deletions(-)
> 
> diff --git a/net/socket.c b/net/socket.c
> index 1c4e153..3521e21 100644
> --- a/net/socket.c
> +++ b/net/socket.c
> @@ -28,6 +28,10 @@
>  #include "net.h"
>  #include "qemu-char.h"
>  #include "qemu-common.h"
> +#include "qdict.h"
> +#include "qstring.h"
> +#include "qbool.h"
> +#include "qint.h"
>  #include "qemu-error.h"
>  #include "qemu-option.h"
>  #include "qemu_socket.h"
> @@ -266,11 +270,16 @@ static NetSocketState *net_socket_fd_init_dgram(VLANState *vlan,
>      }
>  
>      nc = qemu_new_net_client(&net_dgram_socket_info, vlan, NULL, model, name);
> -
> -    snprintf(nc->info_str, sizeof(nc->info_str),
> -	    "socket: fd=%d (%s mcast=%s:%d)",
> -	    fd, is_connected ? "cloned" : "",
> -	    inet_ntoa(saddr.sin_addr), ntohs(saddr.sin_port));
> +    
> +    nc->info_dict = qdict_new();
> +    qdict_put(nc->info_dict, "fd", qint_from_int(fd));
> +    
> +    char mcast_addr[22];
> +    snprintf(mcast_addr, strlen(mcast_addr), "%s:%d",
> +                     inet_ntoa(saddr.sin_addr),
> +                     ntohs(saddr.sin_port));
> +    qdict_put(nc->info_dict, "mcast", qstring_from_str(mcast_addr));

 We should break 'mcast', otherwise QMP clients will have to parse it. Maybe
you can make vnc.c::put_addr_qdict() public and use it (with a better name).

 Note that this is also valid for 'connection_from' and all the others..


> +    qdict_put(nc->info_dict, "cloned", qbool_from_int(is_connected));
>  
>      s = DO_UPCAST(NetSocketState, nc, nc);
>  
> @@ -306,8 +315,9 @@ static NetSocketState *net_socket_fd_init_stream(VLANState *vlan,
>      NetSocketState *s;
>  
>      nc = qemu_new_net_client(&net_socket_info, vlan, NULL, model, name);
> +    nc->info_dict = qdict_new();
>  
> -    snprintf(nc->info_str, sizeof(nc->info_str), "socket: fd=%d", fd);
> +    qdict_put(nc->info_dict, "fd", qint_from_int(fd));
>  
>      s = DO_UPCAST(NetSocketState, nc, nc);
>  
> @@ -366,9 +376,12 @@ static void net_socket_accept(void *opaque)
>      if (!s1) {
>          closesocket(fd);
>      } else {
> -        snprintf(s1->nc.info_str, sizeof(s1->nc.info_str),
> -                 "socket: connection from %s:%d",
> +        char connection_from[22];
> +        s1->nc.info_dict = qdict_new();
> +
> +        snprintf(connection_from, strlen(connection_from), "%s:%d", 
>                   inet_ntoa(saddr.sin_addr), ntohs(saddr.sin_port));
> +        qdict_put(s1->nc.info_dict, "connection_from", qstring_from_str(connection_from));
>      }
>  }
>  
> @@ -459,9 +472,13 @@ static int net_socket_connect_init(VLANState *vlan,
>      s = net_socket_fd_init(vlan, model, name, fd, connected);
>      if (!s)
>          return -1;
> -    snprintf(s->nc.info_str, sizeof(s->nc.info_str),
> -             "socket: connect to %s:%d",
> +
> +    char connect_to[22];
> +    s->nc.info_dict = qdict_new();
> +
> +    snprintf(connect_to, strlen(connect_to), "%s:%d", 
>               inet_ntoa(saddr.sin_addr), ntohs(saddr.sin_port));
> +    qdict_put(s->nc.info_dict, "connect_to", qstring_from_str(connect_to));
>      return 0;
>  }
>  
> @@ -487,10 +504,14 @@ static int net_socket_mcast_init(VLANState *vlan,
>          return -1;
>  
>      s->dgram_dst = saddr;
> +    
> +    s->nc.info_dict = qdict_new();
> +    char mcast_addr[22];
> +    snprintf(mcast_addr, strlen(mcast_addr), "%s:%d",
> +                     inet_ntoa(saddr.sin_addr),
> +                     ntohs(saddr.sin_port));
> +    qdict_put(s->nc.info_dict, "mcast", qstring_from_str(mcast_addr));
>  
> -    snprintf(s->nc.info_str, sizeof(s->nc.info_str),
> -             "socket: mcast=%s:%d",
> -             inet_ntoa(saddr.sin_addr), ntohs(saddr.sin_port));
>      return 0;
>  
>  }

  reply	other threads:[~2010-04-09 17:52 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-08 20:16 [Qemu-devel] [PATCH 0/22] Convert do_info_network() to QObject/QMP Miguel Di Ciurcio Filho
2010-04-08 20:16 ` [Qemu-devel] [PATCH 01/22] QObject API: add qdict_to_qstring() function Miguel Di Ciurcio Filho
2010-04-09 17:26   ` [Qemu-devel] " Luiz Capitulino
2010-04-08 20:16 ` [Qemu-devel] [PATCH 02/22] net: replace qemu_nic_format_info_str and VLANClientState->info_str by QDicts Miguel Di Ciurcio Filho
2010-04-09 17:41   ` [Qemu-devel] " Luiz Capitulino
2010-04-08 20:16 ` [Qemu-devel] [PATCH 03/22] net: dp8393x: replace qemu_format_nic_info_str by qemu_format_nic_info_dict Miguel Di Ciurcio Filho
2010-04-08 20:16 ` [Qemu-devel] [PATCH 04/22] net: e1000: " Miguel Di Ciurcio Filho
2010-04-08 20:16 ` [Qemu-devel] [PATCH 05/22] net: eepro100: " Miguel Di Ciurcio Filho
2010-04-09 17:42   ` [Qemu-devel] " Luiz Capitulino
2010-04-08 20:16 ` [Qemu-devel] [PATCH 06/22] net: ne2000: " Miguel Di Ciurcio Filho
2010-04-08 20:16 ` [Qemu-devel] [PATCH 07/22] net: pcnet: " Miguel Di Ciurcio Filho
2010-04-08 20:16 ` [Qemu-devel] [PATCH 08/22] net: lan9118: " Miguel Di Ciurcio Filho
2010-04-08 20:16 ` [Qemu-devel] [PATCH 09/22] net: mcf_fec: " Miguel Di Ciurcio Filho
2010-04-08 20:16 ` [Qemu-devel] [PATCH 10/22] net: mipsnet: " Miguel Di Ciurcio Filho
2010-04-08 20:16 ` [Qemu-devel] [PATCH 11/22] net: rtl8139: " Miguel Di Ciurcio Filho
2010-04-08 20:16 ` [Qemu-devel] [PATCH 12/22] net: smc91c111: " Miguel Di Ciurcio Filho
2010-04-08 20:16 ` [Qemu-devel] [PATCH 13/22] net: stellaris_enet: " Miguel Di Ciurcio Filho
2010-04-08 20:16 ` [Qemu-devel] [PATCH 14/22] net: usb-net: " Miguel Di Ciurcio Filho
2010-04-08 20:16 ` [Qemu-devel] [PATCH 15/22] net: virtio-net: " Miguel Di Ciurcio Filho
2010-04-08 20:16 ` [Qemu-devel] [PATCH 16/22] net: xilinx_ethlite: " Miguel Di Ciurcio Filho
2010-04-08 20:16 ` [Qemu-devel] [PATCH 17/22] net: dump: " Miguel Di Ciurcio Filho
2010-04-08 20:16 ` [Qemu-devel] [PATCH 18/22] net: slirp: " Miguel Di Ciurcio Filho
2010-04-09 17:42   ` [Qemu-devel] " Luiz Capitulino
2010-04-08 20:16 ` [Qemu-devel] [PATCH 19/22] net: socket: " Miguel Di Ciurcio Filho
2010-04-09 17:47   ` Luiz Capitulino [this message]
2010-04-08 20:16 ` [Qemu-devel] [PATCH 20/22] net: tap: replace qemu_format_nic_info_str by info_dict Miguel Di Ciurcio Filho
2010-04-09 17:48   ` [Qemu-devel] " Luiz Capitulino
2010-04-08 20:16 ` [Qemu-devel] [PATCH 21/22] net: vde: " Miguel Di Ciurcio Filho
2010-04-08 20:16 ` [Qemu-devel] [PATCH 22/22] monitor/net: Convert do_info_network() to QObject/QMP Miguel Di Ciurcio Filho
2010-04-09 17:52   ` [Qemu-devel] " Luiz Capitulino
2010-04-09 17:25 ` [Qemu-devel] Re: [PATCH 0/22] " Luiz Capitulino

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100409144753.2f249d27@redhat.com \
    --to=lcapitulino@redhat.com \
    --cc=armbru@redhat.com \
    --cc=miguel.filho@gmail.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.