From patchwork Tue Dec 11 13:45:54 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amos Kong X-Patchwork-Id: 205223 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 37B542C0089 for ; Wed, 12 Dec 2012 00:43:48 +1100 (EST) Received: from localhost ([::1]:54777 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TiQ7e-00055N-DW for incoming@patchwork.ozlabs.org; Tue, 11 Dec 2012 08:43:46 -0500 Received: from eggs.gnu.org ([208.118.235.92]:59828) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TiQ7Q-0004xC-Bk for qemu-devel@nongnu.org; Tue, 11 Dec 2012 08:43:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TiQ7K-0003Bg-Im for qemu-devel@nongnu.org; Tue, 11 Dec 2012 08:43:32 -0500 Received: from mx1.redhat.com ([209.132.183.28]:44195) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TiQ7K-0003Bb-Av for qemu-devel@nongnu.org; Tue, 11 Dec 2012 08:43:26 -0500 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id qBBDhPbm008948 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 11 Dec 2012 08:43:25 -0500 Received: from dhcp-8-167.nay.redhat.com ([10.66.7.126]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id qBBDhNLU032561; Tue, 11 Dec 2012 08:43:24 -0500 From: Amos Kong To: qemu-devel@nongnu.org Date: Tue, 11 Dec 2012 21:45:54 +0800 Message-Id: <1355233554-28130-1-git-send-email-akong@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Amos Kong , stefanha@redhat.com, mst@redhat.com Subject: [Qemu-devel] [PATCH] net: clean up network at qemu process termination X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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;