openbsd-ports/emulators/qemu/patches/patch-vl_c
todd 202b6aaad6 Import qemu snapshot from 2005-02-27
QEMU is a generic and open source processor emulator 
which achieves a good emulation speed by using dynamic translation.

QEMU has two operating modes:

* Full system emulation. In this mode, QEMU emulates 
a full system (for example a PC), including a processor and 
various peripherials. It can be used to launch different
Operating Systems without rebooting the PC or to debug system code.

* User mode emulation (Linux host only). In this mode, 

.. many thanks for feedback from many people, and for Lars Hansson and 
   Michael Schmidt for posting early work on the port of qemu to ports@

For now, only for macppc and i386, as these are currently the only archs
that have reported success building qemu.
QEMU can launch Linux processes compiled for one CPU on another CPU.
2005-03-07 16:41:28 +00:00

48 lines
1.2 KiB
Plaintext

$OpenBSD: patch-vl_c,v 1.1.1.1 2005/03/07 16:41:28 todd Exp $
--- vl.c.orig Thu Feb 10 16:00:06 2005
+++ vl.c Tue Mar 1 15:53:26 2005
@@ -42,7 +42,7 @@
#include <dirent.h>
#ifdef _BSD
#include <sys/stat.h>
-#ifndef __APPLE__
+#if !defined(__APPLE__) && !defined(__OpenBSD__)
#include <libutil.h>
#endif
#else
@@ -1574,11 +1574,34 @@ static int tun_open(char *ifname, int if
char *dev;
struct stat s;
+#ifdef __OpenBSD__
+ int i = 0, enoentcount = 0, err = 0;
+ char dname[100];
+
+ for (; i < 10; i++) {
+ snprintf(dname, sizeof dname, "%s%d", "/dev/tun", i);
+ fd = open(dname, O_RDWR);
+ if (fd >= 0)
+ break;
+ else if (errno != ENOENT || ++enoentcount > 3) {
+ if (errno != EBUSY) {
+ err = errno;
+ break;
+ }
+ } else
+ err = errno;
+ }
+ if (fd < 0) {
+ fprintf(stderr, "warning: could not open %s (%s): no virtual network emulation\n", dname, strerror(err));
+ return -1;
+ }
+#else
fd = open("/dev/tap", O_RDWR);
if (fd < 0) {
fprintf(stderr, "warning: could not open /dev/tap: no virtual network emulation\n");
return -1;
}
+#endif
fstat(fd, &s);
dev = devname(s.st_rdev, S_IFCHR);