Message ID | 1270757799-31891-21-git-send-email-miguel.filho@gmail.com |
---|---|
State | New |
Headers | show |
On Thu, 8 Apr 2010 17:16:37 -0300 Miguel Di Ciurcio Filho <miguel.filho@gmail.com> wrote: > Signed-off-by: Miguel Di Ciurcio Filho <miguel.filho@gmail.com> > --- > 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..8e0ad2d 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_to_str(ifname)); qstring_from_str() is better. > + > + 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(); > + > + 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)); > + > 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);
diff --git a/net/tap-win32.c b/net/tap-win32.c index 74348da..8e0ad2d 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_to_str(ifname)); + + 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(); + + 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)); + 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);
Signed-off-by: Miguel Di Ciurcio Filho <miguel.filho@gmail.com> --- net/tap-win32.c | 9 ++++++--- net/tap.c | 18 +++++++++++++----- 2 files changed, 19 insertions(+), 8 deletions(-)