From: Victor Dorneanu <victor@dornea.nu>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [Fwd: qemu-0.11.1 / tap device bug]
Date: Sat, 19 Dec 2009 16:27:21 +0100 [thread overview]
Message-ID: <4B2CF0D9.3020700@dornea.nu> (raw)
[-- Attachment #1: Type: text/plain, Size: 101 bytes --]
Hi there!
I send you some bug report I've reported to NetBSD's mailing lists.
--
Victor Dorneanu
[-- Attachment #2: qemu-0.11.1 / tap device bug.eml --]
[-- Type: message/rfc822, Size: 3095 bytes --]
[-- Attachment #2.1.1: Type: text/plain, Size: 1166 bytes --]
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
[-- Attachment #2.1.2: patch.diff --]
[-- Type: text/plain, Size: 1177 bytes --]
--- 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;
}
reply other threads:[~2009-12-19 15:29 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4B2CF0D9.3020700@dornea.nu \
--to=victor@dornea.nu \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.