Package: qemu Version: 0.11.0-6 Severity: important Tags: patch Hi,
On GNU/kFreeBSD port, QEMU can't access to block devices. I made a small patch that solves this issue and another ones. A problem is that GNU/kFreeBSD is considered in this patch as a flavour of BSD, because the block access and other freatures are kernel-dependant, and setting this options up without the declatarion of HAVE_BSD by configure is very difficult for me, but in my opinion this patch is useful for basic tasks. Sincerely, Javier -- System Information: Debian Release: squeeze/sid APT prefers unstable APT policy: (500, 'unstable'), (500, 'testing'), (1, 'experimental') Architecture: kfreebsd-i386 (i686) Kernel: kFreeBSD 7.2-1-486 Locale: LANG=es_ES.UTF-8, LC_CTYPE=es_ES.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Versions of packages qemu depends on: ii qemu-system 0.11.0-6 QEMU full system emulation binarie ii qemu-utils 0.11.0-6 QEMU utilities qemu recommends no packages. qemu suggests no packages. -- no debconf information
diff -Naur qemu-0.11.0.orig/block/raw-posix.c qemu-0.11.0/block/raw-posix.c --- qemu-0.11.0.orig/block/raw-posix.c 2009-11-28 23:44:57.000000000 +0100 +++ qemu-0.11.0/block/raw-posix.c 2009-11-28 23:49:21.000000000 +0100 @@ -53,7 +53,7 @@ #include <linux/cdrom.h> #include <linux/fd.h> #endif -#ifdef __FreeBSD__ +#ifdef __FreeBSD_kernel__ #include <signal.h> #include <sys/disk.h> #include <sys/cdio.h> @@ -124,7 +124,7 @@ static int fd_open(BlockDriverState *bs); static int64_t raw_getlength(BlockDriverState *bs); -#if defined(__FreeBSD__) +#if defined(__FreeBSD_kernel__) static int cdrom_reopen(BlockDriverState *bs); #endif @@ -781,7 +781,7 @@ int64_t size; #ifdef HOST_BSD struct stat sb; -#ifdef __FreeBSD__ +#ifdef __FreeBSD_kernel__ int reopened = 0; #endif #endif @@ -796,7 +796,7 @@ return ret; #ifdef HOST_BSD -#ifdef __FreeBSD__ +#ifdef __FreeBSD_kernel__ again: #endif if (!fstat(fd, &sb) && (S_IFCHR & sb.st_mode)) { @@ -817,7 +817,7 @@ #else size = lseek(fd, 0LL, SEEK_END); #endif -#ifdef __FreeBSD__ +#ifdef __FreeBSD_kernel__ switch(s->type) { case FTYPE_CD: /* XXX FreeBSD acd returns UINT_MAX sectors for an empty drive */ @@ -1125,7 +1125,7 @@ } #endif -#elif defined(__FreeBSD__) +#elif defined(__FreeBSD_kernel__) static int fd_open(BlockDriverState *bs) { BDRVRawState *s = bs->opaque; @@ -1387,7 +1387,7 @@ }; #endif /* __linux__ */ -#ifdef __FreeBSD__ +#ifdef __FreeBSD_kernel__ static int cdrom_open(BlockDriverState *bs, const char *filename, int flags) { BDRVRawState *s = bs->opaque; @@ -1516,7 +1516,7 @@ bdrv_register(&bdrv_host_floppy); bdrv_register(&bdrv_host_cdrom); #endif -#ifdef __FreeBSD__ +#ifdef __FreeBSD_kernel__ bdrv_register(&bdrv_host_cdrom); #endif } diff -Naur qemu-0.11.0.orig/configure qemu-0.11.0/configure --- qemu-0.11.0.orig/configure 2009-11-28 23:44:56.000000000 +0100 +++ qemu-0.11.0/configure 2009-11-28 23:49:21.000000000 +0100 @@ -233,6 +233,7 @@ audio_possible_drivers="dsound sdl fmod" ;; GNU/kFreeBSD) +bsd="yes" audio_drv_list="oss" audio_possible_drivers="oss sdl esd pa" if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then @@ -343,10 +344,14 @@ if [ "$bsd" = "yes" ] ; then if [ "$darwin" != "yes" ] ; then - make="gmake" + if [ "$targetos" != "GNU/kFreeBSD"] ; then + make="gmake" + fi usb="bsd" fi - bsd_user="yes" + if [ "$targetos" !="GNU/kFreeBSD"]; then + bsd_user="yes" + fi fi # find source path diff -Naur qemu-0.11.0.orig/exec.c qemu-0.11.0/exec.c --- qemu-0.11.0.orig/exec.c 2009-11-28 23:44:56.000000000 +0100 +++ qemu-0.11.0/exec.c 2009-11-28 23:49:21.000000000 +0100 @@ -464,7 +464,7 @@ exit(1); } } -#elif defined(__FreeBSD__) || defined(__DragonFly__) +#elif defined(__FreeBSD_kernel__) || defined(__DragonFly__) { int flags; void *addr = NULL; diff -Naur qemu-0.11.0.orig/fpu/softfloat.h qemu-0.11.0/fpu/softfloat.h --- qemu-0.11.0.orig/fpu/softfloat.h 2009-11-28 23:44:57.000000000 +0100 +++ qemu-0.11.0/fpu/softfloat.h 2009-11-29 00:08:03.000000000 +0100 @@ -90,7 +90,8 @@ #define FLOAT128 #else /* native float support */ -#if (defined(__i386__) || defined(__x86_64__)) && !defined(HOST_BSD) +#if (defined(__i386__) || defined(__x86_64__)) && (!defined(HOST_BSD) || \ + defined(__GLIBC__)) #define FLOATX80 #endif #endif /* !CONFIG_SOFTFLOAT */ diff -Naur qemu-0.11.0.orig/fpu/softfloat-native.c qemu-0.11.0/fpu/softfloat-native.c --- qemu-0.11.0.orig/fpu/softfloat-native.c 2009-11-28 23:44:57.000000000 +0100 +++ qemu-0.11.0/fpu/softfloat-native.c 2009-11-28 23:53:15.000000000 +0100 @@ -9,8 +9,8 @@ void set_float_rounding_mode(int val STATUS_PARAM) { STATUS(float_rounding_mode) = val; -#if defined(HOST_BSD) && !defined(__APPLE__) || \ - (defined(HOST_SOLARIS) && HOST_SOLARIS < 10) +#if defined(HOST_BSD) && !defined(__APPLE__) && !defined(__GLIBC__) \ + || (defined(HOST_SOLARIS) && HOST_SOLARIS < 10) fpsetround(val); #elif defined(__arm__) /* nothing to do */ diff -Naur qemu-0.11.0.orig/fpu/softfloat-native.h qemu-0.11.0/fpu/softfloat-native.h --- qemu-0.11.0.orig/fpu/softfloat-native.h 2009-11-28 23:44:57.000000000 +0100 +++ qemu-0.11.0/fpu/softfloat-native.h 2009-11-28 23:54:21.000000000 +0100 @@ -1,7 +1,8 @@ /* Native implementation of soft float functions */ #include <math.h> -#if (defined(HOST_BSD) && !defined(__APPLE__)) || defined(HOST_SOLARIS) +#if (defined(HOST_BSD) && !defined(__APPLE__) && !defined(__GLIBC__)) || \ + defined(HOST_SOLARIS) #include <ieeefp.h> #define fabsf(f) ((float)fabs(f)) #else @@ -111,7 +112,8 @@ /*---------------------------------------------------------------------------- | Software IEC/IEEE floating-point rounding mode. *----------------------------------------------------------------------------*/ -#if (defined(HOST_BSD) && !defined(__APPLE__)) || defined(HOST_SOLARIS) +#if (defined(HOST_BSD) && !defined(__APPLE__) && !defined(__GLIBC__)) || \ + defined(HOST_SOLARIS) #if defined(__OpenBSD__) #define FE_RM FP_RM #define FE_RP FP_RP diff -Naur qemu-0.11.0.orig/net.c qemu-0.11.0/net.c --- qemu-0.11.0.orig/net.c 2009-11-28 23:44:56.000000000 +0100 +++ qemu-0.11.0/net.c 2009-11-28 23:58:45.000000000 +0100 @@ -56,12 +56,11 @@ #include <sys/stat.h> #if defined(__FreeBSD__) || defined(__DragonFly__) #include <libutil.h> -#else -#include <util.h> -#endif #elif defined (__GLIBC__) && defined (__FreeBSD_kernel__) #include <freebsd/stdlib.h> #else +#include <util.h> +#endif #ifdef __linux__ #include <pty.h> #include <malloc.h> diff -Naur qemu-0.11.0.orig/osdep.c qemu-0.11.0/osdep.c --- qemu-0.11.0.orig/osdep.c 2009-11-28 23:44:56.000000000 +0100 +++ qemu-0.11.0/osdep.c 2009-11-28 23:49:21.000000000 +0100 @@ -95,7 +95,7 @@ #include <sys/types.h> #include <sys/mount.h> #else -#ifndef __FreeBSD__ +#ifndef __FreeBSD_kernel__ #include <sys/vfs.h> #endif #endif @@ -110,7 +110,7 @@ void *ptr; /* no need (?) for a dummy file on OpenBSD/FreeBSD */ -#if defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__DragonFly__) +#if defined(__OpenBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) int map_anon = MAP_ANON; #else int map_anon = 0; @@ -181,7 +181,7 @@ } size = (size + 4095) & ~4095; ftruncate(phys_ram_fd, phys_ram_size + size); -#endif /* !(__OpenBSD__ || __FreeBSD__ || __DragonFly__) */ +#endif /* !(__OpenBSD__ || __FreeBSD_kernel__ || __DragonFly__) */ ptr = mmap(NULL, size, PROT_WRITE | PROT_READ, map_anon | MAP_SHARED, diff -Naur qemu-0.11.0.orig/qemu-char.c qemu-0.11.0/qemu-char.c --- qemu-0.11.0.orig/qemu-char.c 2009-11-28 23:44:53.000000000 +0100 +++ qemu-0.11.0/qemu-char.c 2009-11-28 23:57:02.000000000 +0100 @@ -71,12 +71,13 @@ #include <libutil.h> #include <dev/misc/ppi/ppi.h> #include <bus/ppbus/ppbconf.h> -#else -#include <util.h> -#endif #elif defined (__GLIBC__) && defined (__FreeBSD_kernel__) #include <freebsd/stdlib.h> +#include <dev/ppbus/ppi.h> +#include <dev/ppbus/ppbconf.h> #else +#include <util.h> +#endif #ifdef __linux__ #include <pty.h> @@ -820,7 +821,7 @@ } #endif -#if defined(__linux__) || defined(__sun__) || defined(__FreeBSD__) \ +#if defined(__linux__) || defined(__sun__) || defined(__FreeBSD_kernel__) \ || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) typedef struct { @@ -1297,7 +1298,7 @@ } #endif /* __linux__ */ -#if defined(__FreeBSD__) || defined(__DragonFly__) +#if defined(__FreeBSD_kernel__) || defined(__DragonFly__) static int pp_ioctl(CharDriverState *chr, int cmd, void *arg) { int fd = (int)chr->opaque; @@ -2256,12 +2257,12 @@ if (strstart(filename, "/dev/parport", NULL)) { chr = qemu_chr_open_pp(filename); } else -#elif defined(__FreeBSD__) || defined(__DragonFly__) +#elif defined(__FreeBSD_kernel__) || defined(__DragonFly__) if (strstart(filename, "/dev/ppi", NULL)) { chr = qemu_chr_open_pp(filename); } else #endif -#if defined(__linux__) || defined(__sun__) || defined(__FreeBSD__) \ +#if defined(__linux__) || defined(__sun__) || defined(__FreeBSD_kernel__) \ || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) if (strstart(filename, "/dev/", NULL)) { chr = qemu_chr_open_tty(filename); diff -Naur qemu-0.11.0.orig/savevm.c qemu-0.11.0/savevm.c --- qemu-0.11.0.orig/savevm.c 2009-11-28 23:44:56.000000000 +0100 +++ qemu-0.11.0/savevm.c 2009-11-29 00:00:58.000000000 +0100 @@ -56,12 +56,11 @@ #include <sys/stat.h> #if defined(__FreeBSD__) || defined(__DragonFly__) #include <libutil.h> -#else -#include <util.h> -#endif #elif defined (__GLIBC__) && defined (__FreeBSD_kernel__) #include <freebsd/stdlib.h> #else +#include <util.h> +#endif #ifdef __linux__ #include <pty.h> #include <malloc.h> diff -Naur qemu-0.11.0.orig/usb-bsd.c qemu-0.11.0/usb-bsd.c --- qemu-0.11.0.orig/usb-bsd.c 2009-11-28 23:44:57.000000000 +0100 +++ qemu-0.11.0/usb-bsd.c 2009-11-28 23:49:21.000000000 +0100 @@ -72,7 +72,7 @@ ep = UE_GET_ADDR(ep); if (dev->ep_fd[ep] < 0) { -#if defined(__FreeBSD__) || defined(__DragonFly__) +#if defined(__FreeBSD_kernel__) || defined(__DragonFly__) snprintf(buf, sizeof(buf) - 1, "%s.%d", dev->devpath, ep); #else snprintf(buf, sizeof(buf) - 1, "%s.%02d", dev->devpath, ep); @@ -325,7 +325,7 @@ return NULL; } -#if defined(__FreeBSD__) || defined(__DragonFly__) +#if defined(__FreeBSD_kernel__) || defined(__DragonFly__) snprintf(ctlpath, PATH_MAX, "/dev/%s", bus_info.udi_devnames[0]); #else snprintf(ctlpath, PATH_MAX, "/dev/%s.00", bus_info.udi_devnames[0]); @@ -415,7 +415,7 @@ if (strncmp(bus_info.udi_devnames[0], "ugen", 4) != 0) continue; -#if defined(__FreeBSD__) || defined(__DragonFly__) +#if defined(__FreeBSD_kernel__) || defined(__DragonFly__) snprintf(devbuf, sizeof(devbuf) - 1, "/dev/%s", bus_info.udi_devnames[0]); #else snprintf(devbuf, sizeof(devbuf) - 1, "/dev/%s.00", bus_info.udi_devnames[0]); diff -Naur qemu-0.11.0.orig/vl.c qemu-0.11.0/vl.c --- qemu-0.11.0.orig/vl.c 2009-11-28 23:44:57.000000000 +0100 +++ qemu-0.11.0/vl.c 2009-11-28 23:58:12.000000000 +0100 @@ -60,12 +60,11 @@ #include <sys/stat.h> #if defined(__FreeBSD__) || defined(__DragonFly__) #include <libutil.h> -#else -#include <util.h> -#endif #elif defined (__GLIBC__) && defined (__FreeBSD_kernel__) #include <freebsd/stdlib.h> #else +#include <util.h> +#endif #ifdef __linux__ #include <pty.h> #include <malloc.h> @@ -566,7 +565,7 @@ static void init_get_clock(void) { use_rt_clock = 0; -#if defined(__linux__) || (defined(__FreeBSD__) && __FreeBSD_version >= 500000) \ +#if defined(__GLIBC__) || (defined(__FreeBSD__) && __FreeBSD_version >= 500000) \ || defined(__DragonFly__) { struct timespec ts; @@ -579,7 +578,7 @@ static int64_t get_clock(void) { -#if defined(__linux__) || (defined(__FreeBSD__) && __FreeBSD_version >= 500000) \ +#if defined(__GLIBC__) || (defined(__FreeBSD__) && __FreeBSD_version >= 500000) \ || defined(__DragonFly__) if (use_rt_clock) { struct timespec ts; @@ -4737,7 +4736,7 @@ #endif size_t max_len; -#if defined(__linux__) +#if defined(__linux__) || (defined(__GLIBC__) && defined(__FreeBSD_kernel__)) { int len; len = readlink("/proc/self/exe", buf, sizeof(buf) - 1);