From patchwork Tue Dec 11 13:45:54 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: net: clean up network at qemu process termination Date: Tue, 11 Dec 2012 03:45:54 -0000 From: Amos Kong X-Patchwork-Id: 205223 Message-Id: <1355233554-28130-1-git-send-email-akong@redhat.com> To: qemu-devel@nongnu.org Cc: Amos Kong , stefanha@redhat.com, mst@redhat.com 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 --- 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;