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 v3 02/12] net: add qemu_nic_format_info_dict and VLANClientState->info_dict
Date: Fri, 23 Apr 2010 18:05:19 -0300 [thread overview]
Message-ID: <20100423180519.25b5ab34@redhat.com> (raw)
In-Reply-To: <1271340427-12579-3-git-send-email-miguel.filho@gmail.com>
On Thu, 15 Apr 2010 11:06:57 -0300
Miguel Di Ciurcio Filho <miguel.filho@gmail.com> wrote:
> 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 <miguel.filho@gmail.com>
> ---
> 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];
Better style:
char mac[18];
vc->info_dict = qdict_new();
Also, I'd do:
assert(vc->info_dict == NULL);
Before assigning it a new dict, just to be sure that it's not called twice for
the same 'vc' (which would leak memory).
> +
> + 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);
next prev parent reply other threads:[~2010-04-23 21:05 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-15 14:06 [Qemu-devel] [PATCH v3 00/12] Convert do_info_network() to QObject/QMP Miguel Di Ciurcio Filho
2010-04-15 14:06 ` [Qemu-devel] [PATCH v3 01/12] QObject API: add qdict_to_qstring() function Miguel Di Ciurcio Filho
2010-04-23 21:04 ` [Qemu-devel] " Luiz Capitulino
2010-04-15 14:06 ` [Qemu-devel] [PATCH v3 02/12] net: add qemu_nic_format_info_dict and VLANClientState->info_dict Miguel Di Ciurcio Filho
2010-04-23 21:05 ` Luiz Capitulino [this message]
2010-04-15 14:06 ` [Qemu-devel] [PATCH v3 03/12] net: eepro100: replace qemu_format_nic_info_str by qemu_format_nic_info_dict Miguel Di Ciurcio Filho
2010-04-15 15:32 ` Richard Henderson
2010-04-15 14:06 ` [Qemu-devel] [PATCH v3 04/12] net: various devices: " Miguel Di Ciurcio Filho
2010-04-15 14:07 ` [Qemu-devel] [PATCH v3 05/12] net: slirp: use info_dict instead of info_str Miguel Di Ciurcio Filho
2010-04-23 21:06 ` [Qemu-devel] " Luiz Capitulino
2010-04-15 14:07 ` [Qemu-devel] [PATCH v3 06/12] net: tap/tap-win32: " Miguel Di Ciurcio Filho
2010-04-23 21:08 ` [Qemu-devel] " Luiz Capitulino
2010-04-15 14:07 ` [Qemu-devel] [PATCH v3 07/12] net: vde: " Miguel Di Ciurcio Filho
2010-04-15 14:07 ` [Qemu-devel] [PATCH v3 08/12] net: dump: " Miguel Di Ciurcio Filho
2010-04-15 14:07 ` [Qemu-devel] [PATCH v3 09/12] net: socket: " Miguel Di Ciurcio Filho
2010-04-23 21:10 ` [Qemu-devel] " Luiz Capitulino
2010-04-15 14:07 ` [Qemu-devel] [PATCH v3 10/12] net: xen: " Miguel Di Ciurcio Filho
2010-04-15 14:07 ` [Qemu-devel] [PATCH v3 11/12] monitor/net: Convert do_info_network() to QObject/QMP Miguel Di Ciurcio Filho
2010-04-23 21:13 ` [Qemu-devel] " Luiz Capitulino
2010-04-15 14:07 ` [Qemu-devel] [PATCH v3 12/12] net: Remove info_str from VLANClientState, not needed anymore Miguel Di Ciurcio Filho
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=20100423180519.25b5ab34@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.