From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:46727) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TsWgq-0008Ir-EW for qemu-devel@nongnu.org; Tue, 08 Jan 2013 05:45:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TsWgm-0006bx-AE for qemu-devel@nongnu.org; Tue, 08 Jan 2013 05:45:52 -0500 Received: from mx1.redhat.com ([209.132.183.28]:17045) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TsWgl-0006bh-Ka for qemu-devel@nongnu.org; Tue, 08 Jan 2013 05:45:48 -0500 From: Stefan Hajnoczi Date: Tue, 8 Jan 2013 11:45:37 +0100 Message-Id: <1357641939-20030-3-git-send-email-stefanha@redhat.com> In-Reply-To: <1357641939-20030-1-git-send-email-stefanha@redhat.com> References: <1357641939-20030-1-git-send-email-stefanha@redhat.com> Subject: [Qemu-devel] [PATCH 2/4] net: clean up network at qemu process termination List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Anthony Liguori , Amos Kong , Stefan Hajnoczi From: Amos Kong 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 Acked-by: Michael S. Tsirkin Signed-off-by: Stefan Hajnoczi --- vl.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/vl.c b/vl.c index f056c95..79e5122 100644 --- 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; -- 1.8.0.2