qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] net: clean up network at qemu process termination
@ 2012-12-11 13:45 Amos Kong
  2012-12-11 14:03 ` Michael S. Tsirkin
  2012-12-11 14:20 ` [Qemu-devel] [PATCH v2] " Amos Kong
  0 siblings, 2 replies; 5+ messages in thread
From: Amos Kong @ 2012-12-11 13:45 UTC (permalink / raw)
  To: qemu-devel; +Cc: Amos Kong, stefanha, mst

We don't clean up network if fails to parse "-device" parameters without
calling net_cleanup(). I touch a problem, the tap device which is
created by qemu-ifup script could not be removed by qemu-ifdown script.
Some similar problems also exist in vl.c

In this patch, if network initialization successes, a cleanup function
will be registered to be called at qemu process termination.

Signed-off-by: Amos Kong <akong@redhat.com>
---
 vl.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/vl.c b/vl.c
index a3ab384..842f987 100644
--- a/vl.c
+++ b/vl.c
@@ -3749,6 +3749,9 @@ int main(int argc, char **argv, char **envp)
         exit(1);
     }
 
+    /* clean up network at qemu process termination */
+    atexit(&net_cleanup);
+
     /* init the bluetooth world */
     if (foreach_device_config(DEV_BT, bt_parse))
         exit(1);
@@ -3999,7 +4002,6 @@ int main(int argc, char **argv, char **envp)
     main_loop();
     bdrv_close_all();
     pause_all_vcpus();
-    net_cleanup();
     res_free();
 
     return 0;
-- 
1.7.1

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

* Re: [Qemu-devel] [PATCH] net: clean up network at qemu process termination
  2012-12-11 13:45 [Qemu-devel] [PATCH] net: clean up network at qemu process termination Amos Kong
@ 2012-12-11 14:03 ` Michael S. Tsirkin
  2012-12-11 14:20 ` [Qemu-devel] [PATCH v2] " Amos Kong
  1 sibling, 0 replies; 5+ messages in thread
From: Michael S. Tsirkin @ 2012-12-11 14:03 UTC (permalink / raw)
  To: Amos Kong; +Cc: qemu-devel, stefanha

On Tue, Dec 11, 2012 at 09:45:54PM +0800, Amos Kong wrote:
> We don't clean up network if fails to parse "-device" parameters without
> calling net_cleanup(). I touch a problem, the tap device which is
> created by qemu-ifup script could not be removed by qemu-ifdown script.
> Some similar problems also exist in vl.c
> 
> In this patch, if network initialization successes, a cleanup function
> will be registered to be called at qemu process termination.
> 
> Signed-off-by: Amos Kong <akong@redhat.com>


If there are multiple net clients, this still leaves
the problem where one client is initialized,
the second one fails, and we exit without ifdown.

I think registering before net_init_clients
will fix this case but please do test.

> ---
>  vl.c |    4 +++-
>  1 files changed, 3 insertions(+), 1 deletions(-)
> 
> diff --git a/vl.c b/vl.c
> index a3ab384..842f987 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -3749,6 +3749,9 @@ int main(int argc, char **argv, char **envp)
>          exit(1);
>      }
>  
> +    /* clean up network at qemu process termination */
> +    atexit(&net_cleanup);
> +
>      /* init the bluetooth world */
>      if (foreach_device_config(DEV_BT, bt_parse))
>          exit(1);
> @@ -3999,7 +4002,6 @@ int main(int argc, char **argv, char **envp)
>      main_loop();
>      bdrv_close_all();
>      pause_all_vcpus();
> -    net_cleanup();
>      res_free();
>  
>      return 0;
> -- 
> 1.7.1

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

* [Qemu-devel] [PATCH v2] net: clean up network at qemu process termination
  2012-12-11 13:45 [Qemu-devel] [PATCH] net: clean up network at qemu process termination Amos Kong
  2012-12-11 14:03 ` Michael S. Tsirkin
@ 2012-12-11 14:20 ` Amos Kong
  2012-12-11 15:07   ` Michael S. Tsirkin
  2012-12-18 13:53   ` Stefan Hajnoczi
  1 sibling, 2 replies; 5+ messages in thread
From: Amos Kong @ 2012-12-11 14:20 UTC (permalink / raw)
  To: qemu-devel; +Cc: Amos Kong, stefanha, mst

We don't clean up network if fails to parse "-device" parameters without
calling net_cleanup(). I touch a problem, the tap device which is
created by qemu-ifup script could not be removed by qemu-ifdown script.
Some similar problems also exist in vl.c

In this patch, if network initialization successes, a cleanup function
will be registered to be called at qemu process termination.

Signed-off-by: Amos Kong <akong@redhat.com>
---
v2: register cleanup function before network initialization
---
 vl.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/vl.c b/vl.c
index a3ab384..3bd773e 100644
--- a/vl.c
+++ b/vl.c
@@ -3745,6 +3745,9 @@ int main(int argc, char **argv, char **envp)
     }
     configure_icount(icount_option);
 
+    /* clean up network at qemu process termination */
+    atexit(&net_cleanup);
+
     if (net_init_clients() < 0) {
         exit(1);
     }
@@ -3999,7 +4002,6 @@ int main(int argc, char **argv, char **envp)
     main_loop();
     bdrv_close_all();
     pause_all_vcpus();
-    net_cleanup();
     res_free();
 
     return 0;
-- 
1.7.1

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

* Re: [Qemu-devel] [PATCH v2] net: clean up network at qemu process termination
  2012-12-11 14:20 ` [Qemu-devel] [PATCH v2] " Amos Kong
@ 2012-12-11 15:07   ` Michael S. Tsirkin
  2012-12-18 13:53   ` Stefan Hajnoczi
  1 sibling, 0 replies; 5+ messages in thread
From: Michael S. Tsirkin @ 2012-12-11 15:07 UTC (permalink / raw)
  To: Amos Kong; +Cc: qemu-devel, stefanha

On Tue, Dec 11, 2012 at 10:20:15PM +0800, Amos Kong wrote:
> We don't clean up network if fails to parse "-device" parameters without
> calling net_cleanup(). I touch a problem, the tap device which is
> created by qemu-ifup script could not be removed by qemu-ifdown script.
> Some similar problems also exist in vl.c
> 
> In this patch, if network initialization successes, a cleanup function
> will be registered to be called at qemu process termination.
> 
> Signed-off-by: Amos Kong <akong@redhat.com>

Acked-by: Michael S. Tsirkin <mst@redhat.com>

> ---
> v2: register cleanup function before network initialization
> ---
>  vl.c |    4 +++-
>  1 files changed, 3 insertions(+), 1 deletions(-)
> 
> diff --git a/vl.c b/vl.c
> index a3ab384..3bd773e 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -3745,6 +3745,9 @@ int main(int argc, char **argv, char **envp)
>      }
>      configure_icount(icount_option);
>  
> +    /* clean up network at qemu process termination */
> +    atexit(&net_cleanup);
> +
>      if (net_init_clients() < 0) {
>          exit(1);
>      }
> @@ -3999,7 +4002,6 @@ int main(int argc, char **argv, char **envp)
>      main_loop();
>      bdrv_close_all();
>      pause_all_vcpus();
> -    net_cleanup();
>      res_free();
>  
>      return 0;
> -- 
> 1.7.1

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

* Re: [Qemu-devel] [PATCH v2] net: clean up network at qemu process termination
  2012-12-11 14:20 ` [Qemu-devel] [PATCH v2] " Amos Kong
  2012-12-11 15:07   ` Michael S. Tsirkin
@ 2012-12-18 13:53   ` Stefan Hajnoczi
  1 sibling, 0 replies; 5+ messages in thread
From: Stefan Hajnoczi @ 2012-12-18 13:53 UTC (permalink / raw)
  To: Amos Kong; +Cc: qemu-devel, mst

On Tue, Dec 11, 2012 at 10:20:15PM +0800, Amos Kong wrote:
> We don't clean up network if fails to parse "-device" parameters without
> calling net_cleanup(). I touch a problem, the tap device which is
> created by qemu-ifup script could not be removed by qemu-ifdown script.
> Some similar problems also exist in vl.c
> 
> In this patch, if network initialization successes, a cleanup function
> will be registered to be called at qemu process termination.
> 
> Signed-off-by: Amos Kong <akong@redhat.com>
> ---
> v2: register cleanup function before network initialization
> ---
>  vl.c |    4 +++-
>  1 files changed, 3 insertions(+), 1 deletions(-)

Thanks, applied to the net tree:
https://github.com/stefanha/qemu/commits/net

Stefan

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

end of thread, other threads:[~2012-12-18 13:54 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-11 13:45 [Qemu-devel] [PATCH] net: clean up network at qemu process termination Amos Kong
2012-12-11 14:03 ` Michael S. Tsirkin
2012-12-11 14:20 ` [Qemu-devel] [PATCH v2] " Amos Kong
2012-12-11 15:07   ` Michael S. Tsirkin
2012-12-18 13:53   ` Stefan Hajnoczi

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