From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:57196) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TiIqK-000753-FC for qemu-devel@nongnu.org; Tue, 11 Dec 2012 00:57:25 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TiIqJ-0007uB-K1 for qemu-devel@nongnu.org; Tue, 11 Dec 2012 00:57:24 -0500 Received: from mx1.redhat.com ([209.132.183.28]:57537) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TiIqJ-0007tZ-Bv for qemu-devel@nongnu.org; Tue, 11 Dec 2012 00:57:23 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id qBB5vMnA032565 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 11 Dec 2012 00:57:22 -0500 Date: Tue, 11 Dec 2012 13:57:04 +0800 From: Amos Kong Message-ID: <20121211055704.GA5080@t430s.nay.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Subject: [Qemu-devel] Network isn't clean when qemu exits List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Qemu Devel Mail List , Stefan Hajnoczi Cc: mst@redhat.com In vl.c:main(), tap device would be created when net_init_clients() is called. "device" option is parsed after calling net_init_clients() by: # "qemu_opts_foreach(qemu_find_opts("device"), device_init_func, NULL, 1) Qemu will exit 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. I did a quick fix, the tap device should be removed. But there are many "exit(1)" after calling net_init_clients() in vl.c, it's ugly to call net_cleanup() before each exit. Not sure if we have other exit(1) in other sub-functions, which is also called after calling net_init_clients(). Any comments? ===== @@ -3882,8 +3889,11 @@ int main(int argc, char **argv, char **envp) } /* init generic devices */ - if (qemu_opts_foreach(qemu_find_opts("device"), device_init_func, NULL, 1) != 0) + if (qemu_opts_foreach(qemu_find_opts("device"), device_init_func, + NULL, 1) != 0) { + net_cleanup(); exit(1); + } -- Amos.