diff mbox

[v2] net: clean up network at qemu process termination

Message ID 1355235615-30831-1-git-send-email-akong@redhat.com
State New
Headers show

Commit Message

Amos Kong Dec. 11, 2012, 2:20 p.m. UTC
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(-)

Comments

Michael S. Tsirkin Dec. 11, 2012, 3:07 p.m. UTC | #1
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
Stefan Hajnoczi Dec. 18, 2012, 1:53 p.m. UTC | #2
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
diff mbox

Patch

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;