From owner-freebsd-emulation@FreeBSD.ORG Sun Sep 6 12:51:27 2009 Return-Path: Delivered-To: freebsd-emulation@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E5EE51065672 for ; Sun, 6 Sep 2009 12:51:27 +0000 (UTC) (envelope-from markmc@redhat.com) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx1.freebsd.org (Postfix) with ESMTP id C40F58FC12 for ; Sun, 6 Sep 2009 12:51:27 +0000 (UTC) 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.13.8/8.13.8) with ESMTP id n86CpO84004619; Sun, 6 Sep 2009 08:51:24 -0400 Received: from [IPv6:::1] (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id n86CpM6u025300; Sun, 6 Sep 2009 08:51:23 -0400 From: Mark McLoughlin To: Juergen Lock In-Reply-To: <20090904201347.GA77929@triton8.kn-bremen.de> References: <4AA11B9F.9050101@codemonkey.ws> <20090904201347.GA77929@triton8.kn-bremen.de> Content-Type: text/plain Date: Sun, 06 Sep 2009 13:50:25 +0100 Message-Id: <1252241425.3191.81.camel@blaa> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 Cc: freebsd-emulation@freebsd.org, qemu-devel@nongnu.org, Anthony Liguori Subject: Re: close tapfd before running down_script [was Re: [Qemu-devel] ANNOUNCE: Release 0.11.0-rc2 of QEMU] X-BeenThere: freebsd-emulation@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Mark McLoughlin List-Id: Development of Emulators of other operating systems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 Sep 2009 12:51:28 -0000 On Fri, 2009-09-04 at 22:13 +0200, Juergen Lock wrote: > The second change is a small patch to tap_cleanup that makes it close > the tap fd before calling the ifdown script instead of after, otherwise > FreeBSD's tap driver may hit a KASSERT in case the ifdown script does > something like an `ifconfig tap0 destroy'... > > Index: qemu/net.c > @@ -1643,12 +1643,13 @@ static void tap_cleanup(VLANClientState > > qemu_purge_queued_packets(vc); > > - if (s->down_script[0]) > - launch_script(s->down_script, s->down_script_arg, s->fd); > - > tap_read_poll(s, 0); > tap_write_poll(s, 0); > close(s->fd); > + > + if (s->down_script[0]) > + launch_script(s->down_script, s->down_script_arg, -1); > + > qemu_free(s); > } > > I don't know if there are use cases where the ifdown script needs the > tap fd still open, otherwise I guess this can also be committed upstream. > And in case you want to: :) > > Signed-off-by: Juergen Lock I don't ever use the the down script myself, but a couple of things to bear in mind: a) 0.9.1 never actually closed the tap fd and since 0.10.0 we've been closing the fd after calling the script b) where qemu creates the tap interface, by closing the tap fd before the script we'd be destroying the interface before passing the interface name to the script The current behaviour seems right to me. Could you explain your use case a bit more? Maybe post the up and down scripts? Cheers, Mark.