Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LJx9L-0002Jj-0K for qemu-devel@nongnu.org; Mon, 05 Jan 2009 16:38:15 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LJx9J-0002Io-89 for qemu-devel@nongnu.org; Mon, 05 Jan 2009 16:38:13 -0500 Received: from [199.232.76.173] (port=49420 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LJx9I-0002Ig-Tt for qemu-devel@nongnu.org; Mon, 05 Jan 2009 16:38:12 -0500 Received: from bay0-omc3-s2.bay0.hotmail.com ([65.54.246.202]:2440) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LJx9I-0007l5-BS for qemu-devel@nongnu.org; Mon, 05 Jan 2009 16:38:12 -0500 Message-ID: Message-Id: <85FEBAE7-7B09-490D-92F1-A0A945309FE3@hotmail.com> From: C.W. Betts In-Reply-To: <4D7F9D0A-3003-4845-A6EA-DA740747D991@sonous.com> Content-Type: multipart/alternative; boundary=Apple-Mail-4--518796734 Mime-Version: 1.0 (Apple Message framework v930.3) Subject: Re: [Qemu-devel] tun/tap patch for OSX Date: Mon, 5 Jan 2009 14:37:53 -0700 References: <5416901D-BAF1-48FB-8577-2264BCD678B6@sonous.com> <4D7F9D0A-3003-4845-A6EA-DA740747D991@sonous.com> 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 --Apple-Mail-4--518796734 Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit If we do commit this, there should be a way to check and see of these kernel modules are installed. On Jan 5, 2009, at 11:11 AM, Lev Lvovsky wrote: > Any interest in this guys? > > To my knowledge, Mattias' tun/tap kernel extension is the only way > to get tun/tap working in OSX. > > thanks, > -lev > > On Dec 28, 2008, at 10:11 PM, 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 >> ). >> >> 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; >> >> > > > --Apple-Mail-4--518796734 Content-Type: text/html; charset=US-ASCII Content-Transfer-Encoding: quoted-printable If we do commit this, there = should be a way to check and see of these kernel modules are = installed.
On Jan 5, 2009, at 11:11 AM, Lev Lvovsky = wrote:

Any interest in this guys?

To my knowledge, = Mattias' tun/tap kernel extension is the only way to get tun/tap working = in OSX.

thanks,
-lev

On Dec 28, 2008, at 10:11 PM, 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= ).

Mattias is = CC'd.

thanks,
-lev

----
bash-3.2$ = svn diff net.c
Index: = net.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- net.c =       (revision = 6082)
+++ net.c =       (working = copy)
@@ -686,8 +686,36 = @@
=    snprintf(s->vc->info_str, sizeof(s->vc->info_str), = "tap: fd=3D%d", fd);
=    return s;
}
+#if = defined(__APPLE__)
+static int = tap_open(char *ifname, int ifname_size)
+{
+ =    int fd;
+ =    int i =3D 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 =3D open(buf, = O_RDWR);
+ =        if (fd < 0) = {
+ =            if = (errno !=3D EBUSY) {
+ =             &n= bsp;  fprintf(stderr, "warning: could not open %s: no virtual = network emulation\n", buf);
+ =             &n= bsp;  return -1;
+ =            }
+ =            i++;
=
+ =        } = else
+ =            break;
+ =    }
+
+ =    fstat(fd, &s);
+    dev =3D 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;






= --Apple-Mail-4--518796734--