Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 28 Sep 2008 01:04:59 -0300
From:      "Carlos A. M. dos Santos" <unixmania@gmail.com>
To:        qemu-devel@nongnu.org, "Anthony Liguori" <anthony@codemonkey.ws>,  freebsd-emulation@freebsd.org
Subject:   Re: [Qemu-devel] Re: qemu svn r5281 on FreeBSD - slow usb, vmwarevga, screen updates... (now updated to r5331)
Message-ID:  <e71790db0809272104p1b3f383epb753fff72bb6f101@mail.gmail.com>
In-Reply-To: <20080927204729.GA52209@saturn.kn-bremen.de>
References:  <20080921204025.GA81055@saturn.kn-bremen.de> <cd6b4a5b0809230639x27e94477k315796c2cfb650f2@mail.gmail.com> <200809242210.m8OMAcSZ021572@saturn.kn-bremen.de> <cd6b4a5b0809241954p159dd86u17fdc2a485008e7d@mail.gmail.com> <48DCF9FC.2070708@codemonkey.ws> <20080926220445.GA13099@saturn.kn-bremen.de> <20080927204729.GA52209@saturn.kn-bremen.de>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, Sep 27, 2008 at 5:47 PM, Juergen Lock <nox@jelal.kn-bremen.de> wrote:
> On Sat, Sep 27, 2008 at 12:04:45AM +0200, I wrote:
>>[...]
>>  I'll see if I can prepare another update over the weekend and then go
>> thru more of the patches that have accumulated in the port...
>
> OK, here we go :)  First the update: (at r5331 now)
>        http://people.freebsd.org/~nox/qemu/qemu-devel-20080927.patch
>
> 1. FreeBSD also has clock_gettime:
>
> Index: qemu/vl.c
> @@ -541,7 +541,7 @@
>  static void init_get_clock(void)
>  {
>     use_rt_clock = 0;
> -#if defined(__linux__)
> +#if defined(__linux__) || (defined(__FreeBSD__) && __FreeBSD_version >= 500000)
>     {
>         struct timespec ts;
>         if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0) {
> @@ -553,7 +553,7 @@
>
>  static int64_t get_clock(void)
>  {
> -#if defined(__linux__)
> +#if defined(__linux__) || (defined(__FreeBSD__) && __FreeBSD_version >= 500000)
>     if (use_rt_clock) {
>         struct timespec ts;
>         clock_gettime(CLOCK_MONOTONIC, &ts);
>
> 2. open() can also return EPERM for O_RDWR on a readonly device (I think
> the case where this happened was a cdrom:)
>
> Index: qemu/block.c
> @@ -381,7 +381,7 @@
>     else
>         open_flags = flags & ~(BDRV_O_FILE | BDRV_O_SNAPSHOT);
>     ret = drv->bdrv_open(bs, filename, open_flags);
> -    if (ret == -EACCES && !(flags & BDRV_O_FILE)) {
> +    if ((ret == -EACCES || ret == -EPERM) && !(flags & BDRV_O_FILE)) {
>         ret = drv->bdrv_open(bs, filename, BDRV_O_RDONLY);
>         bs->read_only = 1;
>     }
>
> 3. the following bugfix is needed at least for FreeBSD/amd64 guests:
> (original patch from
>        http://www.nabble.com/-PATCH--i386-hard-interrupt-generation-bug-fix-p14921171.html
> )
>
> Index: qemu/cpu-exec.c
> @@ -394,16 +394,18 @@
>                                      (env->eflags & IF_MASK &&
>                                       !(env->hflags & HF_INHIBIT_IRQ_MASK))))) {
>                             int intno;
> -                            svm_check_intercept(SVM_EXIT_INTR);
>                             env->interrupt_request &= ~(CPU_INTERRUPT_HARD | CPU_INTERRUPT_VIRQ);
>                             intno = cpu_get_pic_interrupt(env);
> -                            if (loglevel & CPU_LOG_TB_IN_ASM) {
> -                                fprintf(logfile, "Servicing hardware INT=0x%02x\n", intno);
> +                            if (intno>=0) {
> +                                svm_check_intercept(SVM_EXIT_INTR);
> +                                if (loglevel & CPU_LOG_TB_IN_ASM) {
> +                                    fprintf(logfile, "Servicing hardware INT=0x%02x\n", intno);
> +                                }
> +                                do_interrupt(intno, 0, 0, 0, 1);
> +                                /* ensure that no TB jump will be modified as
> +                                   the program flow was changed */
> +                                next_tb = 0;
>                             }
> -                            do_interrupt(intno, 0, 0, 0, 1);
> -                            /* ensure that no TB jump will be modified as
> -                               the program flow was changed */
> -                            next_tb = 0;
>  #if !defined(CONFIG_USER_ONLY)
>                         } else if ((interrupt_request & CPU_INTERRUPT_VIRQ) &&
>                                    (env->eflags & IF_MASK) &&
>
> 4. this is also needed for (some?) amd64 guests on i386 hosts:
>
> Index: qemu/exec-all.h
> @@ -30,7 +30,7 @@
>  struct TranslationBlock;
>
>  /* XXX: make safe guess about sizes */
> -#define MAX_OP_PER_INSTR 64
> +#define MAX_OP_PER_INSTR 128 /* 64 */
>  /* A Call op needs up to 6 + 2N parameters (N = number of arguments).  */
>  #define MAX_OPC_PARAM 10
>  #define OPC_BUF_SIZE 512
>
> 5. no need (?) for a dummy file on FreeBSD too: (like on OpenBSD)
>
> Index: qemu/osdep.c
> @@ -75,8 +75,10 @@
>  #include <sys/types.h>
>  #include <sys/mount.h>
>  #else
> +#ifndef __FreeBSD__
>  #include <sys/vfs.h>
>  #endif
> +#endif
>
>  #include <sys/mman.h>
>  #include <fcntl.h>
> @@ -87,7 +87,7 @@
>     static int phys_ram_size = 0;
>     void *ptr;
>
> -#ifdef __OpenBSD__ /* no need (?) for a dummy file on OpenBSD */
> +#if defined(__OpenBSD__) || defined(__FreeBSD__) /* no need (?) for a dummy file on OpenBSD/FreeBSD */
>     int map_anon = MAP_ANON;
>  #else
>     int map_anon = 0;
> @@ -154,7 +154,7 @@
>     }
>     size = (size + 4095) & ~4095;
>     ftruncate(phys_ram_fd, phys_ram_size + size);
> -#endif /* !__OpenBSD__ */
> +#endif /* !(__OpenBSD__ || __FreeBSD__) */
>     ptr = mmap(NULL,
>                size,
>                PROT_WRITE | PROT_READ, map_anon | MAP_SHARED,
>
> 6. correct lib search path on FreeBSD/amd64 hosts (tho this needs to be
> conditionally applied if its to go into qemu svn:)
>
> Index: qemu/x86_64.ld
> @@ -2,7 +2,7 @@
>  OUTPUT_FORMAT("elf64-x86-64", "elf64-x86-64", "elf64-x86-64")
>  OUTPUT_ARCH(i386:x86-64)
>  ENTRY(_start)
> -SEARCH_DIR("/lib64"); SEARCH_DIR("/usr/lib64"); SEARCH_DIR("/usr/local/lib64");
> +SEARCH_DIR("/lib"); SEARCH_DIR("/usr/lib"); SEARCH_DIR("/usr/local/lib");
>  SECTIONS
>  {
>   /* Read-only sections, merged into text segment: */
>
>  I think thats it for now...  more maybe later.
>        Juergen
>
> Signed-off-by: Juergen Lock <nox@jelal.kn-bremen.de>

I suggest applying the following patch (on top of yours). It includes
options to build additional sound emulators.

--- Makefile.orig	2008-09-28 00:11:29.000000000 -0300
+++ Makefile	2008-09-28 00:53:03.000000000 -0300
@@ -38,6 +38,10 @@
 		GNUTLS "gnutls dependency (vnc encryption)" On \
 		PCAP "pcap dependency (networking with bpf)" On \
 		CDROM_DMA "IDE CDROM DMA" On \
+		AC97 "Intel 82801AA AC97 sound card" Off \
+		ADLIB "Adlib card with Yamaha YM3812 (OPL2) chip" Off \
+		CS4231A "CS4231A sound card (Windows Sound System)" Off \
+		GUS "Gravis Ultrasound GF1 sound card" Off \
 		ALL_TARGETS "Also build dyngen targets (requires gcc34)" On

 .include <bsd.port.pre.mk>
@@ -76,6 +80,35 @@
 CONFIGURE_ARGS+=	--enable-pcap
 .endif

+.if defined(WITH_AC97)
+AUDIO_CARD_LIST=	ac97
+.endif
+
+.if defined(WITH_ADLIB)
+.if defined(AUDIO_CARD_LIST)
+AUDIO_CARD_LIST+=	,
+.endif
+AUDIO_CARD_LIST+=	adlib
+.endif
+
+.if defined(WITH_CS4231A)
+.if defined(AUDIO_CARD_LIST)
+AUDIO_CARD_LIST+=	,
+.endif
+AUDIO_CARD_LIST+=	cs4231a
+.endif
+
+.if defined(WITH_GUS)
+.if defined(AUDIO_CARD_LIST)
+AUDIO_CARD_LIST+=	,
+.endif
+AUDIO_CARD_LIST+=	gus
+.endif
+
+.if defined(AUDIO_CARD_LIST)
+CONFIGURE_ARGS+=	--audio-card-list="${AUDIO_CARD_LIST}"
+.endif
+
 .if defined(WITH_SAMBA)
 RUN_DEPENDS+=	${LOCALBASE}/sbin/smbd:${PORTSDIR}/net/samba3
 .endif

Signed-off-by: Carlos Santos <unixmania@gmail.com>

-- 
cd /usr/ports/sysutils/life
make clean



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