]> git.proxmox.com Git - qemu.git/commitdiff
net: clean up network at qemu process termination
authorAmos Kong <akong@redhat.com>
Tue, 11 Dec 2012 14:20:15 +0000 (22:20 +0800)
committerStefan Hajnoczi <stefanha@redhat.com>
Mon, 7 Jan 2013 09:43:21 +0000 (10:43 +0100)
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>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
vl.c

diff --git a/vl.c b/vl.c
index f056c95807917fb0087be61abc29d51464f164fc..79e51223931131066250e5b1d18958289c8058ce 100644 (file)
--- a/vl.c
+++ b/vl.c
@@ -3762,6 +3762,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);
     }
@@ -4014,7 +4017,6 @@ int main(int argc, char **argv, char **envp)
     main_loop();
     bdrv_close_all();
     pause_all_vcpus();
-    net_cleanup();
     res_free();
 
     return 0;