* [Qemu-devel] tun/tap patch for OSX
@ 2008-12-29 6:11 Lev Lvovsky
2009-01-05 18:11 ` Lev Lvovsky
2009-01-08 20:31 ` Anthony Liguori
0 siblings, 2 replies; 4+ messages in thread
From: Lev Lvovsky @ 2008-12-29 6:11 UTC (permalink / raw)
To: qemu-devel; +Cc: Mattias Nissler
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;
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] tun/tap patch for OSX
2008-12-29 6:11 [Qemu-devel] tun/tap patch for OSX Lev Lvovsky
@ 2009-01-05 18:11 ` Lev Lvovsky
[not found] ` <85FEBAE7-7B09-490D-92F1-A0A945309FE3@hotmail.com>
2009-01-08 20:31 ` Anthony Liguori
1 sibling, 1 reply; 4+ messages in thread
From: Lev Lvovsky @ 2009-01-05 18:11 UTC (permalink / raw)
To: qemu-devel; +Cc: Mattias Nissler
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;
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] tun/tap patch for OSX
[not found] ` <85FEBAE7-7B09-490D-92F1-A0A945309FE3@hotmail.com>
@ 2009-01-05 21:37 ` C.W. Betts
0 siblings, 0 replies; 4+ messages in thread
From: C.W. Betts @ 2009-01-05 21:37 UTC (permalink / raw)
To: qemu-devel
[-- Attachment #1: Type: text/plain, Size: 1931 bytes --]
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;
>>
>>
>
>
>
[-- Attachment #2: Type: text/html, Size: 4973 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] tun/tap patch for OSX
2008-12-29 6:11 [Qemu-devel] tun/tap patch for OSX Lev Lvovsky
2009-01-05 18:11 ` Lev Lvovsky
@ 2009-01-08 20:31 ` Anthony Liguori
1 sibling, 0 replies; 4+ messages in thread
From: Anthony Liguori @ 2009-01-08 20:31 UTC (permalink / raw)
To: qemu-devel; +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;
>
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-01-08 20:31 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-12-29 6:11 [Qemu-devel] tun/tap patch for OSX Lev Lvovsky
2009-01-05 18:11 ` Lev Lvovsky
[not found] ` <85FEBAE7-7B09-490D-92F1-A0A945309FE3@hotmail.com>
2009-01-05 21:37 ` C.W. Betts
2009-01-08 20:31 ` Anthony Liguori
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).