From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51696) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bNA0P-0000Lb-GR for qemu-devel@nongnu.org; Tue, 12 Jul 2016 22:34:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bNA0M-0002KC-Aj for qemu-devel@nongnu.org; Tue, 12 Jul 2016 22:34:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59502) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bNA0M-0002K4-4j for qemu-devel@nongnu.org; Tue, 12 Jul 2016 22:34:30 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 976A17F341 for ; Wed, 13 Jul 2016 02:34:28 +0000 (UTC) References: <20160711144847.16651-1-marcandre.lureau@redhat.com> <57849FA1.3050705@redhat.com> <71cb921e-afa5-6344-46b0-fdecfcc03a3d@redhat.com> From: Jason Wang Message-ID: <5785A8AE.9050207@redhat.com> Date: Wed, 13 Jul 2016 10:34:22 +0800 MIME-Version: 1.0 In-Reply-To: <71cb921e-afa5-6344-46b0-fdecfcc03a3d@redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH] tap: use an exit notifier to call down_script List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini , marcandre.lureau@redhat.com, qemu-devel@nongnu.org Cc: akong@redhat.com On 2016=E5=B9=B407=E6=9C=8812=E6=97=A5 15:51, Paolo Bonzini wrote: > > On 12/07/2016 09:43, Jason Wang wrote: >> >> On 2016=E5=B9=B407=E6=9C=8811=E6=97=A5 22:48, marcandre.lureau@redhat.= com wrote: >>> From: Marc-Andr=C3=A9 Lureau >>> >>> We would like to move back net_cleanup() at the end of main function, >>> like it used to be until f30dbae63a46f23116715dff8d130c, but minimum >>> tap cleanup is necessary regarless at exit() time. Use an exit notifi= er >>> to call TAP down_script. If net_cleanup() is called first, then remov= e >>> the exit notifier as it will become a dangling pointer otherwise. >>> >>> Signed-off-by: Marc-Andr=C3=A9 Lureau >>> Suggested-by: Paolo Bonzini >> This looks like a tap specific solution. But at least slirp wants to d= o >> some cleanup too. > Right, specifically slirp_smb_cleanup. > >> We need a generic solution. Does it work if we use >> atexit(net_chr_cleanup) and first cleanup net and then chr at that >> function? > I think exit notifiers _are_ a generic solution. Most pieces of QEMU > don't care about cleanup at exit(), because the operating system takes > care of it (freeing memory, closing file descriptors, etc.). > > Tap, slirp and chardev are exceptions, and they can use the exit > notifiers. I'll send a patch for slirp. > > Paolo > Ok. Reviewed-by: Jason Wang