qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
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 02/22] net: replace qemu_nic_format_info_str and VLANClientState->info_str by QDicts
Date: Fri, 9 Apr 2010 14:41:45 -0300	[thread overview]
Message-ID: <20100409144145.7da076d0@redhat.com> (raw)
In-Reply-To: <1270757799-31891-3-git-send-email-miguel.filho@gmail.com>

On Thu,  8 Apr 2010 17:16:19 -0300
Miguel Di Ciurcio Filho <miguel.filho@gmail.com> wrote:

> 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.

 This will break the build of each individual patch, which will break
git bisect. Each individual patch should build when applied.

 To fix that, you can add the new function and only drop the current one
when the full conversion is done. The temporary duplication is ok.

 More comments below.

> Signed-off-by: Miguel Di Ciurcio Filho <miguel.filho@gmail.com>
> ---
>  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]);

 sizeof(mac) is better.

> +
> +    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;

 Isn't VLANClientState freed somewhere? At least in netdev_del it should.. So,
you have to do a QDECREF(info_dict) there.

>      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);

  reply	other threads:[~2010-04-09 17:53 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-08 20:16 [Qemu-devel] [PATCH 0/22] Convert do_info_network() to QObject/QMP Miguel Di Ciurcio Filho
2010-04-08 20:16 ` [Qemu-devel] [PATCH 01/22] QObject API: add qdict_to_qstring() function Miguel Di Ciurcio Filho
2010-04-09 17:26   ` [Qemu-devel] " Luiz Capitulino
2010-04-08 20:16 ` [Qemu-devel] [PATCH 02/22] net: replace qemu_nic_format_info_str and VLANClientState->info_str by QDicts Miguel Di Ciurcio Filho
2010-04-09 17:41   ` Luiz Capitulino [this message]
2010-04-08 20:16 ` [Qemu-devel] [PATCH 03/22] net: dp8393x: replace qemu_format_nic_info_str by qemu_format_nic_info_dict Miguel Di Ciurcio Filho
2010-04-08 20:16 ` [Qemu-devel] [PATCH 04/22] net: e1000: " Miguel Di Ciurcio Filho
2010-04-08 20:16 ` [Qemu-devel] [PATCH 05/22] net: eepro100: " Miguel Di Ciurcio Filho
2010-04-09 17:42   ` [Qemu-devel] " Luiz Capitulino
2010-04-08 20:16 ` [Qemu-devel] [PATCH 06/22] net: ne2000: " Miguel Di Ciurcio Filho
2010-04-08 20:16 ` [Qemu-devel] [PATCH 07/22] net: pcnet: " Miguel Di Ciurcio Filho
2010-04-08 20:16 ` [Qemu-devel] [PATCH 08/22] net: lan9118: " Miguel Di Ciurcio Filho
2010-04-08 20:16 ` [Qemu-devel] [PATCH 09/22] net: mcf_fec: " Miguel Di Ciurcio Filho
2010-04-08 20:16 ` [Qemu-devel] [PATCH 10/22] net: mipsnet: " Miguel Di Ciurcio Filho
2010-04-08 20:16 ` [Qemu-devel] [PATCH 11/22] net: rtl8139: " Miguel Di Ciurcio Filho
2010-04-08 20:16 ` [Qemu-devel] [PATCH 12/22] net: smc91c111: " Miguel Di Ciurcio Filho
2010-04-08 20:16 ` [Qemu-devel] [PATCH 13/22] net: stellaris_enet: " Miguel Di Ciurcio Filho
2010-04-08 20:16 ` [Qemu-devel] [PATCH 14/22] net: usb-net: " Miguel Di Ciurcio Filho
2010-04-08 20:16 ` [Qemu-devel] [PATCH 15/22] net: virtio-net: " Miguel Di Ciurcio Filho
2010-04-08 20:16 ` [Qemu-devel] [PATCH 16/22] net: xilinx_ethlite: " Miguel Di Ciurcio Filho
2010-04-08 20:16 ` [Qemu-devel] [PATCH 17/22] net: dump: " Miguel Di Ciurcio Filho
2010-04-08 20:16 ` [Qemu-devel] [PATCH 18/22] net: slirp: " Miguel Di Ciurcio Filho
2010-04-09 17:42   ` [Qemu-devel] " Luiz Capitulino
2010-04-08 20:16 ` [Qemu-devel] [PATCH 19/22] net: socket: " Miguel Di Ciurcio Filho
2010-04-09 17:47   ` [Qemu-devel] " Luiz Capitulino
2010-04-08 20:16 ` [Qemu-devel] [PATCH 20/22] net: tap: replace qemu_format_nic_info_str by info_dict Miguel Di Ciurcio Filho
2010-04-09 17:48   ` [Qemu-devel] " Luiz Capitulino
2010-04-08 20:16 ` [Qemu-devel] [PATCH 21/22] net: vde: " Miguel Di Ciurcio Filho
2010-04-08 20:16 ` [Qemu-devel] [PATCH 22/22] monitor/net: Convert do_info_network() to QObject/QMP Miguel Di Ciurcio Filho
2010-04-09 17:52   ` [Qemu-devel] " Luiz Capitulino
2010-04-09 17:25 ` [Qemu-devel] Re: [PATCH 0/22] " 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=20100409144145.7da076d0@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 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).