Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 3 Jun 2004 00:39:41 +0200 (CEST)
From:      Juergen Lock <nox@jelal.kn-bremen.de>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   ports/67506: new port emulators/qemu
Message-ID:  <200406022239.i52Mdfq39643@saturn.kn-bremen.de>
Resent-Message-ID: <200406022240.i52MecbB097416@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         67506
>Category:       ports
>Synopsis:       new port emulators/qemu
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Wed Jun 02 15:40:38 PDT 2004
>Closed-Date:
>Last-Modified:
>Originator:     Juergen Lock
>Release:        FreeBSD 4.9-RELEASE i386
>Organization:
me?  organized??
>Environment:
System: FreeBSD neptun 4.9-RELEASE FreeBSD 4.9-RELEASE #0: Tue Jun  1 23:03:18 CEST 2004     nox@neptun:/usr/src/sys/compile/NEPTUN  i386


>Description:

	port of qemu mainly to attract developers (some things work, some
not yet)

>How-To-Repeat:

	unshar in an empty directory, make install

>Fix:

# This is a shell archive.  Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file".  Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
#	Makefile
#	distinfo
#	pkg-descr
#	pkg-plist
#	files/
#	files/patch-aa
#	files/patch-ab
#	files/patch-ac
#	files/patch-ba
#	files/patch-bb
#	files/patch-bc
#	files/patch-bd
#	files/patch-be
#	files/patch-bf
#	files/patch-bt
#
echo x - Makefile
sed 's/^X//' >Makefile << 'END-of-Makefile'
X# New ports collection makefile for:	qemu
X# Date created:			2004/05/31
X# Whom:				Juergen Lock <nox@jelal.kn-bremen.de>
X#
X# $FreeBSD$
X#
X
XPORTNAME=	qemu
XPORTVERSION=	055
XPORTREVISION=	20040530
XCATEGORIES=	emulators
XMASTER_SITES=	http://dad-answers.com/qemu/
XDISTNAME=	${PORTNAME}-snapshot-2004-05-30_23-40
X
XMAINTAINER=	nox@jelal.kn-bremen.de
XCOMMENT=	QEMU CPU Emulator
X
XBUILD_DEPENDS+=	texi2html:${PORTSDIR}/textproc/texi2html
X
XHAS_CONFIGURE=	yes
XUSE_BZIP2=	yes
XUSE_GMAKE=	yes
XUSE_SDL=	sdl
XUSE_GCC=	3.3
XUSE_PERL5=	yes
XWRKSRC=		${WRKDIR}/${DISTNAME}
XPATCH_STRIP=	-p1
XCONFIGURE_ARGS+=	--cc=${CC}\ -fno-strict-aliasing\ -DDEBUG_IRQ_COUNT\ -I${PREFIX}/include --enable-slirp
XMAN1=		qemu.1 qemu-mkcow.1
X
X.include <bsd.port.mk>
END-of-Makefile
echo x - distinfo
sed 's/^X//' >distinfo << 'END-of-distinfo'
XMD5 (qemu-snapshot-2004-05-30_23-40.tar.bz2) = 4ce3834c66e4628e33a083db5e542287
XSIZE (qemu-snapshot-2004-05-30_23-40.tar.bz2) = 637024
END-of-distinfo
echo x - pkg-descr
sed 's/^X//' >pkg-descr << 'END-of-pkg-descr'
XQEMU is a FAST! processor emulator using dynamic translation to achieve
Xgood emulation speed.
XQEMU has two operating modes:
X
X    * Full system emulation. In this mode, QEMU emulates a full system
X(for example a PC), including a processor and various peripherials.
XIt can be used to launch different Operating Systems without rebooting
Xthe PC or to debug system code.
X    * User mode emulation (Linux host only). In this mode, QEMU can launch
XLinux processes compiled for one CPU on another CPU. It can be used to
Xlaunch the Wine Windows API emulator or to ease cross-compilation and
Xcross-debugging. 
X
XAs QEMU requires no host kernel patches to run, it is very safe and easy to use.
X
X
XFreeBSD host notes:
X- needs to run as root in order to use /dev/tap* networking (why?)
X- slirp (usermode networking) compiles but doesn't seem to work for me
X- seems to have a timer problem (time sleep 1 takes 49 seconds and
Xbooting sleeps for minutes at the acd0 probe), but only on _some_ guest
Xsystems (FreeSBIE, knoppix.)  An installed 5.2.1 guest system works ok
X(this also doesn't happen with linux as host.)  And enabling /dev/rtc doesn't
Xhelp either... (not included since it needs a patch to emulators/rtc.)
X- using physical media doesn't work on 4.x hosts (missing DIOCGMEDIASIZE
Xioctl)
X
XWWW: http://fabrice.bellard.free.fr/qemu/
END-of-pkg-descr
echo x - pkg-plist
sed 's/^X//' >pkg-plist << 'END-of-pkg-plist'
Xbin/qemu
Xbin/qemu-mkcow
Xbin/vmdk2raw
Xshare/qemu/bios.bin
Xshare/qemu/vgabios.bin
Xshare/qemu/linux_boot.bin
Xshare/doc/qemu/qemu-doc.html
Xshare/doc/qemu/qemu-tech.html
END-of-pkg-plist
echo c - files/
mkdir -p files/ > /dev/null 2>&1
echo x - files/patch-aa
sed 's/^X//' >files/patch-aa << 'END-of-files/patch-aa'
Xdiff -urd --exclude=CVS ../cvs/qemu/Makefile qemu-0.5.5/Makefile
X--- ../cvs/qemu/Makefile	Mon May 17 21:06:42 2004
X+++ qemu-0.5.5/Makefile	Sun May 30 05:26:19 2004
X@@ -70,7 +70,7 @@
X 
X # documentation
X %.html: %.texi
X-	texi2html -monolithic -number $<
X+	-texi2html -monolithic -number $<
X 
X qemu.1: qemu-doc.texi
X 	./texi2pod.pl $< qemu.pod
Xdiff -urd --exclude=CVS ../cvs/qemu/block.c qemu-0.5.5/block.c
X--- ../cvs/qemu/block.c	Sat May  8 16:27:20 2004
X+++ qemu-0.5.5/block.c	Sun May 30 16:36:53 2004
X@@ -27,6 +27,13 @@
X #include <sys/mman.h>
X #endif
X 
X+#ifdef _BSD
X+#include <sys/types.h>
X+#include <sys/stat.h>
X+#include <sys/ioctl.h>
X+#include <sys/disk.h>
X+#endif
X+
X #include "cow.h"
X 
X struct BlockDriverState {
X@@ -81,7 +88,10 @@
X {
X     int fd;
X     int64_t size;
X-    struct cow_header_v2 cow_header;
X+    union {
X+      struct cow_header_v2 cow_header;
X+      uint8_t cow_buffer[2048];
X+    } cow;
X #ifndef _WIN32
X     char template[] = "/tmp/vl.XXXXXX";
X     int cow_fd;
X@@ -117,15 +127,15 @@
X     bs->fd = fd;
X 
X     /* see if it is a cow image */
X-    if (read(fd, &cow_header, sizeof(cow_header)) != sizeof(cow_header)) {
X+    if (read(fd, &cow.cow_header, sizeof(cow)) != sizeof(cow)) {
X         fprintf(stderr, "%s: could not read header\n", filename);
X         goto fail;
X     }
X #ifndef _WIN32
X-    if (be32_to_cpu(cow_header.magic) == COW_MAGIC &&
X-        be32_to_cpu(cow_header.version) == COW_VERSION) {
X+    if (be32_to_cpu(cow.cow_header.magic) == COW_MAGIC &&
X+        be32_to_cpu(cow.cow_header.version) == COW_VERSION) {
X         /* cow image found */
X-        size = cow_header.size;
X+        size = cow.cow_header.size;
X #ifndef WORDS_BIGENDIAN
X         size = bswap64(size);
X #endif    
X@@ -133,34 +143,41 @@
X 
X         bs->cow_fd = fd;
X         bs->fd = -1;
X-        if (cow_header.backing_file[0] != '\0') {
X-            if (stat(cow_header.backing_file, &st) != 0) {
X-                fprintf(stderr, "%s: could not find original disk image '%s'\n", filename, cow_header.backing_file);
X+        if (cow.cow_header.backing_file[0] != '\0') {
X+            if (stat(cow.cow_header.backing_file, &st) != 0) {
X+                fprintf(stderr, "%s: could not find original disk image '%s'\n", filename, cow.cow_header.backing_file);
X                 goto fail;
X             }
X-            if (st.st_mtime != be32_to_cpu(cow_header.mtime)) {
X-                fprintf(stderr, "%s: original raw disk image '%s' does not match saved timestamp\n", filename, cow_header.backing_file);
X+            if (st.st_mtime != be32_to_cpu(cow.cow_header.mtime)) {
X+                fprintf(stderr, "%s: original raw disk image '%s' does not match saved timestamp\n", filename, cow.cow_header.backing_file);
X                 goto fail;
X             }
X-            fd = open(cow_header.backing_file, O_RDONLY | O_LARGEFILE);
X+            fd = open(cow.cow_header.backing_file, O_RDONLY | O_LARGEFILE);
X             if (fd < 0)
X                 goto fail;
X             bs->fd = fd;
X         }
X         /* mmap the bitmap */
X-        bs->cow_bitmap_size = ((bs->total_sectors + 7) >> 3) + sizeof(cow_header);
X+        bs->cow_bitmap_size = ((bs->total_sectors + 7) >> 3) + sizeof(cow.cow_header);
X         bs->cow_bitmap_addr = mmap(get_mmap_addr(bs->cow_bitmap_size), 
X                                    bs->cow_bitmap_size, 
X                                    PROT_READ | PROT_WRITE,
X                                    MAP_SHARED, bs->cow_fd, 0);
X         if (bs->cow_bitmap_addr == MAP_FAILED)
X             goto fail;
X-        bs->cow_bitmap = bs->cow_bitmap_addr + sizeof(cow_header);
X+        bs->cow_bitmap = bs->cow_bitmap_addr + sizeof(cow.cow_header);
X         bs->cow_sectors_offset = (bs->cow_bitmap_size + 511) & ~511;
X         snapshot = 0;
X     } else 
X #endif
X     {
X+#ifdef _BSD
X+        struct stat sb;
X+        if (!fstat(fd,&sb) && (S_IFCHR & sb.st_mode)) {
X+            if (ioctl(fd, DIOCGMEDIASIZE, (off_t *)&size))
X+                size = lseek(fd, 0LL, SEEK_END);
X+        } else
X+#endif                      
X         /* standard raw image */
X         size = lseek64(fd, 0, SEEK_END);
X         bs->total_sectors = size / 512;
XOnly in qemu-0.5.5: block.c.bck
Xdiff -urd --exclude=CVS ../cvs/qemu/configure qemu-0.5.5/configure
X--- ../cvs/qemu/configure	Thu May 20 14:23:39 2004
X+++ qemu-0.5.5/configure	Sun May 30 05:42:05 2004
X@@ -419,9 +419,11 @@
X if [ "$bsd" = "yes" ] ; then
X   echo "#define O_LARGEFILE 0" >> $config_h
X   echo "#define lseek64 lseek" >> $config_h
X+  echo "#define mkstemp64 mkstemp" >> $config_h
X   echo "#define ftruncate64 ftruncate" >> $config_h
X   echo "#define MAP_ANONYMOUS MAP_ANON" >> $config_h
X   echo "#define _BSD 1" >> $config_h
X+  echo "#define off64_t off_t" >> $config_h
X fi
X 
X for target in $target_list; do 
XOnly in qemu-0.5.5: qemu.1
Xdiff -urd --exclude=CVS ../cvs/qemu/target-i386/cpu.h qemu-0.5.5/target-i386/cpu.h
X--- ../cvs/qemu/target-i386/cpu.h	Thu May 20 15:01:56 2004
X+++ qemu-0.5.5/target-i386/cpu.h	Sun May 30 05:16:10 2004
X@@ -259,7 +259,7 @@
X     CC_OP_NB,
X };
X 
X-#if (defined(__i386__) || defined(__x86_64__)) && !defined(_BSD)
X+#if defined(__i386__) || defined(__x86_64__)
X #define USE_X86LDOUBLE
X #endif
X 
Xdiff -urd --exclude=CVS ../cvs/qemu/target-i386/exec.h qemu-0.5.5/target-i386/exec.h
X--- ../cvs/qemu/target-i386/exec.h	Sat May 29 12:08:52 2004
X+++ qemu-0.5.5/target-i386/exec.h	Sun May 30 05:19:43 2004
X@@ -293,6 +293,22 @@
X 
X #endif /* !defined(CONFIG_USER_ONLY) */
X 
X+#if defined(_BSD) && defined(USE_X86LDOUBLE)
X+#include <math.h>
X+/*int rintl(long double __x);
X+long int lrintl(long double __x);
X+long long int llrintl(long double __x);
X+long double powl(long double __x, long double __y);
X+long double logl(long double __x);
X+long double tanl(long double __x);
X+long double atan2l(long double __y, long double __x);
X+long double ceill(long double __x);
X+long double floorl(long double __x);
X+long double sqrtl(long double __x);
X+long double sinl(long double __x);
X+long double cosl(long double __x);*/
X+#endif
X+
X #ifdef USE_X86LDOUBLE
X /* use long double functions */
X #define lrint lrintl
X@@ -310,7 +326,7 @@
X #define rint rintl
X #endif
X 
X-#if !defined(_BSD)
X+#if !defined(_BSD) || defined(USE_X86LDOUBLE)
X extern int lrint(CPU86_LDouble x);
X extern int64_t llrint(CPU86_LDouble x);
X #else
Xdiff -urd --exclude=CVS ../cvs/qemu/target-i386/op.c qemu-0.5.5/target-i386/op.c
X--- ../cvs/qemu/target-i386/op.c	Sat May 29 12:08:52 2004
X+++ qemu-0.5.5/target-i386/op.c	Sun May 30 05:40:54 2004
X@@ -1304,6 +1304,149 @@
X    functions comes from the LGPL'ed x86 emulator found in the Willows
X    TWIN windows emulator. */
X 
X+#if defined(_BSD) && defined(USE_X86LDOUBLE)
X+
X+CPU86_LDouble rintl(CPU86_LDouble __x) {
X+  CPU86_LDouble __rintres;
X+  __asm__ __volatile__
X+    ("fistp %0"
X+     : "=m" (__rintres) : "t" (__x) : "st");
X+  return __rintres;
X+}
X+
X+int lrintl(CPU86_LDouble __x) {
X+  int __lrintres;
X+  __asm__ __volatile__
X+    ("fistpl %0"
X+     : "=m" (__lrintres) : "t" (__x) : "st");
X+  return __lrintres;
X+}
X+
X+
X+int64_t llrintl(CPU86_LDouble __x) {
X+  int64_t __llrintres;
X+  __asm__ __volatile__
X+    ("fistpll %0"
X+     : "=m" (__llrintres) : "t" (__x) : "st");
X+  return __llrintres;
X+}
X+
X+CPU86_LDouble powl(CPU86_LDouble __x, CPU86_LDouble __y) {
X+  register CPU86_LDouble __value;
X+  register long double __exponent;
X+  __extension__ long long int __p = (long long int) __y;
X+  if (__x == 0.0)
X+    {
X+       if (__y > 0.0)
X+         return __y == (double) __p && (__p & 1) != 0 ? __x : 0.0;
X+       else if (__y < 0.0)
X+         return (__y == (double) __p && (-__p & 1) != 0
X+                 ? 1.0 / __x : 1.0 / fabs (__x));
X+    }
X+  if (__y == (double) __p)
X+    {
X+      long double __r = 1.0;
X+      if (__p == 0)
X+        return 1.0;
X+      if (__p < 0)
X+        {
X+          __p = -__p;
X+          __x = 1.0 / __x;
X+        }
X+      while (1)
X+        {
X+          if (__p & 1)
X+            __r *= __x;
X+          __p >>= 1;
X+          if (__p == 0)
X+            return __r;
X+          __x *= __x;
X+        }
X+      /* NOTREACHED */
X+    }
X+  __asm __volatile__
X+    ("fyl2x" : "=t" (__value) : "0" (__x), "u" (1.0) : "st(1)");
X+  __asm __volatile__
X+    ("fmul      %%st(1)         # y * log2(x)\n\t"
X+     "fst       %%st(1)\n\t"
X+     "frndint                   # int(y * log2(x))\n\t"
X+     "fxch\n\t"
X+     "fsub      %%st(1)         # fract(y * log2(x))\n\t"
X+     "f2xm1                     # 2^(fract(y * log2(x))) - 1\n\t"
X+     : "=t" (__value), "=u" (__exponent) : "0" (__y), "1" (__value));
X+  __value += 1.0;
X+  __asm __volatile__
X+    ("fscale"
X+     : "=t" (__value) : "0" (__value), "u" (__exponent));
X+  return __value;
X+}
X+
X+CPU86_LDouble logl(CPU86_LDouble __x) {
X+  register CPU86_LDouble __result;
X+  __asm __volatile__ ("fldln2; fxch; fyl2x" : "=t" (__result) : "0" (__x) : "st(1)");
X+  return __result;
X+}
X+
X+CPU86_LDouble tanl(CPU86_LDouble __x) {
X+  register CPU86_LDouble __value;
X+  register CPU86_LDouble __value2 __attribute__ ((__unused__));
X+  __asm __volatile__
X+    ("fptan"
X+     : "=t" (__value2), "=u" (__value) : "0" (__x));
X+  return __value;
X+}
X+
X+CPU86_LDouble atan2l(CPU86_LDouble __y, CPU86_LDouble __x) {
X+  register CPU86_LDouble __value;
X+  __asm __volatile__
X+    ("fpatan"
X+     : "=t" (__value) : "0" (__x), "u" (__y) : "st(1)");
X+  return __value;
X+}
X+
X+CPU86_LDouble ceill(CPU86_LDouble __x) {
X+  register CPU86_LDouble __value;
X+  __volatile unsigned short int __cw;
X+  __volatile unsigned short int __cwtmp;
X+  __asm __volatile ("fnstcw %0" : "=m" (__cw));
X+  __cwtmp = (__cw & 0xf3ff) | 0x0800; /* rounding up */
X+  __asm __volatile ("fldcw %0" : : "m" (__cwtmp));
X+  __asm __volatile ("frndint" : "=t" (__value) : "0" (__x));
X+  __asm __volatile ("fldcw %0" : : "m" (__cw));
X+  return __value;
X+}
X+
X+CPU86_LDouble floorl(CPU86_LDouble __x) {
X+  register CPU86_LDouble __value;
X+  __volatile unsigned short int __cw;
X+  __volatile unsigned short int __cwtmp;
X+  __asm __volatile ("fnstcw %0" : "=m" (__cw));
X+  __cwtmp = (__cw & 0xf3ff) | 0x0400; /* rounding down */
X+  __asm __volatile ("fldcw %0" : : "m" (__cwtmp));
X+  __asm __volatile ("frndint" : "=t" (__value) : "0" (__x));
X+  __asm __volatile ("fldcw %0" : : "m" (__cw));
X+  return __value;
X+}
X+
X+CPU86_LDouble sqrtl(CPU86_LDouble __x) {
X+  register CPU86_LDouble __result;
X+  __asm __volatile__ ("fsqrt" : "=t" (__result) : "0" (__x));
X+  return __result;
X+}
X+
X+CPU86_LDouble sinl(CPU86_LDouble __x) {
X+  register CPU86_LDouble __result;
X+  __asm __volatile__ ("fsin" : "=t" (__result) : "0" (__x));
X+  return __result;
X+}
X+
X+CPU86_LDouble cosl(CPU86_LDouble __x) {
X+  register CPU86_LDouble __result;
X+  __asm __volatile__ ("fcos" : "=t" (__result) : "0" (__x));
X+  return __result;
X+}
X+#endif
X+
X #if defined(__powerpc__)
X extern CPU86_LDouble copysign(CPU86_LDouble, CPU86_LDouble);
X 
Xdiff -urd --exclude=CVS ../cvs/qemu/vl.c qemu-0.5.5/vl.c
X--- ../cvs/qemu/vl.c	Wed May 26 23:12:06 2004
X+++ qemu-0.5.5/vl.c	Sun May 30 05:30:56 2004
X@@ -662,6 +662,14 @@
X     case QEMU_TIMER_REALTIME:
X #ifdef _WIN32
X         return GetTickCount();
X+#elif defined(_BSD)
X+        {
X+            struct timeval r;
X+            if (!gettimeofday(&r, NULL)) {
X+                return ((CLK_TCK * 1000LL) * (int64_t)r.tv_sec 
X+                      + ((int64_t)r.tv_usec * CLK_TCK) / 1000) / timer_freq;
X+            }
X+        }        
X #else
X         {
X             struct tms tp;
X@@ -828,6 +836,7 @@
X            the emulated kernel requested a too high timer frequency */
X         getitimer(ITIMER_REAL, &itv);
X 
X+#if defined(__linux__)
X         if (itv.it_interval.tv_usec > 1000) {
X             /* try to use /dev/rtc to have a faster timer */
X             if (start_rtc_timer() < 0)
X@@ -843,7 +852,9 @@
X             sigaction(SIGIO, &act, NULL);
X             fcntl(rtc_fd, F_SETFL, O_ASYNC);
X             fcntl(rtc_fd, F_SETOWN, getpid());
X-        } else {
X+        } else 
X+#endif
X+        {
X         use_itimer:
X             pit_min_timer_count = ((uint64_t)itv.it_interval.tv_usec * 
X                                    PIT_FREQ) / 1000000;
END-of-files/patch-aa
echo x - files/patch-ab
sed 's/^X//' >files/patch-ab << 'END-of-files/patch-ab'
XIndex: qemu-snapshot-2004-05-30_23-40/target-i386/op.c
X@@ -1307,11 +1307,9 @@
X #if defined(_BSD) && defined(USE_X86LDOUBLE)
X 
X CPU86_LDouble rintl(CPU86_LDouble __x) {
X-  CPU86_LDouble __rintres;
X-  __asm__ __volatile__
X-    ("fistp %0"
X-     : "=m" (__rintres) : "t" (__x) : "st");
X-  return __rintres;
X+  register CPU86_LDouble __result;
X+  __asm __volatile__ ("frndint" : "=t" (__result) : "0" (__x));
X+  return __result;
X }
X 
X int lrintl(CPU86_LDouble __x) {
END-of-files/patch-ab
echo x - files/patch-ac
sed 's/^X//' >files/patch-ac << 'END-of-files/patch-ac'
XIndex: qemu/configure
X@@ -204,7 +204,7 @@
X 
X if test -z "$sdl" ; then
X 
X-sdl_config="sdl-config"
X+sdl_config="sdl11-config"
X sdl=no
X sdl_static=no
X 
END-of-files/patch-ac
echo x - files/patch-ba
sed 's/^X//' >files/patch-ba << 'END-of-files/patch-ba'
XIndex: qemu/block.c
X@@ -31,6 +31,7 @@
X #include <sys/types.h>
X #include <sys/stat.h>
X #include <sys/ioctl.h>
X+#include <sys/queue.h>
X #include <sys/disk.h>
X #endif
X 
END-of-files/patch-ba
echo x - files/patch-bb
sed 's/^X//' >files/patch-bb << 'END-of-files/patch-bb'
XIndex: qemu/block.c
X@@ -175,7 +175,9 @@
X #ifdef _BSD
X         struct stat sb;
X         if (!fstat(fd,&sb) && (S_IFCHR & sb.st_mode)) {
X+#ifdef DIOCGMEDIASIZE
X             if (ioctl(fd, DIOCGMEDIASIZE, (off_t *)&size))
X+#endif
X                 size = lseek(fd, 0LL, SEEK_END);
X         } else
X #endif                      
END-of-files/patch-bb
echo x - files/patch-bc
sed 's/^X//' >files/patch-bc << 'END-of-files/patch-bc'
XIndex: qemu/i386-dis.c
X@@ -2896,6 +2896,10 @@
X   OP_E (bytemode, sizeflag);
X }
X 
X+#ifndef PRIx64
X+#define PRIx64 "llx"
X+#endif
X+
X static void
X print_operand_value (buf, hex, disp)
X   char *buf;
END-of-files/patch-bc
echo x - files/patch-bd
sed 's/^X//' >files/patch-bd << 'END-of-files/patch-bd'
XIndex: qemu/configure
X@@ -286,7 +286,7 @@
X if test -z "$prefix" ; then
X     prefix="/usr/local"
X fi
X-mandir="$prefix/share/man"
X+mandir="$prefix/man"
X datadir="$prefix/share/qemu"
X docdir="$prefix/share/doc/qemu"
X bindir="$prefix/bin"
END-of-files/patch-bd
echo x - files/patch-be
sed 's/^X//' >files/patch-be << 'END-of-files/patch-be'
XIndex: qemu/vl.c
X@@ -666,8 +667,8 @@
X         {
X             struct timeval r;
X             if (!gettimeofday(&r, NULL)) {
X-                return ((CLK_TCK * 1000LL) * (int64_t)r.tv_sec 
X-                      + ((int64_t)r.tv_usec * CLK_TCK) / 1000) / timer_freq;
X+                return ((timer_freq * 1000LL) * (int64_t)r.tv_sec 
X+                      + ((int64_t)r.tv_usec * timer_freq) / 1000) / timer_freq;
X             }
X         }        
X #else
END-of-files/patch-be
echo x - files/patch-bf
sed 's/^X//' >files/patch-bf << 'END-of-files/patch-bf'
XIndex: qemu/slirp/slirp_config.h
X@@ -61,7 +61,7 @@
X #define HAVE_STDLIB_H
X 
X /* Define if you have sys/ioctl.h */
X-#undef HAVE_SYS_IOCTL_H
X+#define HAVE_SYS_IOCTL_H
X 
X /* Define if you have sys/filio.h */
X #undef HAVE_SYS_FILIO_H
X@@ -86,7 +86,7 @@
X #undef BAD_SPRINTF
X 
X /* Define if you have readv */
X-#undef HAVE_READV
X+#define HAVE_READV
X 
X /* Define if iovec needs to be declared */
X #undef DECLARE_IOVEC
X@@ -95,7 +95,7 @@
X #undef DECLARE_SPRINTF
X 
X /* Define if you have a POSIX.1 sys/wait.h */
X-#undef HAVE_SYS_WAIT_H
X+#define HAVE_SYS_WAIT_H
X 
X /* Define if you have sys/select.h */
X #define HAVE_SYS_SELECT_H
X@@ -107,7 +107,7 @@
X #define HAVE_ARPA_INET_H
X 
X /* Define if you have sys/signal.h */
X-#undef HAVE_SYS_SIGNAL_H
X+#define HAVE_SYS_SIGNAL_H
X 
X /* Define if you have sys/stropts.h */
X #undef HAVE_SYS_STROPTS_H
X@@ -162,7 +162,7 @@
X #define HAVE_MEMMOVE
X 
X /* Define if you have <termios.h> */
X-#undef HAVE_TERMIOS_H
X+#define HAVE_TERMIOS_H
X 
X /* Define if you have gethostid */
X #undef HAVE_GETHOSTID
X@@ -180,7 +180,7 @@
X #undef HAVE_GRANTPT
X 
X /* Define if you have fchmod */
X-#undef HAVE_FCHMOD
X+#define HAVE_FCHMOD
X 
X /* Define if you have <sys/type32.h> */
X #undef HAVE_SYS_TYPES32_H
END-of-files/patch-bf
echo x - files/patch-bt
sed 's/^X//' >files/patch-bt << 'END-of-files/patch-bt'
XIndex: qemu/vl.c
X@@ -41,6 +41,9 @@
X #ifdef _BSD
X #include <sys/stat.h>
X #include <libutil.h>
X+#ifdef __FreeBSD__
X+#include <sys/module.h>
X+#endif
X #else
X #include <linux/if.h>
X #include <linux/if_tun.h>
X@@ -1022,6 +1025,34 @@
X 
X #endif /* CONFIG_SLIRP */
X 
X+#ifdef __FreeBSD__
X+#define LOAD_QUIETLY	1
X+#define LOAD_VERBOSLY	2
X+
X+int
X+loadmodules(int how, const char *module, ...)
X+{
X+  int loaded = 0;
X+  va_list ap;
X+
X+  va_start(ap, module);
X+#ifndef NO_MODULES
X+  while (module != NULL) {
X+    if (modfind(module) == -1) {
X+      if (kldload(module) == -1) {
X+        if (how == LOAD_VERBOSLY)
X+          fprintf(stderr, "%s: Cannot load module\n", module);
X+      } else
X+        loaded++;
X+    }
X+    module = va_arg(ap, const char *);
X+  }
X+  va_end(ap);
X+#endif
X+  return loaded;
X+}
X+#endif
X+
X #if !defined(_WIN32)
X #ifdef _BSD
X static int tun_open(char *ifname, int ifname_size)
X@@ -1030,11 +1061,46 @@
X     char *dev;
X     struct stat s;
X 
X+#ifdef __FreeBSD__
X+    int i, kldtried = 0, enoentcount = 0, err = 0;
X+    char dname[100];
X+    for (i = -1; i < 10; i++) {
X+        if (i == -1)
X+	    strcpy(dname, "/dev/tap");
X+        else
X+	    snprintf(dname, sizeof dname, "%s%d",
X+		     "/dev/tap", i);
X+        fd = open(dname, O_RDWR);
X+        if (fd >= 0)
X+            break;
X+        else if (errno == ENXIO || errno == ENOENT) {
X+            if (i == 0 && !kldtried++) {
X+                /*
X+                 * Attempt to load the tunnel interface KLD if it isn't loaded
X+                 * already.
X+                 */
X+                if (loadmodules(LOAD_VERBOSLY, "if_tap", NULL))
X+                    i = -1;
X+                continue;
X+            }
X+            if (errno != ENOENT || ++enoentcount > 3) {
X+                err = errno;
X+	        break;
X+            }
X+        } else
X+            err = errno;
X+    }
X+    if (fd < 0) {
X+        fprintf(stderr, "warning: could not open %s (%s): no virtual network emulation\n", dname, strerror(err));
X+        return -1;
X+    }
X+#else
X     fd = open("/dev/tap", O_RDWR);
X     if (fd < 0) {
X-        fprintf(stderr, "warning: could not open /dev/tap: no virtual network emulation\n");
X+        fprintf(stderr, "warning: could not open /dev/tap (%s): no virtual network emulation\n", strerror(errno));
X         return -1;
X     }
X+#endif
X 
X     fstat(fd, &s);
X     dev = devname(s.st_rdev, S_IFCHR);
END-of-files/patch-bt
exit

>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200406022239.i52Mdfq39643>