From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LL1XX-0007G1-L4 for qemu-devel@nongnu.org; Thu, 08 Jan 2009 15:31:39 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LL1XX-0007FU-7Y for qemu-devel@nongnu.org; Thu, 08 Jan 2009 15:31:39 -0500 Received: from [199.232.76.173] (port=41184 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LL1XX-0007FR-1I for qemu-devel@nongnu.org; Thu, 08 Jan 2009 15:31:39 -0500 Received: from mail-ew0-f21.google.com ([209.85.219.21]:36736) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LL1XV-0004hY-W0 for qemu-devel@nongnu.org; Thu, 08 Jan 2009 15:31:38 -0500 Received: by ewy14 with SMTP id 14so10414349ewy.10 for ; Thu, 08 Jan 2009 12:31:36 -0800 (PST) Message-ID: <4966629F.7020300@codemonkey.ws> Date: Thu, 08 Jan 2009 14:31:27 -0600 From: Anthony Liguori MIME-Version: 1.0 Subject: Re: [Qemu-devel] tun/tap patch for OSX References: <5416901D-BAF1-48FB-8577-2264BCD678B6@sonous.com> In-Reply-To: <5416901D-BAF1-48FB-8577-2264BCD678B6@sonous.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Mattias Nissler Lev Lvovsky wrote: > The following patch provided by Mattias Nissler, and tweaked by myself > to be applied to net.c (previously to vl.c) allows qemu to use the > tun/tap devices provided at Mattias' site > (http://tuntaposx.sourceforge.net). Needs a valid Signed-off-by along with appropriate documentation pointing users to tuntaposx. Regards, Anthony Liguori > Mattias is CC'd. > > thanks, > -lev > > ---- > bash-3.2$ svn diff net.c > Index: net.c > =================================================================== > --- net.c (revision 6082) > +++ net.c (working copy) > @@ -686,8 +686,36 @@ > snprintf(s->vc->info_str, sizeof(s->vc->info_str), "tap: fd=%d", > fd); > return s; > } > +#if defined(__APPLE__) > +static int tap_open(char *ifname, int ifname_size) > +{ > + int fd; > + int i = 0; > + char *dev; > + char buf[20]; > + struct stat s; > > -#if defined (_BSD) || defined (__FreeBSD_kernel__) > + while (1) { > + snprintf(buf, 20, "/dev/tap%d", i); > + fd = open(buf, O_RDWR); > + if (fd < 0) { > + if (errno != EBUSY) { > + fprintf(stderr, "warning: could not open %s: no > virtual network emulation\n", buf); > + return -1; > + } > + i++; > + } else > + break; > + } > + > + fstat(fd, &s); > + dev = devname(s.st_rdev, S_IFCHR); > + pstrcpy(ifname, ifname_size, dev); > + > + fcntl(fd, F_SETFL, O_NONBLOCK); > + return fd; > +} > +#elif defined (_BSD) || defined (__FreeBSD_kernel__) > static int tap_open(char *ifname, int ifname_size) > { > int fd; > > >