From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:32914) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YEJdk-00032G-PZ for qemu-devel@nongnu.org; Thu, 22 Jan 2015 10:25:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YEJdj-0002Lt-0h for qemu-devel@nongnu.org; Thu, 22 Jan 2015 10:25:48 -0500 Received: from mx1.redhat.com ([209.132.183.28]:55948) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YEJdi-0002Ll-Q4 for qemu-devel@nongnu.org; Thu, 22 Jan 2015 10:25:46 -0500 Message-ID: <54C11672.8080001@redhat.com> Date: Thu, 22 Jan 2015 08:25:38 -0700 From: Eric Blake MIME-Version: 1.0 References: <1419148106-21502-1-git-send-email-royv@ezchip.com> In-Reply-To: <1419148106-21502-1-git-send-email-royv@ezchip.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="WngGGmi3jEht2nH7t5pvJeHWO9EbakA5a" 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 , qemu-devel@nongnu.org Cc: armbru@redhat.com, noamc@ezchip.com, stefanha@redhat.com, aliguori@amazon.com, lcapitulino@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --WngGGmi3jEht2nH7t5pvJeHWO9EbakA5a Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 12/21/2014 12:48 AM, 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= s/there're/there are/ > interfaces left >=20 > This is achieved using another ioctl >=20 > Note: This commit includes the above support only for linux systems= >=20 > Signed-off-by: Roy Vardi > --- > #define PATH_NET_TUN "/dev/net/tun" > =20 > int tap_open(char *ifname, int ifname_size, int *vnet_hdr, > - int vnet_hdr_required, int mq_required) > + int vnet_hdr_required, int mq_required, int persistent_re= quired) Used as a boolean, so s/int/bool/ > { > struct ifreq ifr; > int fd, ret; > @@ -109,6 +110,17 @@ int tap_open(char *ifname, int ifname_size, int *v= net_hdr, > close(fd); > return -1; > } > + > + if (!persistent_required) { > + ret =3D ioctl(fd, TUNSETPERSIST, 0); > + if (ret !=3D 0) { > + error_report("could not configure non-persistent %s (%s): = %m", %m is not portable to non-glibc (then again, this file is Linux-only). > +++ b/net/tap.c > @@ -556,7 +556,8 @@ int net_init_bridge(const NetClientOptions *opts, c= onst 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_required) Again, prefer bool. > @@ -688,7 +689,7 @@ int net_init_tap(const NetClientOptions *opts, cons= t char *name, > NetClientState *peer) > { > const NetdevTapOptions *tap; > - int fd, vnet_hdr =3D 0, i =3D 0, queues; > + int fd, vnet_hdr =3D 0, i =3D 0, queues, persistent; Use bool. > /* for the no-fd, no-helper case */ > const char *script =3D NULL; /* suppress wrong "uninit'd use" gcc = warning */ > const char *downscript =3D NULL; > @@ -699,6 +700,7 @@ int net_init_tap(const NetClientOptions *opts, cons= t char *name, > tap =3D opts->tap; > queues =3D tap->has_queues ? tap->queues : 1; > vhostfdname =3D tap->has_vhostfd ? tap->vhostfd : NULL; > + persistent =3D tap->has_persistent ? tap->persistent : 1; s/1/true/ > +++ b/qapi-schema.json > @@ -2007,6 +2007,8 @@ > # > # @queues: #optional number of queues to be created for multiqueue cap= able tap > # > +# @persistent: #optional for opening tap in persistent mode (default: = on) (Since: 2.3) Long line; please wrap at 80 columns. In QMP, the default is 'true', not 'on' (the command line parser maps multiple strings including 'on' into the single QMP bool type). --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --WngGGmi3jEht2nH7t5pvJeHWO9EbakA5a Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJUwRZyAAoJEKeha0olJ0Nq8esH/25Z117a9CUVMray99GlWZqL USa/aNtLTgznjEiechtrrV9jf1YuTalu0Yy28aiCJtt9XMqF18UivXFszugKuA8r hRz592oiXaUK06iJ5iYrVio3LjYSW2mm0SDhINCKjjQQyFm12Rjaiax63X53ZJ9z PfmDuegEFsJN6h+I/wh4E4yKFCv9ml9CBqFOiwQxm1aoVkdxqlLL5xHFBS+W/wNR FKoBqdzViWq8tebRrBz+zoBTEAp3fOBkCfIcGl7MIoIVXQwlh35l+gTSZvdCnNmR 0gH3kJnVApB6qBukZcvpj77Q9wD+ZR0i9dnFIsarLLdW7uchgbnwNdvudDuBGYY= =RnNp -----END PGP SIGNATURE----- --WngGGmi3jEht2nH7t5pvJeHWO9EbakA5a--