From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:34429) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TiQOz-0005PQ-0x for qemu-devel@nongnu.org; Tue, 11 Dec 2012 09:01:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TiQOr-0008SC-HQ for qemu-devel@nongnu.org; Tue, 11 Dec 2012 09:01:40 -0500 Received: from mx1.redhat.com ([209.132.183.28]:56069) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TiQOr-0008S5-A3 for qemu-devel@nongnu.org; Tue, 11 Dec 2012 09:01:33 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id qBBE1PVZ015892 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 11 Dec 2012 09:01:32 -0500 Date: Tue, 11 Dec 2012 16:03:53 +0200 From: "Michael S. Tsirkin" Message-ID: <20121211140353.GB18083@redhat.com> References: <1355233554-28130-1-git-send-email-akong@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1355233554-28130-1-git-send-email-akong@redhat.com> Subject: Re: [Qemu-devel] [PATCH] net: clean up network at qemu process termination List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Amos Kong Cc: qemu-devel@nongnu.org, stefanha@redhat.com On Tue, Dec 11, 2012 at 09:45:54PM +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 If there are multiple net clients, this still leaves the problem where one client is initialized, the second one fails, and we exit without ifdown. I think registering before net_init_clients will fix this case but please do test. > --- > 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; > -- > 1.7.1