All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] Fix tap downscript argument
@ 2009-01-13 18:54 Mark McLoughlin
  2009-01-13 19:16 ` [Qemu-devel] " Anthony Liguori
  2009-01-14 12:49 ` John Wong
  0 siblings, 2 replies; 3+ messages in thread
From: Mark McLoughlin @ 2009-01-13 18:54 UTC (permalink / raw)
  To: Anthony Liguori; +Cc: John Wong, qemu-devel

Kill off the hack that parses info_str for the tap interface
name to pass as the argument to the downscript and, instead,
just explicitly keep a copy of the string for later.

As reported by John Wong, this commit:

  Add qemu_format_nic_info_str()

changed the invocation of downscript from e.g.

  /path/kvm-ifdown "tap0"

to:

  /path/kvm-ifdown "tap0,script=/path/kvm-ifup,downscript=/path/kvm-ifdown"

This fix restores the original behavior.

Reported-by: John Wong <johnw@wonghome.net>
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
---
 net.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/net.c b/net.c
index 30ba717..e6639ec 100644
--- a/net.c
+++ b/net.c
@@ -652,6 +652,7 @@ typedef struct TAPState {
     VLANClientState *vc;
     int fd;
     char down_script[1024];
+    char down_script_arg[128];
 } TAPState;
 
 #ifdef HAVE_IOVEC
@@ -978,8 +979,10 @@ static int net_tap_init(VLANState *vlan, const char *model,
     snprintf(s->vc->info_str, sizeof(s->vc->info_str),
              "ifname=%s,script=%s,downscript=%s",
              ifname, setup_script, down_script);
-    if (down_script && strcmp(down_script, "no"))
+    if (down_script && strcmp(down_script, "no")) {
         snprintf(s->down_script, sizeof(s->down_script), "%s", down_script);
+        snprintf(s->down_script_arg, sizeof(s->down_script_arg), "%s", ifname);
+    }
     return 0;
 }
 
@@ -1736,13 +1739,10 @@ void net_cleanup(void)
 
         for(vc = vlan->first_client; vc != NULL; vc = vc->next) {
             if (vc->fd_read == tap_receive) {
-                char ifname[64];
                 TAPState *s = vc->opaque;
 
-                if (strcmp(vc->model, "tap") == 0 &&
-                    sscanf(vc->info_str, "ifname=%63s ", ifname) == 1 &&
-                    s->down_script[0])
-                    launch_script(s->down_script, ifname, s->fd);
+                if (s->down_script[0])
+                    launch_script(s->down_script, s->down_script_arg, s->fd);
             }
 #if defined(CONFIG_VDE)
             if (vc->fd_read == vde_from_qemu) {
-- 
1.6.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [Qemu-devel] Re: [PATCH] Fix tap downscript argument
  2009-01-13 18:54 [Qemu-devel] [PATCH] Fix tap downscript argument Mark McLoughlin
@ 2009-01-13 19:16 ` Anthony Liguori
  2009-01-14 12:49 ` John Wong
  1 sibling, 0 replies; 3+ messages in thread
From: Anthony Liguori @ 2009-01-13 19:16 UTC (permalink / raw)
  To: Mark McLoughlin; +Cc: John Wong, qemu-devel

Mark McLoughlin wrote:
> Kill off the hack that parses info_str for the tap interface
> name to pass as the argument to the downscript and, instead,
> just explicitly keep a copy of the string for later.
>
> As reported by John Wong, this commit:
>
>   Add qemu_format_nic_info_str()
>
> changed the invocation of downscript from e.g.
>
>   /path/kvm-ifdown "tap0"
>
> to:
>
>   /path/kvm-ifdown "tap0,script=/path/kvm-ifup,downscript=/path/kvm-ifdown"
>
> This fix restores the original behavior.
>
> Reported-by: John Wong <johnw@wonghome.net>
> Signed-off-by: Mark McLoughlin <markmc@redhat.com>

Applied.  Thanks.

Regards,

Anthony Liguori

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Qemu-devel] Re: [PATCH] Fix tap downscript argument
  2009-01-13 18:54 [Qemu-devel] [PATCH] Fix tap downscript argument Mark McLoughlin
  2009-01-13 19:16 ` [Qemu-devel] " Anthony Liguori
@ 2009-01-14 12:49 ` John Wong
  1 sibling, 0 replies; 3+ messages in thread
From: John Wong @ 2009-01-14 12:49 UTC (permalink / raw)
  To: Mark McLoughlin; +Cc: qemu-devel

Hi Mark, the patch fixed the downscript problem.
Thank you.

On 2009年01月14日 02:54, Mark McLoughlin wrote:
> Kill off the hack that parses info_str for the tap interface
> name to pass as the argument to the downscript and, instead,
> just explicitly keep a copy of the string for later.
>
> As reported by John Wong, this commit:
>
>   Add qemu_format_nic_info_str()
>
> changed the invocation of downscript from e.g.
>
>   /path/kvm-ifdown "tap0"
>
> to:
>
>   /path/kvm-ifdown "tap0,script=/path/kvm-ifup,downscript=/path/kvm-ifdown"
>
> This fix restores the original behavior.
>
> Reported-by: John Wong <johnw@wonghome.net>
> Signed-off-by: Mark McLoughlin <markmc@redhat.com>
> ---
>  net.c |   12 ++++++------
>  1 files changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/net.c b/net.c
> index 30ba717..e6639ec 100644
> --- a/net.c
> +++ b/net.c
> @@ -652,6 +652,7 @@ typedef struct TAPState {
>      VLANClientState *vc;
>      int fd;
>      char down_script[1024];
> +    char down_script_arg[128];
>  } TAPState;
>  
>  #ifdef HAVE_IOVEC
> @@ -978,8 +979,10 @@ static int net_tap_init(VLANState *vlan, const char *model,
>      snprintf(s->vc->info_str, sizeof(s->vc->info_str),
>               "ifname=%s,script=%s,downscript=%s",
>               ifname, setup_script, down_script);
> -    if (down_script && strcmp(down_script, "no"))
> +    if (down_script && strcmp(down_script, "no")) {
>          snprintf(s->down_script, sizeof(s->down_script), "%s", down_script);
> +        snprintf(s->down_script_arg, sizeof(s->down_script_arg), "%s", ifname);
> +    }
>      return 0;
>  }
>  
> @@ -1736,13 +1739,10 @@ void net_cleanup(void)
>  
>          for(vc = vlan->first_client; vc != NULL; vc = vc->next) {
>              if (vc->fd_read == tap_receive) {
> -                char ifname[64];
>                  TAPState *s = vc->opaque;
>  
> -                if (strcmp(vc->model, "tap") == 0 &&
> -                    sscanf(vc->info_str, "ifname=%63s ", ifname) == 1 &&
> -                    s->down_script[0])
> -                    launch_script(s->down_script, ifname, s->fd);
> +                if (s->down_script[0])
> +                    launch_script(s->down_script, s->down_script_arg, s->fd);
>              }
>  #if defined(CONFIG_VDE)
>              if (vc->fd_read == vde_from_qemu) {
>   

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-01-14 12:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-01-13 18:54 [Qemu-devel] [PATCH] Fix tap downscript argument Mark McLoughlin
2009-01-13 19:16 ` [Qemu-devel] " Anthony Liguori
2009-01-14 12:49 ` John Wong

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.