Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.30) id 1BECTf-0007B6-Cb for qemu-devel@nongnu.org; Thu, 15 Apr 2004 15:24:47 -0400 Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.30) id 1BECT7-00070B-Ow for qemu-devel@nongnu.org; Thu, 15 Apr 2004 15:24:44 -0400 Received: from [80.91.224.249] (helo=main.gmane.org) by monty-python.gnu.org with esmtp (Exim 4.30) id 1BECS0-0006pz-4H for qemu-devel@nongnu.org; Thu, 15 Apr 2004 15:23:04 -0400 Received: from list by main.gmane.org with local (Exim 3.35 #1 (Debian)) id 1BECRs-0006G2-00 for ; Thu, 15 Apr 2004 21:22:56 +0200 Received: from chello212186175067.4.14.vie.surfer.at ([chello212186175067.4.14.vie.surfer.at]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 15 Apr 2004 21:22:56 +0200 Received: from ge by chello212186175067.4.14.vie.surfer.at with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 15 Apr 2004 21:22:56 +0200 From: Gabriel Ebner Date: Thu, 15 Apr 2004 21:21:58 +0200 Message-ID: <1852025.iu0f2uxYHE@schnecke2.gabrielebner.at> References: <20040404201119.GA2094@mail.com> <20040404202705.GA30876@jbrown.mylinuxbox.org> <20040406202305.GA30254@mail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="nextPart2572773.hiGDiTGX4N" Content-Transfer-Encoding: 7Bit Sender: news Subject: [Qemu-devel] [PATCH] /dev/tun support (was: Re: Gentoo & qemu & non-static build) 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 --nextPart2572773.hiGDiTGX4N Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8Bit Hello rutger@mail.com wrote: > Now trying to let qemu use /dev/tun (default of udev) instead of > /dev/net/tun ... With this patch against current CVS if qemu can't open /dev/net/tun, it will try /dev/tun. Documentation and error strings adjusted. Gabriel. -- Gabriel Ebner - reverse "ta.renbeleirbag@eg" --nextPart2572773.hiGDiTGX4N Content-Type: text/x-diff; name="qemu-udev-tun-r2.patch" Content-Transfer-Encoding: 8Bit Content-Disposition: attachment; filename="qemu-udev-tun-r2.patch" Index: vl.c =================================================================== RCS file: /cvsroot/qemu/qemu/vl.c,v retrieving revision 1.59 diff -u -r1.59 vl.c --- vl.c 12 Apr 2004 20:39:28 -0000 1.59 +++ vl.c 15 Apr 2004 19:10:13 -0000 @@ -765,22 +765,29 @@ #else +#define MAX_TUNDEV_LEN 13 + static int tun_open(char *ifname, int ifname_size) { struct ifreq ifr; int fd, ret; + char tundev[MAX_TUNDEV_LEN]; - fd = open("/dev/net/tun", O_RDWR); - if (fd < 0) { - fprintf(stderr, "warning: could not open /dev/net/tun: no virtual network emulation\n"); + if ((fd = open("/dev/net/tun", O_RDWR)) >= 0) { + strncpy(tundev, "/dev/net/tun", MAX_TUNDEV_LEN); + } else if ((fd = open("/dev/tun", O_RDWR)) >= 0) { + strncpy(tundev, "/dev/tun", MAX_TUNDEV_LEN); + } else { + fprintf(stderr, "warning: could not open either /dev/net/tun or /dev/tun: no virtual network emulation\n"); return -1; } + memset(&ifr, 0, sizeof(ifr)); ifr.ifr_flags = IFF_TAP | IFF_NO_PI; pstrcpy(ifr.ifr_name, IFNAMSIZ, "tun%d"); ret = ioctl(fd, TUNSETIFF, (void *) &ifr); if (ret != 0) { - fprintf(stderr, "warning: could not configure /dev/net/tun: no virtual network emulation\n"); + fprintf(stderr, "warning: could not configure %s: no virtual network emulation\n", tundev); close(fd); return -1; } Index: qemu-doc.texi =================================================================== RCS file: /cvsroot/qemu/qemu/qemu-doc.texi,v retrieving revision 1.25 diff -u -r1.25 qemu-doc.texi --- qemu-doc.texi 4 Apr 2004 15:21:17 -0000 1.25 +++ qemu-doc.texi 15 Apr 2004 19:10:13 -0000 @@ -552,7 +552,7 @@ properly @code{sudo} so that the command @code{ifconfig} contained in @file{qemu-ifup} can be executed as root. You must verify that your host kernel supports the TUN/TAP network interfaces: the device -@file{/dev/net/tun} must be present. +@file{/dev/net/tun} or @file{/dev/tun} must be present. When network is enabled, there is a virtual network connection between the host kernel and the emulated kernel. The emulated kernel is seen --nextPart2572773.hiGDiTGX4N--