From: Miguel Di Ciurcio Filho <miguel.filho@gmail.com>
To: qemu-devel@nongnu.org
Cc: armbru@redhat.com, lcapitulino@redhat.com
Subject: [Qemu-devel] [PATCH v4 02/10] net: introduce qemu_nic_format_info_dict and VLANClientState->info_dict
Date: Tue, 18 May 2010 14:07:41 -0300 [thread overview]
Message-ID: <1274202469-9332-3-git-send-email-miguel.filho@gmail.com> (raw)
In-Reply-To: <1274202469-9332-1-git-send-email-miguel.filho@gmail.com>
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.
Signed-off-by: Miguel Di Ciurcio Filho <miguel.filho@gmail.com>
---
net.c | 17 +++++++++++++++++
net.h | 2 ++
2 files changed, 19 insertions(+), 0 deletions(-)
diff --git a/net.c b/net.c
index efa8b3d..9e8a8ab 100644
--- a/net.c
+++ b/net.c
@@ -173,6 +173,22 @@ 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])
+{
+ char mac[18];
+
+ if (vc->info_dict == NULL) {
+ vc->info_dict = qdict_new();
+ }
+
+ 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 +317,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 b83f615..4566f7d 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);
--
1.7.1
next prev parent reply other threads:[~2010-05-18 17:19 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-18 17:07 [Qemu-devel] [PATCH v4 0/10] Introduce 'info netdevices' with QMP support Miguel Di Ciurcio Filho
2010-05-18 17:07 ` [Qemu-devel] [PATCH v4 01/10] QObject API: introduce qdict_to_qstring() function Miguel Di Ciurcio Filho
2010-05-27 17:50 ` [Qemu-devel] " Luiz Capitulino
2010-05-18 17:07 ` Miguel Di Ciurcio Filho [this message]
2010-05-18 17:07 ` [Qemu-devel] [PATCH v4 03/10] net: various devices: add qemu_format_nic_info_dict Miguel Di Ciurcio Filho
2010-05-18 17:07 ` [Qemu-devel] [PATCH v4 04/10] net: xen: introduce info_dict Miguel Di Ciurcio Filho
2010-05-18 17:07 ` [Qemu-devel] [PATCH v4 05/10] net: tap/tap-win32: " Miguel Di Ciurcio Filho
2010-05-27 17:50 ` [Qemu-devel] " Luiz Capitulino
2010-05-18 17:07 ` [Qemu-devel] [PATCH v4 06/10] net: vde: " Miguel Di Ciurcio Filho
2010-05-27 17:51 ` [Qemu-devel] " Luiz Capitulino
2010-05-18 17:07 ` [Qemu-devel] [PATCH v4 07/10] net: dump: " Miguel Di Ciurcio Filho
2010-05-18 17:07 ` [Qemu-devel] [PATCH v4 08/10] net: slirp: " Miguel Di Ciurcio Filho
2010-05-18 17:07 ` [Qemu-devel] [PATCH v4 09/10] net: socket: " Miguel Di Ciurcio Filho
2010-05-18 17:07 ` [Qemu-devel] [PATCH v4 10/10] monitor/net: introduce 'info netdevices' with QMP support Miguel Di Ciurcio Filho
2010-05-27 17:50 ` [Qemu-devel] Re: [PATCH v4 0/10] Introduce " 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=1274202469-9332-3-git-send-email-miguel.filho@gmail.com \
--to=miguel.filho@gmail.com \
--cc=armbru@redhat.com \
--cc=lcapitulino@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).