Patchwork [Fwd:,qemu-0.11.1,/,tap,device,bug]

login
register
mail settings
Submitter Victor Dorneanu
Date Dec. 19, 2009, 3:27 p.m.
Message ID <4B2CF0D9.3020700@dornea.nu>
Download mbox | patch
Permalink /patch/41464/
State New
Headers show

Comments

Victor Dorneanu - Dec. 19, 2009, 3:27 p.m.
Hi there!

I send you some bug report I've reported to NetBSD's mailing lists.

Patch

--- 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;
     }