From patchwork Thu Apr 8 20:16:19 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: 49746 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 448B3B7D24 for ; Fri, 9 Apr 2010 06:19:58 +1000 (EST) Received: from localhost ([127.0.0.1]:46077 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NzyBL-0000SI-3c for incoming@patchwork.ozlabs.org; Thu, 08 Apr 2010 16:18:31 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Nzy6v-0007Gi-OR for qemu-devel@nongnu.org; Thu, 08 Apr 2010 16:13:57 -0400 Received: from [140.186.70.92] (port=43944 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nzy6u-0007Fh-7O for qemu-devel@nongnu.org; Thu, 08 Apr 2010 16:13:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Nzy6s-0003yC-BW for qemu-devel@nongnu.org; Thu, 08 Apr 2010 16:13:55 -0400 Received: from mail-qy0-f188.google.com ([209.85.221.188]:37069) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Nzy6s-0003y4-9E for qemu-devel@nongnu.org; Thu, 08 Apr 2010 16:13:54 -0400 Received: by qyk26 with SMTP id 26so2709084qyk.19 for ; Thu, 08 Apr 2010 13:13:53 -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=16lOmWcc1jg52MAj22ov4UhOoBnuizAqowIy3scl0KE=; b=GQ5eEUWQhS2CyBZNeEt0P9/RfgCK+hv1EQQURdOL075YIBq0Dke8NbZEk2oiwBnAoz TC9cjKkN15pyIE4cJZV5TsPUxnGopqKdOfn7JehlRBAhZax0Ud5zFT+YmZiC4KRSyqH9 8eUc3Dov93qXLBVe0QQW5BAx+hFp5Y5hdZfJU= 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=K0It8Ix6DrB6WGzmbRxP0VwZ9YRoeQ79LBea6rrofXFYwXK41UFY8WZfPZadGjeMkk n1EebiGBaVtsFMO7COMXRN7BGasyloc2CmY20nBNvb97inFvGmF1iGuhkySUabo8r/wm Ea74yF6A2YpSissH3q9uBraco9yCgmsk1/+Uw= Received: by 10.229.211.210 with SMTP id gp18mr843704qcb.31.1270757632635; Thu, 08 Apr 2010 13:13:52 -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.13.50 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 08 Apr 2010 13:13:51 -0700 (PDT) From: Miguel Di Ciurcio Filho To: qemu-devel@nongnu.org Date: Thu, 8 Apr 2010 17:16:19 -0300 Message-Id: <1270757799-31891-3-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 02/22] net: replace qemu_nic_format_info_str and VLANClientState->info_str by QDicts 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 There is no standard format when formatting info_str, so it is difficult to extract information and transmit it over QMP. This patch changes info_str from a simple string to a QDict. Patches that convert the devices to this new format will follow. Signed-off-by: Miguel Di Ciurcio Filho --- net.c | 14 ++++++++++---- net.h | 4 ++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/net.c b/net.c index 3ede738..ad01732 100644 --- a/net.c +++ b/net.c @@ -35,6 +35,8 @@ #include "sysemu.h" #include "qemu-common.h" #include "qemu_socket.h" +#include "qdict.h" +#include "qstring.h" #include "hw/qdev.h" static QTAILQ_HEAD(, VLANState) vlans; @@ -164,13 +166,17 @@ int parse_host_port(struct sockaddr_in *saddr, const char *str) return 0; } -void qemu_format_nic_info_str(VLANClientState *vc, uint8_t macaddr[6]) +void qemu_format_nic_info_dict(VLANClientState *vc, uint8_t macaddr[6]) { - snprintf(vc->info_str, sizeof(vc->info_str), - "model=%s,macaddr=%02x:%02x:%02x:%02x:%02x:%02x", - vc->model, + vc->info_dict = qdict_new(); + char mac[18]; + + snprintf(mac, 18, "%02x:%02x:%02x:%02x:%02x:%02x", macaddr[0], macaddr[1], macaddr[2], macaddr[3], macaddr[4], macaddr[5]); + + qdict_put(vc->info_dict, "macaddr", qstring_from_str(mac)); + qdict_put(vc->info_dict, "model", qstring_from_str(vc->model)); } void qemu_macaddr_default_if_unset(MACAddr *macaddr) diff --git a/net.h b/net.h index 16f19c5..b744294 100644 --- a/net.h +++ b/net.h @@ -65,7 +65,7 @@ struct VLANClientState { NetQueue *send_queue; char *model; char *name; - char info_str[256]; + QDict *info_dict; unsigned receive_disabled : 1; }; @@ -110,7 +110,7 @@ ssize_t qemu_send_packet_async(VLANClientState *vc, const uint8_t *buf, int size, NetPacketSent *sent_cb); void qemu_purge_queued_packets(VLANClientState *vc); void qemu_flush_queued_packets(VLANClientState *vc); -void qemu_format_nic_info_str(VLANClientState *vc, uint8_t macaddr[6]); +void qemu_format_nic_info_dict(VLANClientState *vc, uint8_t macaddr[6]); void qemu_macaddr_default_if_unset(MACAddr *macaddr); int qemu_show_nic_models(const char *arg, const char *const *models); void qemu_check_nic_model(NICInfo *nd, const char *model);