From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51792) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y1xNY-00079w-PY for qemu-devel@nongnu.org; Fri, 19 Dec 2014 08:14:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y1xNS-0006Bm-PR for qemu-devel@nongnu.org; Fri, 19 Dec 2014 08:14:00 -0500 Received: from mail-wi0-x231.google.com ([2a00:1450:400c:c05::231]:46469) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y1xNS-0006As-Ey for qemu-devel@nongnu.org; Fri, 19 Dec 2014 08:13:54 -0500 Received: by mail-wi0-f177.google.com with SMTP id l15so1709573wiw.16 for ; Fri, 19 Dec 2014 05:13:53 -0800 (PST) Date: Fri, 19 Dec 2014 13:13:50 +0000 From: Stefan Hajnoczi Message-ID: <20141219131350.GA23953@stefanha-thinkpad.redhat.com> References: <1418645123-32256-1-git-send-email-royv@ezchip.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="OXfL5xGRrasGEqWY" Content-Disposition: inline In-Reply-To: <1418645123-32256-1-git-send-email-royv@ezchip.com> Subject: Re: [Qemu-devel] [PATCH] net: Add persistent flag to -net tap option List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Roy Vardi Cc: lcapitulino@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org, aliguori@amazon.com, armbru@redhat.com --OXfL5xGRrasGEqWY Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Dec 15, 2014 at 02:05:23PM +0200, Roy Vardi wrote: > From: Roy Vardi >=20 > Add 'persistent' boolean flag to -net tap option. > When set to off - tap interface will be released on shutdown > When set to on\not specified - tap interface will remain >=20 > Running with -net tap,persistent=3Doff will force the tap interface > down when qemu goes down, thus ensuring that there're no zombie tap > interfaces left >=20 > This is achieved using another ioctl >=20 > Note: This commit includes the above support only for linux systems I don't understand the point of this patch. The following doesn't persist the tun interface: qemu-system-i386 -net tap,script=3Dmyscript.sh,downscript=3Dno -net nic You are changing the default to persist the interface, won't this cause problems for existing users who don't expect persistent interfaces? > @@ -109,6 +110,17 @@ int tap_open(char *ifname, int ifname_size, int *vne= t_hdr, > close(fd); > return -1; > } > + > + if (!persistent_required) { > + ret =3D ioctl(fd, TUNSETPERSIST, 0); > + if (ret !=3D 0) { Indentation is off here. QEMU uses 4-space indentation and this if statement should not be indented. > + error_report("could not configure non-persistent %s (%s)= : %m", > + PATH_NET_TUN, ifr.ifr_name); > + close(fd); > + return -1; > + } > + } > + > pstrcpy(ifname, ifname_size, ifr.ifr_name); > fcntl(fd, F_SETFL, O_NONBLOCK); > return fd; > diff --git a/net/tap.c b/net/tap.c > index bde6b58..43267bb 100644 > --- a/net/tap.c > +++ b/net/tap.c > @@ -556,7 +556,8 @@ int net_init_bridge(const NetClientOptions *opts, con= st char *name, > =20 > static int net_tap_init(const NetdevTapOptions *tap, int *vnet_hdr, > const char *setup_script, char *ifname, > - size_t ifname_sz, int mq_required) > + size_t ifname_sz, int mq_required, > + int persistent_reuired) Typo s/reuired/required/ > diff --git a/qemu-options.hx b/qemu-options.hx > index 10b9568..d26215a 100644 > --- a/qemu-options.hx > +++ b/qemu-options.hx > @@ -1417,7 +1417,7 @@ DEF("net", HAS_ARG, QEMU_OPTION_net, > "-net tap[,vlan=3Dn][,name=3Dstr],ifname=3Dname\n" > " connect the host TAP network interface to VLAN 'n'\= n" > #else > - "-net tap[,vlan=3Dn][,name=3Dstr][,fd=3Dh][,fds=3Dx:y:...:z][,ifname= =3Dname][,script=3Dfile][,downscript=3Ddfile][,helper=3Dhelper][,sndbuf=3Dn= bytes][,vnet_hdr=3Don|off][,vhost=3Don|off][,vhostfd=3Dh][,vhostfds=3Dx:y:.= =2E.:z][,vhostforce=3Don|off][,queues=3Dn]\n" > + "-net tap[,vlan=3Dn][,name=3Dstr][,fd=3Dh][,fds=3Dx:y:...:z][,ifname= =3Dname][,script=3Dfile][,downscript=3Ddfile][,helper=3Dhelper][,sndbuf=3Dn= bytes][,vnet_hdr=3Don|off][,vhost=3Don|off][,vhostfd=3Dh][,vhostfds=3Dx:y:.= =2E.:z][,vhostforce=3Don|off][,queues=3Dn][persistent=3Don|off]\n" Missing comma: [,persistent=3Don|off] > " connect the host TAP network interface to VLAN 'n'\= n" > " use network scripts 'file' (default=3D" DEFAULT_NET= WORK_SCRIPT ")\n" > " to configure it and 'dfile' (default=3D" DEFAULT_NE= TWORK_DOWN_SCRIPT ")\n" > @@ -1437,6 +1437,7 @@ DEF("net", HAS_ARG, QEMU_OPTION_net, > " use 'vhostfd=3Dh' to connect to an already opened v= host net device\n" > " use 'vhostfds=3Dx:y:...:z to connect to multiple al= ready opened vhost net devices\n" > " use 'queues=3Dn' to specify the number of queues to= be created for multiqueue TAP\n" > + " use persistent=3Doff to release the TAP interface o= n shutdown (default=3Don)\n" Please use the same formatting as for the other options: use 'persistent=3Doff' to release ... --OXfL5xGRrasGEqWY Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAEBAgAGBQJUlCSOAAoJEJykq7OBq3PIhQUH/0zetZDIft/jmTT+X0atNrfv suJIKeDTbzf9q962Ozp8KDDFppxDy/08ZCxljvbDAL3Qs+Qc9zTbTro6J/NS5iAZ obz72iGJ79G9hyf50emdl/5fUrQvC2chY6uMu7v7LWFDBzyUgodcgO0BY/ZG94BY 58jkrdVHY5bEK9Fg7XLTyatp2MmwfItUE2zcVCsnPizubPH2LMVPRz68EJqRNpTY qGmyj4WItDCCi/q7HpkSWZdc873+ch+Z+UWRvP5CrxJmSgg1m9C+uta/eB9HVkY7 PYxFOFqGaT4Z9Ol1A/zMevlbNqjSwCX9cAv5Tl8dpDorU+Ut9rb6y0bDJXdIyPA= =Uhsf -----END PGP SIGNATURE----- --OXfL5xGRrasGEqWY--