From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NM1FX-0005OL-3w for qemu-devel@nongnu.org; Sat, 19 Dec 2009 10:29:43 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NM1FR-0005KN-L4 for qemu-devel@nongnu.org; Sat, 19 Dec 2009 10:29:41 -0500 Received: from [199.232.76.173] (port=50366 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NM1FR-0005KK-G7 for qemu-devel@nongnu.org; Sat, 19 Dec 2009 10:29:37 -0500 Received: from relay2.mail.vrmd.de ([81.28.224.28]:40857) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NM1FR-0005ps-5o for qemu-devel@nongnu.org; Sat, 19 Dec 2009 10:29:37 -0500 Received: from [188.103.24.194] (helo=[192.168.178.21]) by relay2.mail.vrmd.de with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.69) (envelope-from ) id 1NM1FI-00039t-SI for qemu-devel@nongnu.org; Sat, 19 Dec 2009 16:29:29 +0100 Message-ID: <4B2CF0D9.3020700@dornea.nu> Date: Sat, 19 Dec 2009 16:27:21 +0100 From: Victor Dorneanu MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------020504070807020708050201" Subject: [Qemu-devel] [Fwd: qemu-0.11.1 / tap device bug] List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org This is a multi-part message in MIME format. --------------020504070807020708050201 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Hi there! I send you some bug report I've reported to NetBSD's mailing lists. -- Victor Dorneanu --------------020504070807020708050201 Content-Type: message/rfc822; name="qemu-0.11.1 / tap device bug.eml" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="qemu-0.11.1 / tap device bug.eml" X-Mozilla-Keys: Message-ID: <4B2BC0B4.7060904@dornea.nu> Date: Fri, 18 Dec 2009 18:49:40 +0100 From: Victor Dorneanu User-Agent: Thunderbird 2.0.0.23 (X11/20091017) MIME-Version: 1.0 To: pkgsrc-users@netbsd.org Subject: qemu-0.11.1 / tap device bug X-Enigmail-Version: 0.96.0 Content-Type: multipart/mixed; boundary="------------000500070409080500030201" This is a multi-part message in MIME format. --------------000500070409080500030201 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Hello there! I don't know if you can remember this thread [1]. Whenever I tried to use some previously configured TAP device, I got a segmentation fault. I thought it could some brilliant idea to have a look at the sources and try to find out what's causing that error. After several gdb sessions, it turned out qemu was accessing the wrong device. -------------- File: net.c / Lines:1466-1470 -------------- TFR(fd = open("/dev/tap", O_RDWR)); if (fd < 0) { fprintf(stderr, "warning: could not open /dev/tap: no virtual network emulation\n"); return -1; } ----------------------------------------------------------------------- If you run qemu like this: $ qemu -net tap,ifname=tap0 ... why is "/dev/tap" being used as tap device?! It should be "/dev/tap0". I have attached a patch which should do the work. Any suggestions/improvements are appreciated. Links: [1] http://mail-index.netbsd.org/netbsd-users/2009/11/25/msg004957.html -- Victor Dorneanu Contact - Web/Blog: http://dornea.nu GnuPGP information - KeyID = 0xD20870F4 (subkeys.pgp.net) - Key fingerprint = DD6B 5E09 242F 7410 3F90 492A 4CBA FD13 D208 70F4 --------------000500070409080500030201 Content-Type: text/plain; name="patch.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="patch.diff" --- net.c.orig 2009-12-18 18:24:20.000000000 +0100 +++ net.c 2009-12-18 18:19:07.000000000 +0100 @@ -116,7 +116,7 @@ #include "sysemu.h" #include "qemu-timer.h" #include "qemu-char.h" -#include "audio/audio.h" +#include "audio/qaudio.h" #include "qemu_socket.h" #include "qemu-log.h" @@ -1461,11 +1461,27 @@ { int fd; char *dev; + char tap_dev[1024]; struct stat s; - TFR(fd = open("/dev/tap", O_RDWR)); +#if defined (__NetBSD__) + // Concatenate dev path (/dev/) and tap device name (e.g. tap0) + if (strlcpy(tap_dev, "/dev/", sizeof(tap_dev)) >= sizeof(tap_dev)) { + fprintf(stderr, "error: tap device name too long\n"); + return -1; + } + + if (strlcat(tap_dev, ifname, sizeof(tap_dev)) >= sizeof(tap_dev)) { + fprintf(stderr, "error: tap device name too long\n"); + return -1; + } +#else + tap_dev="/dev/tap"; +#endif + TFR(fd = open(tap_dev, O_RDWR)); + if (fd < 0) { - fprintf(stderr, "warning: could not open /dev/tap: no virtual network emulation\n"); + fprintf(stderr, "warning: could not open %s: no virtual network emulation\n",tap_dev); return -1; } --------------000500070409080500030201-- --------------020504070807020708050201--