From patchwork Thu Apr 8 20:16:36 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miguel Di Ciurcio Filho X-Patchwork-Id: 49763 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 4A7B0B7CFA for ; Fri, 9 Apr 2010 06:52:15 +1000 (EST) Received: from localhost ([127.0.0.1]:34728 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nzyhb-0005ch-DI for incoming@patchwork.ozlabs.org; Thu, 08 Apr 2010 16:51:51 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Nzy8C-0008K9-IX for qemu-devel@nongnu.org; Thu, 08 Apr 2010 16:15:16 -0400 Received: from [140.186.70.92] (port=44391 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nzy8A-0008IG-7m for qemu-devel@nongnu.org; Thu, 08 Apr 2010 16:15:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Nzy86-0004Df-RK for qemu-devel@nongnu.org; Thu, 08 Apr 2010 16:15:14 -0400 Received: from mail-qy0-f188.google.com ([209.85.221.188]:37221) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Nzy86-00047q-Mm for qemu-devel@nongnu.org; Thu, 08 Apr 2010 16:15:10 -0400 Received: by mail-qy0-f188.google.com with SMTP id 26so2709965qyk.19 for ; Thu, 08 Apr 2010 13:15:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:date :message-id:x-mailer:in-reply-to:references; bh=H1LYPIkPWsBlRhcuuHF4vR9T4NYdyHqTr2ZiFI84Ino=; b=mVyquSdfMBdodEzNnTD1WcF0mKDvWSZEhcnLtX9asbr7MIvf+dLzA2P+CsGPKFfMAQ QLbGGWVqC/xb9Z8kOiyT7+duW4QnQM1LPUtn4tehbmWwqIO/axrCBVKwu3Hpwuu/8RNm L8lAVp8L8gig6AdxcTj4cWrxOjLJQ3KWNiMwo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; b=KmPQ7TX4fPU1Ney1hSRe/cBoZzyZgOHz0cdg20oe8m3CKjPXaRw35qCUyQlOcgMwyO IN9PWFwXccDb9zxBJqSRVdWnmzJUhV3VIB5pFP3VTa7N+de+qpanzlKN+GU005DzxG9U seeha5gWzpudOuUNz6B5vhYmsTHSGYyduUvj8= Received: by 10.229.91.11 with SMTP id k11mr1045912qcm.50.1270757710101; Thu, 08 Apr 2010 13:15:10 -0700 (PDT) Received: from localhost.localdomain (quake.ic.unicamp.br [143.106.7.51]) by mx.google.com with ESMTPS id w30sm776636qce.4.2010.04.08.13.15.07 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 08 Apr 2010 13:15:09 -0700 (PDT) From: Miguel Di Ciurcio Filho To: qemu-devel@nongnu.org Date: Thu, 8 Apr 2010 17:16:36 -0300 Message-Id: <1270757799-31891-20-git-send-email-miguel.filho@gmail.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1270757799-31891-1-git-send-email-miguel.filho@gmail.com> References: <1270757799-31891-1-git-send-email-miguel.filho@gmail.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) Cc: armbru@redhat.com, lcapitulino@redhat.com Subject: [Qemu-devel] [PATCH 19/22] net: socket: replace qemu_format_nic_info_str by qemu_format_nic_info_dict X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Miguel Di Ciurcio Filho --- 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)); + 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; }