[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] Re: [PATCH v3 06/12] net: tap/tap-win32: use info_dict inst
From: |
Luiz Capitulino |
Subject: |
[Qemu-devel] Re: [PATCH v3 06/12] net: tap/tap-win32: use info_dict instead of info_str |
Date: |
Fri, 23 Apr 2010 18:08:52 -0300 |
On Thu, 15 Apr 2010 11:07:01 -0300
Miguel Di Ciurcio Filho <address@hidden> wrote:
> Signed-off-by: Miguel Di Ciurcio Filho <address@hidden>
> ---
> net/tap-win32.c | 9 ++++++---
> net/tap.c | 18 +++++++++++++-----
> 2 files changed, 19 insertions(+), 8 deletions(-)
>
> diff --git a/net/tap-win32.c b/net/tap-win32.c
> index 74348da..a54cd31 100644
> --- a/net/tap-win32.c
> +++ b/net/tap-win32.c
> @@ -32,6 +32,8 @@
> #include "net.h"
> #include "sysemu.h"
> #include "qemu-error.h"
> +#include "qdict.h"
> +#include "qstring.h"
> #include <stdio.h>
> #include <windows.h>
> #include <winioctl.h>
> @@ -688,10 +690,11 @@ static int tap_win32_init(VLANState *vlan, const char
> *model,
>
> nc = qemu_new_net_client(&net_tap_win32_info, vlan, NULL, model, name);
>
> - s = DO_UPCAST(TAPState, nc, nc);
> + nc->info_dict = qdict_new();
>
> - snprintf(s->nc.info_str, sizeof(s->nc.info_str),
> - "tap: ifname=%s", ifname);
> + qdict_put(nc->info_dict, "ifname", qstring_from_str(ifname));
Isn't it better/needed to also do:
qdict_put(nc->info_dict, "tap", qbool_from_int(1));
So that you can reliably recognize this is a tap nic? Another option
is to have model=tap, although I'm not sure if it has any undesirable
implication.
What do you think, Markus?
Note that same applies for slirp,vde etc..
> +
> + s = DO_UPCAST(TAPState, nc, nc);
>
> s->handle = handle;
>
> diff --git a/net/tap.c b/net/tap.c
> index 303d69f..8ba7eed 100644
> --- a/net/tap.c
> +++ b/net/tap.c
> @@ -39,6 +39,9 @@
> #include "qemu-char.h"
> #include "qemu-common.h"
> #include "qemu-error.h"
> +#include "qdict.h"
> +#include "qint.h"
> +#include "qstring.h"
>
> #include "net/tap-linux.h"
>
> @@ -447,18 +450,23 @@ int net_init_tap(QemuOpts *opts, Monitor *mon, const
> char *name, VLANState *vlan
> }
>
> if (qemu_opt_get(opts, "fd")) {
> - snprintf(s->nc.info_str, sizeof(s->nc.info_str), "fd=%d", fd);
> + if (s->nc.info_dict == NULL)
> + s->nc.info_dict = qdict_new();
Style: in QEMU if you to have to use braces.
> +
> + qdict_put(s->nc.info_dict, "fd", qint_from_int(fd));
> } else {
> const char *ifname, *script, *downscript;
> + if (s->nc.info_dict == NULL)
> + s->nc.info_dict = qdict_new();
>
> ifname = qemu_opt_get(opts, "ifname");
> script = qemu_opt_get(opts, "script");
> downscript = qemu_opt_get(opts, "downscript");
>
> - snprintf(s->nc.info_str, sizeof(s->nc.info_str),
> - "ifname=%s,script=%s,downscript=%s",
> - ifname, script, downscript);
> -
> + qdict_put(s->nc.info_dict, "ifname", qstring_from_str(ifname));
> + qdict_put(s->nc.info_dict, "script", qstring_from_str(script));
> + qdict_put(s->nc.info_dict, "downscript",
> qstring_from_str(downscript));
Did you consider using qobject_from_jsonf()?
> +
> if (strcmp(downscript, "no") != 0) {
> snprintf(s->down_script, sizeof(s->down_script), "%s",
> downscript);
> snprintf(s->down_script_arg, sizeof(s->down_script_arg), "%s",
> ifname);
- [Qemu-devel] [PATCH v3 12/12] net: Remove info_str from VLANClientState, not needed anymore, (continued)
- [Qemu-devel] [PATCH v3 12/12] net: Remove info_str from VLANClientState, not needed anymore, Miguel Di Ciurcio Filho, 2010/04/15
- [Qemu-devel] [PATCH v3 11/12] monitor/net: Convert do_info_network() to QObject/QMP, Miguel Di Ciurcio Filho, 2010/04/15
- [Qemu-devel] [PATCH v3 10/12] net: xen: use info_dict instead of info_str, Miguel Di Ciurcio Filho, 2010/04/15
- [Qemu-devel] [PATCH v3 09/12] net: socket: use info_dict instead of info_str, Miguel Di Ciurcio Filho, 2010/04/15
- [Qemu-devel] [PATCH v3 07/12] net: vde: use info_dict instead of info_str, Miguel Di Ciurcio Filho, 2010/04/15
- [Qemu-devel] [PATCH v3 08/12] net: dump: use info_dict instead of info_str, Miguel Di Ciurcio Filho, 2010/04/15
- [Qemu-devel] [PATCH v3 04/12] net: various devices: replace qemu_format_nic_info_str by qemu_format_nic_info_dict, Miguel Di Ciurcio Filho, 2010/04/15
- [Qemu-devel] [PATCH v3 06/12] net: tap/tap-win32: use info_dict instead of info_str, Miguel Di Ciurcio Filho, 2010/04/15
- [Qemu-devel] Re: [PATCH v3 06/12] net: tap/tap-win32: use info_dict instead of info_str,
Luiz Capitulino <=
- [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
- [Qemu-devel] [PATCH v3 05/12] net: slirp: use info_dict instead of info_str, Miguel Di Ciurcio Filho, 2010/04/15
- [Qemu-devel] [PATCH v3 01/12] QObject API: add qdict_to_qstring() function, Miguel Di Ciurcio Filho, 2010/04/15
- [Qemu-devel] [PATCH v3 02/12] net: add qemu_nic_format_info_dict and VLANClientState->info_dict, Miguel Di Ciurcio Filho, 2010/04/15