From patchwork Thu Apr 15 14:06:57 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: 50276 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 0556AB7D1B for ; Fri, 16 Apr 2010 01:39:55 +1000 (EST) Received: from localhost ([127.0.0.1]:55985 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O2R5p-0001tW-GP for incoming@patchwork.ozlabs.org; Thu, 15 Apr 2010 11:35:01 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1O2Ptv-0003mz-DZ for qemu-devel@nongnu.org; Thu, 15 Apr 2010 10:18:39 -0400 Received: from [140.186.70.92] (port=50361 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O2Ptp-0003GA-Pk for qemu-devel@nongnu.org; Thu, 15 Apr 2010 10:18:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1O2PiC-0007Uy-Cj for qemu-devel@nongnu.org; Thu, 15 Apr 2010 10:06:34 -0400 Received: from mail-yw0-f198.google.com ([209.85.211.198]:33867) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O2PiB-0007Op-KO for qemu-devel@nongnu.org; Thu, 15 Apr 2010 10:06:32 -0400 Received: by mail-yw0-f198.google.com with SMTP id 36so720141ywh.4 for ; Thu, 15 Apr 2010 07:06:31 -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=bkC0/pB/SUPFLq6x3f+Rpa7SFvYck5oaQqTqQXwbITk=; b=sSD0dOsi369f0vBEnPVCgH4hcxx1en664z8cJNz64Ff06iowb7wx6trNrqwVSWgqg3 rDemBb/P46mHLT2j2mvyCfgOLULqAFIK9UCo7yVkjhND4fFUUU1qB/C5mD85NAHjc6fI YpOWJjuL9tXmxOWyQPNGlpy8H/Tkywr8jDkP4= 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=gXJiJ4GgMQjpoPjkj5VBgpGxAJM2Kcj3COateyskoKgWSRbjVbYtW6xykzXHHwhdyc nJlotbu4V347uJPrtocsTO30t+4UD5nd/r8DqDa3bPoGPIPRkv3zkeL0JPi8Cq9KE7mV fvZr4WHPMJySRYKWSsDVpZpRgsNg8b++dNlpg= Received: by 10.100.23.34 with SMTP id 34mr406710anw.50.1271340386970; Thu, 15 Apr 2010 07:06:26 -0700 (PDT) Received: from localhost.localdomain (quake.ic.unicamp.br [143.106.7.51]) by mx.google.com with ESMTPS id y2sm1240378ani.4.2010.04.15.07.06.24 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 15 Apr 2010 07:06:26 -0700 (PDT) From: Miguel Di Ciurcio Filho To: qemu-devel@nongnu.org Date: Thu, 15 Apr 2010 11:06:57 -0300 Message-Id: <1271340427-12579-3-git-send-email-miguel.filho@gmail.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1271340427-12579-1-git-send-email-miguel.filho@gmail.com> References: <1271340427-12579-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 v3 02/12] net: add qemu_nic_format_info_dict and VLANClientState->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 There is no standard format when formatting VLANClientState.info_str, so it is difficult to extract information and transmit it over QMP. This patch adds info_dict, a QDict to better handle the information of a NIC. Patches that convert the devices to use this new function will follow. Signed-off-by: Miguel Di Ciurcio Filho --- net.c | 16 ++++++++++++++++ net.h | 2 ++ 2 files changed, 18 insertions(+), 0 deletions(-) diff --git a/net.c b/net.c index d7d76eb..8c02f28 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; @@ -173,6 +175,19 @@ void qemu_format_nic_info_str(VLANClientState *vc, uint8_t macaddr[6]) macaddr[3], macaddr[4], macaddr[5]); } +void qemu_format_nic_info_dict(VLANClientState *vc, uint8_t macaddr[6]) +{ + vc->info_dict = qdict_new(); + char mac[18]; + + snprintf(mac, sizeof(mac), "%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) { static int index = 0; @@ -301,6 +316,7 @@ void qemu_del_vlan_client(VLANClientState *vc) qemu_free(vc->name); qemu_free(vc->model); + QDECREF(vc->info_dict); qemu_free(vc); } diff --git a/net.h b/net.h index c7a3a1b..d12276a 100644 --- a/net.h +++ b/net.h @@ -66,6 +66,7 @@ struct VLANClientState { char *model; char *name; char info_str[256]; + QDict *info_dict; unsigned receive_disabled : 1; }; @@ -111,6 +112,7 @@ ssize_t qemu_send_packet_async(VLANClientState *vc, const uint8_t *buf, 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);