qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] Running QEMU on FreeBSD
@ 2004-05-29 21:25 Antony T Curtis
  2004-05-29 21:39 ` Bartosz Fabianowski
  0 siblings, 1 reply; 32+ messages in thread
From: Antony T Curtis @ 2004-05-29 21:25 UTC (permalink / raw)
  To: qemu-devel

Hi guys,

I have managed to make QEMU 5.5 (downloaded tarball from web site) and
have successfully made it compile and run on FreeBSD-5-CURRENT

However, the problem I have is that the QEMU window does not update and
to see what is on the 'screen', I have to do a screendump and examine
the image file - obviously non-optimal. So far, I have successfully run
the freedos sample image.

I have not managed to make QEMU compile under FreeBSD 4.9 ... The system
compiler (GCC 2.95) does not understand many of the constructs used in
the source.

-- 
Antony T Curtis <antony.t.curtis@ntlworld.com>

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [Qemu-devel] Running QEMU on FreeBSD
  2004-05-29 21:25 [Qemu-devel] Running QEMU on FreeBSD Antony T Curtis
@ 2004-05-29 21:39 ` Bartosz Fabianowski
  2004-05-29 21:50   ` Antony T Curtis
  0 siblings, 1 reply; 32+ messages in thread
From: Bartosz Fabianowski @ 2004-05-29 21:39 UTC (permalink / raw)
  To: qemu-devel

> However, the problem I have is that the QEMU window does not update
> and to see what is on the 'screen'

Maybe you should give the CVS version a try. I am also running FreeBSD 5
-CURRENT and it works beautifully for me. Actually, I have just
installed Windows XP inside QEMU on FreeBSD. However, you will probably
need to apply the patch I posted to the list earlier today in order to
make the CVS version compile on FreeBSD.

> The system compiler (GCC 2.95) does not understand many of the
> constructs used in the source.

I don't believe QEMU can be compiled with GCC 2.x at all. That line of 
GCC is just too broken. However, on FreeBSD 4.x you can still use the 
lang/gcc32, lang/gcc33, or lang/gcc34 port if you want to try compiling 
QEMU with GCC 3.x. Though, frankly, I don't see much point in wasting 
time on that. FreeBSD 5.x is the future ;).

Regards,
- Bartosz Fabianowski

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [Qemu-devel] Running QEMU on FreeBSD
  2004-05-29 21:39 ` Bartosz Fabianowski
@ 2004-05-29 21:50   ` Antony T Curtis
  2004-05-29 21:58     ` Bartosz Fabianowski
  0 siblings, 1 reply; 32+ messages in thread
From: Antony T Curtis @ 2004-05-29 21:50 UTC (permalink / raw)
  To: qemu-devel

On Sat, 2004-05-29 at 22:39, Bartosz Fabianowski wrote:
> > However, the problem I have is that the QEMU window does not update
> > and to see what is on the 'screen'
> 
> Maybe you should give the CVS version a try. I am also running FreeBSD 5
> -CURRENT and it works beautifully for me. Actually, I have just
> installed Windows XP inside QEMU on FreeBSD. However, you will probably
> need to apply the patch I posted to the list earlier today in order to
> make the CVS version compile on FreeBSD.

Actually, I found the problem (a bit of debug code I left behind) and
QEMU is now working well :) .

I only just subscribed to the list so ... I haven't seen your patches
yet... Ho hum... duplication of effort I think... I even put in code to
use the if_tap interface, but so far it's untested.

Does the version in CVS offer much more than the 0.5.5 I downloaded and
built from?

And one of the things I am interested in doing is having a working OS/2
on my P4 laptop (OS/2 doesn't install on it) and maybe booting the XP
partition from FreeBSD.

> > The system compiler (GCC 2.95) does not understand many of the
> > constructs used in the source.
> 
> I don't believe QEMU can be compiled with GCC 2.x at all. That line of 
> GCC is just too broken. However, on FreeBSD 4.x you can still use the 
> lang/gcc32, lang/gcc33, or lang/gcc34 port if you want to try compiling 
> QEMU with GCC 3.x. Though, frankly, I don't see much point in wasting 
> time on that. FreeBSD 5.x is the future ;).

Well - I have most of it compiling on FreeBSD 4.9 already... but I'm
going to try with gcc33 on 4 soon (as soon as the gcc33 port finishes
building maybe)

Thanks anyways
-- 
Antony T Curtis <antony.t.curtis@ntlworld.com>

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [Qemu-devel] Running QEMU on FreeBSD
  2004-05-29 21:50   ` Antony T Curtis
@ 2004-05-29 21:58     ` Bartosz Fabianowski
  2004-05-29 22:09       ` Antony T Curtis
  0 siblings, 1 reply; 32+ messages in thread
From: Bartosz Fabianowski @ 2004-05-29 21:58 UTC (permalink / raw)
  To: qemu-devel

> I even put in code to use the if_tap interface, but so far it's 
> untested.

It's all in CVS already ;). There was a set of patches posted in March
and then updated in April I think that got committed recently. It was in
the list's archive, but for some reason the archive vanished this morning.

> Does the version in CVS offer much more than the 0.5.5 I downloaded 
> and built from?

It has most FreeBSD patches built in. It has some bug fixes. It allows
you to install FreeBSD inside QEMU. Quite cool.

> And one of the things I am interested in doing is having a working 
> OS/2 on my P4 laptop (OS/2 doesn't install on it) and maybe booting 
> the XP partition from FreeBSD.

XP works inside QEMU, I can confirm that. But some of the Windows
updates didn't want to install. No clue why. Another problem is that
because there is no long double type in FreeBSD yet, the FPU emulation
is a bit hackish and you get stuff like this:

http://www.fabianowski.de/long_double.png

Best regards,
- Bartosz Fabianowski

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [Qemu-devel] Running QEMU on FreeBSD
  2004-05-29 21:58     ` Bartosz Fabianowski
@ 2004-05-29 22:09       ` Antony T Curtis
  2004-05-29 22:24         ` Bartosz Fabianowski
  0 siblings, 1 reply; 32+ messages in thread
From: Antony T Curtis @ 2004-05-29 22:09 UTC (permalink / raw)
  To: qemu-devel

On Sat, 2004-05-29 at 22:58, Bartosz Fabianowski wrote:
> > I even put in code to use the if_tap interface, but so far it's 
> > untested.
> 
> It's all in CVS already ;). There was a set of patches posted in March
> and then updated in April I think that got committed recently. It was in
> the list's archive, but for some reason the archive vanished this morning.
> 
> > Does the version in CVS offer much more than the 0.5.5 I downloaded 
> > and built from?
> 
> It has most FreeBSD patches built in. It has some bug fixes. It allows
> you to install FreeBSD inside QEMU. Quite cool.

I'll have to check it out then :)

> > And one of the things I am interested in doing is having a working 
> > OS/2 on my P4 laptop (OS/2 doesn't install on it) and maybe booting 
> > the XP partition from FreeBSD.
> 
> XP works inside QEMU, I can confirm that. But some of the Windows
> updates didn't want to install. No clue why. Another problem is that
> because there is no long double type in FreeBSD yet, the FPU emulation
> is a bit hackish and you get stuff like this:
> 
> http://www.fabianowski.de/long_double.png

Hmm... gcc 3.3 does support long doubles...

I pulled in some code from Linux for the missing long double
functions... So in theory, the binary I have does have long double
support ;)

> Best regards,
> - Bartosz Fabianowski
> 
> 
> _______________________________________________
> Qemu-devel mailing list
> Qemu-devel@nongnu.org
> http://lists.nongnu.org/mailman/listinfo/qemu-devel
>  FLAGS (\Recent \Seen))
-- 

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [Qemu-devel] Running QEMU on FreeBSD
  2004-05-29 22:09       ` Antony T Curtis
@ 2004-05-29 22:24         ` Bartosz Fabianowski
  2004-05-29 23:09           ` Antony T Curtis
  0 siblings, 1 reply; 32+ messages in thread
From: Bartosz Fabianowski @ 2004-05-29 22:24 UTC (permalink / raw)
  To: qemu-devel

> I pulled in some code from Linux for the missing long double
> functions... So in theory, the binary I have does have long double
> support ;)

Nice one. As far as I can tell from various mailing lists and bug 
reports, somebody is working on adding the long double rounding 
functions to FreeBSD's libc. Of course, they won't be able to use code 
from Linux due to licensing issues. So until that work is finished, 
maybe you could submit your patches so somebody could commit it to QEMU? 
I'd love to have long doubles in QEMU and don't want to duplicate your work.

Regards,
- Bartosz Fabianowski

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [Qemu-devel] Running QEMU on FreeBSD
  2004-05-29 22:24         ` Bartosz Fabianowski
@ 2004-05-29 23:09           ` Antony T Curtis
  2004-05-30  3:53             ` Antony T Curtis
  2004-05-30  7:25             ` Markus Niemistö
  0 siblings, 2 replies; 32+ messages in thread
From: Antony T Curtis @ 2004-05-29 23:09 UTC (permalink / raw)
  To: qemu-devel

On Sat, 2004-05-29 at 23:24, Bartosz Fabianowski wrote:
> > I pulled in some code from Linux for the missing long double
> > functions... So in theory, the binary I have does have long double
> > support ;)
> 
> Nice one. As far as I can tell from various mailing lists and bug 
> reports, somebody is working on adding the long double rounding 
> functions to FreeBSD's libc. Of course, they won't be able to use code 
> from Linux due to licensing issues. So until that work is finished, 
> maybe you could submit your patches so somebody could commit it to QEMU? 
> I'd love to have long doubles in QEMU and don't want to duplicate your work.

Sure... I'll generate some diffs soon...
Meanwhile, I've done a few more mods so that QEMU can use FreeBSD's
devices... so that I can specify put "-cdrom /dev/cdrom" on the command
line - successfully booted off a FreeBSD install cdrom :D

Haven't successfully booted the XP partition, it hangs but I think it
could be down to partitionmagic doing something odd.

qemu-mkcow has also been amended to cope with devices in FreeBSD...

> Regards,
> - Bartosz Fabianowski
> 
> 
> _______________________________________________
> Qemu-devel mailing list
> Qemu-devel@nongnu.org
> http://lists.nongnu.org/mailman/listinfo/qemu-devel
>  FLAGS (\Recent \Seen))
-- 

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [Qemu-devel] Running QEMU on FreeBSD
  2004-05-29 23:09           ` Antony T Curtis
@ 2004-05-30  3:53             ` Antony T Curtis
  2004-05-30  7:25             ` Markus Niemistö
  1 sibling, 0 replies; 32+ messages in thread
From: Antony T Curtis @ 2004-05-30  3:53 UTC (permalink / raw)
  To: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 1065 bytes --]

On Sun, 2004-05-30 at 00:09, Antony T Curtis wrote:
> On Sat, 2004-05-29 at 23:24, Bartosz Fabianowski wrote:
> > > I pulled in some code from Linux for the missing long double
> > > functions... So in theory, the binary I have does have long double
> > > support ;)
> > 
> > Nice one. As far as I can tell from various mailing lists and bug 
> > reports, somebody is working on adding the long double rounding 
> > functions to FreeBSD's libc. Of course, they won't be able to use code 
> > from Linux due to licensing issues. So until that work is finished, 
> > maybe you could submit your patches so somebody could commit it to QEMU? 
> > I'd love to have long doubles in QEMU and don't want to duplicate your work.
> 
> Sure... I'll generate some diffs soon...

I have checked out te code from CVS and I am integrating my changes.

Attached is my FreeBSD diffs... (includes your diff) 

More to come soon - including my diffs to enable using device nodes
directly instead of files for hard drives and cdroms.
-- 
Antony T Curtis <antony.t.curtis@ntlworld.com>

[-- Attachment #2: qemu-freebsd.patch --]
[-- Type: text/x-patch, Size: 9662 bytes --]

diff -BcNpPr --exclude=CVS /home/antony/cvs/qemu/Makefile qemu-0.5.5/Makefile
*** /home/antony/cvs/qemu/Makefile	Mon May 17 21:06:42 2004
--- qemu-0.5.5/Makefile	Sun May 30 05:26:19 2004
*************** TAGS: 
*** 70,76 ****
  
  # documentation
  %.html: %.texi
! 	texi2html -monolithic -number $<
  
  qemu.1: qemu-doc.texi
  	./texi2pod.pl $< qemu.pod
--- 70,76 ----
  
  # documentation
  %.html: %.texi
! 	-texi2html -monolithic -number $<
  
  qemu.1: qemu-doc.texi
  	./texi2pod.pl $< qemu.pod
diff -BcNpPr --exclude=CVS /home/antony/cvs/qemu/configure qemu-0.5.5/configure
*** /home/antony/cvs/qemu/configure	Thu May 20 14:23:39 2004
--- qemu-0.5.5/configure	Sun May 30 05:42:05 2004
*************** echo "TARGET_DIRS=$target_list" >> $conf
*** 419,427 ****
--- 419,429 ----
  if [ "$bsd" = "yes" ] ; then
    echo "#define O_LARGEFILE 0" >> $config_h
    echo "#define lseek64 lseek" >> $config_h
+   echo "#define mkstemp64 mkstemp" >> $config_h
    echo "#define ftruncate64 ftruncate" >> $config_h
    echo "#define MAP_ANONYMOUS MAP_ANON" >> $config_h
    echo "#define _BSD 1" >> $config_h
+   echo "#define off64_t off_t" >> $config_h
  fi
  
  for target in $target_list; do 
diff -BcNpPr --exclude=CVS /home/antony/cvs/qemu/target-i386/cpu.h qemu-0.5.5/target-i386/cpu.h
*** /home/antony/cvs/qemu/target-i386/cpu.h	Thu May 20 15:01:56 2004
--- qemu-0.5.5/target-i386/cpu.h	Sun May 30 05:16:10 2004
*************** enum {
*** 259,265 ****
      CC_OP_NB,
  };
  
! #if (defined(__i386__) || defined(__x86_64__)) && !defined(_BSD)
  #define USE_X86LDOUBLE
  #endif
  
--- 259,265 ----
      CC_OP_NB,
  };
  
! #if defined(__i386__) || defined(__x86_64__)
  #define USE_X86LDOUBLE
  #endif
  
diff -BcNpPr --exclude=CVS /home/antony/cvs/qemu/target-i386/exec.h qemu-0.5.5/target-i386/exec.h
*** /home/antony/cvs/qemu/target-i386/exec.h	Sat May 29 12:08:52 2004
--- qemu-0.5.5/target-i386/exec.h	Sun May 30 05:19:43 2004
*************** static inline void stfl(void *ptr, float
*** 293,298 ****
--- 293,314 ----
  
  #endif /* !defined(CONFIG_USER_ONLY) */
  
+ #if defined(_BSD) && defined(USE_X86LDOUBLE)
+ #include <math.h>
+ /*int rintl(long double __x);
+ long int lrintl(long double __x);
+ long long int llrintl(long double __x);
+ long double powl(long double __x, long double __y);
+ long double logl(long double __x);
+ long double tanl(long double __x);
+ long double atan2l(long double __y, long double __x);
+ long double ceill(long double __x);
+ long double floorl(long double __x);
+ long double sqrtl(long double __x);
+ long double sinl(long double __x);
+ long double cosl(long double __x);*/
+ #endif
+ 
  #ifdef USE_X86LDOUBLE
  /* use long double functions */
  #define lrint lrintl
*************** static inline void stfl(void *ptr, float
*** 310,316 ****
  #define rint rintl
  #endif
  
! #if !defined(_BSD)
  extern int lrint(CPU86_LDouble x);
  extern int64_t llrint(CPU86_LDouble x);
  #else
--- 326,332 ----
  #define rint rintl
  #endif
  
! #if !defined(_BSD) || defined(USE_X86LDOUBLE)
  extern int lrint(CPU86_LDouble x);
  extern int64_t llrint(CPU86_LDouble x);
  #else
diff -BcNpPr --exclude=CVS /home/antony/cvs/qemu/target-i386/op.c qemu-0.5.5/target-i386/op.c
*** /home/antony/cvs/qemu/target-i386/op.c	Sat May 29 12:08:52 2004
--- qemu-0.5.5/target-i386/op.c	Sun May 30 05:40:54 2004
*************** CCTable cc_table[CC_OP_NB] = {
*** 1304,1309 ****
--- 1304,1452 ----
     functions comes from the LGPL'ed x86 emulator found in the Willows
     TWIN windows emulator. */
  
+ #if defined(_BSD) && defined(USE_X86LDOUBLE)
+ 
+ CPU86_LDouble rintl(CPU86_LDouble __x) {
+   CPU86_LDouble __rintres;
+   __asm__ __volatile__
+     ("fistp %0"
+      : "=m" (__rintres) : "t" (__x) : "st");
+   return __rintres;
+ }
+ 
+ int lrintl(CPU86_LDouble __x) {
+   int __lrintres;
+   __asm__ __volatile__
+     ("fistpl %0"
+      : "=m" (__lrintres) : "t" (__x) : "st");
+   return __lrintres;
+ }
+ 
+ 
+ int64_t llrintl(CPU86_LDouble __x) {
+   int64_t __llrintres;
+   __asm__ __volatile__
+     ("fistpll %0"
+      : "=m" (__llrintres) : "t" (__x) : "st");
+   return __llrintres;
+ }
+ 
+ CPU86_LDouble powl(CPU86_LDouble __x, CPU86_LDouble __y) {
+   register CPU86_LDouble __value;
+   register long double __exponent;
+   __extension__ long long int __p = (long long int) __y;
+   if (__x == 0.0)
+     {
+        if (__y > 0.0)
+          return __y == (double) __p && (__p & 1) != 0 ? __x : 0.0;
+        else if (__y < 0.0)
+          return (__y == (double) __p && (-__p & 1) != 0
+                  ? 1.0 / __x : 1.0 / fabs (__x));
+     }
+   if (__y == (double) __p)
+     {
+       long double __r = 1.0;
+       if (__p == 0)
+         return 1.0;
+       if (__p < 0)
+         {
+           __p = -__p;
+           __x = 1.0 / __x;
+         }
+       while (1)
+         {
+           if (__p & 1)
+             __r *= __x;
+           __p >>= 1;
+           if (__p == 0)
+             return __r;
+           __x *= __x;
+         }
+       /* NOTREACHED */
+     }
+   __asm __volatile__
+     ("fyl2x" : "=t" (__value) : "0" (__x), "u" (1.0) : "st(1)");
+   __asm __volatile__
+     ("fmul      %%st(1)         # y * log2(x)\n\t"
+      "fst       %%st(1)\n\t"
+      "frndint                   # int(y * log2(x))\n\t"
+      "fxch\n\t"
+      "fsub      %%st(1)         # fract(y * log2(x))\n\t"
+      "f2xm1                     # 2^(fract(y * log2(x))) - 1\n\t"
+      : "=t" (__value), "=u" (__exponent) : "0" (__y), "1" (__value));
+   __value += 1.0;
+   __asm __volatile__
+     ("fscale"
+      : "=t" (__value) : "0" (__value), "u" (__exponent));
+   return __value;
+ }
+ 
+ CPU86_LDouble logl(CPU86_LDouble __x) {
+   register CPU86_LDouble __result;
+   __asm __volatile__ ("fldln2; fxch; fyl2x" : "=t" (__result) : "0" (__x) : "st(1)");
+   return __result;
+ }
+ 
+ CPU86_LDouble tanl(CPU86_LDouble __x) {
+   register CPU86_LDouble __value;
+   register CPU86_LDouble __value2 __attribute__ ((__unused__));
+   __asm __volatile__
+     ("fptan"
+      : "=t" (__value2), "=u" (__value) : "0" (__x));
+   return __value;
+ }
+ 
+ CPU86_LDouble atan2l(CPU86_LDouble __y, CPU86_LDouble __x) {
+   register CPU86_LDouble __value;
+   __asm __volatile__
+     ("fpatan"
+      : "=t" (__value) : "0" (__x), "u" (__y) : "st(1)");
+   return __value;
+ }
+ 
+ CPU86_LDouble ceill(CPU86_LDouble __x) {
+   register CPU86_LDouble __value;
+   __volatile unsigned short int __cw;
+   __volatile unsigned short int __cwtmp;
+   __asm __volatile ("fnstcw %0" : "=m" (__cw));
+   __cwtmp = (__cw & 0xf3ff) | 0x0800; /* rounding up */
+   __asm __volatile ("fldcw %0" : : "m" (__cwtmp));
+   __asm __volatile ("frndint" : "=t" (__value) : "0" (__x));
+   __asm __volatile ("fldcw %0" : : "m" (__cw));
+   return __value;
+ }
+ 
+ CPU86_LDouble floorl(CPU86_LDouble __x) {
+   register CPU86_LDouble __value;
+   __volatile unsigned short int __cw;
+   __volatile unsigned short int __cwtmp;
+   __asm __volatile ("fnstcw %0" : "=m" (__cw));
+   __cwtmp = (__cw & 0xf3ff) | 0x0400; /* rounding down */
+   __asm __volatile ("fldcw %0" : : "m" (__cwtmp));
+   __asm __volatile ("frndint" : "=t" (__value) : "0" (__x));
+   __asm __volatile ("fldcw %0" : : "m" (__cw));
+   return __value;
+ }
+ 
+ CPU86_LDouble sqrtl(CPU86_LDouble __x) {
+   register CPU86_LDouble __result;
+   __asm __volatile__ ("fsqrt" : "=t" (__result) : "0" (__x));
+   return __result;
+ }
+ 
+ CPU86_LDouble sinl(CPU86_LDouble __x) {
+   register CPU86_LDouble __result;
+   __asm __volatile__ ("fsin" : "=t" (__result) : "0" (__x));
+   return __result;
+ }
+ 
+ CPU86_LDouble cosl(CPU86_LDouble __x) {
+   register CPU86_LDouble __result;
+   __asm __volatile__ ("fcos" : "=t" (__result) : "0" (__x));
+   return __result;
+ }
+ #endif
+ 
  #if defined(__powerpc__)
  extern CPU86_LDouble copysign(CPU86_LDouble, CPU86_LDouble);
  
diff -BcNpPr --exclude=CVS /home/antony/cvs/qemu/vl.c qemu-0.5.5/vl.c
*** /home/antony/cvs/qemu/vl.c	Wed May 26 23:12:06 2004
--- qemu-0.5.5/vl.c	Sun May 30 05:30:56 2004
*************** int64_t qemu_get_clock(QEMUClock *clock)
*** 662,667 ****
--- 662,675 ----
      case QEMU_TIMER_REALTIME:
  #ifdef _WIN32
          return GetTickCount();
+ #elif defined(_BSD)
+         {
+             struct timeval r;
+             if (!gettimeofday(&r, NULL)) {
+                 return ((CLK_TCK * 1000LL) * (int64_t)r.tv_sec 
+                       + ((int64_t)r.tv_usec * CLK_TCK) / 1000) / timer_freq;
+             }
+         }        
  #else
          {
              struct tms tp;
*************** static void init_timers(void)
*** 828,833 ****
--- 836,842 ----
             the emulated kernel requested a too high timer frequency */
          getitimer(ITIMER_REAL, &itv);
  
+ #if defined(__linux__)
          if (itv.it_interval.tv_usec > 1000) {
              /* try to use /dev/rtc to have a faster timer */
              if (start_rtc_timer() < 0)
*************** static void init_timers(void)
*** 843,849 ****
              sigaction(SIGIO, &act, NULL);
              fcntl(rtc_fd, F_SETFL, O_ASYNC);
              fcntl(rtc_fd, F_SETOWN, getpid());
!         } else {
          use_itimer:
              pit_min_timer_count = ((uint64_t)itv.it_interval.tv_usec * 
                                     PIT_FREQ) / 1000000;
--- 852,860 ----
              sigaction(SIGIO, &act, NULL);
              fcntl(rtc_fd, F_SETFL, O_ASYNC);
              fcntl(rtc_fd, F_SETOWN, getpid());
!         } else 
! #endif
!         {
          use_itimer:
              pit_min_timer_count = ((uint64_t)itv.it_interval.tv_usec * 
                                     PIT_FREQ) / 1000000;

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [Qemu-devel] Running QEMU on FreeBSD
  2004-05-29 23:09           ` Antony T Curtis
  2004-05-30  3:53             ` Antony T Curtis
@ 2004-05-30  7:25             ` Markus Niemistö
  2004-05-30  9:50               ` Antony T Curtis
  1 sibling, 1 reply; 32+ messages in thread
From: Markus Niemistö @ 2004-05-30  7:25 UTC (permalink / raw)
  To: qemu-devel

On Sun, 30 May 2004 00:09:16 +0100
Antony T Curtis <antony.t.curtis@ntlworld.com> wrote:

> Sure... I'll generate some diffs soon...
> Meanwhile, I've done a few more mods so that QEMU can use FreeBSD's
> devices... so that I can specify put "-cdrom /dev/cdrom" on the
> command line - successfully booted off a FreeBSD install cdrom :D

The patch you sent doesn't deal with these issues, right? Could you
please make a patch and send it to the list. I've occasionally tried to
fix using devices but the patches I've made worked only partially.

Was the problem with CDs due to qemu not reading 2048 blocks or was
there something else?

Thanks,
	Markus

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [Qemu-devel] Running QEMU on FreeBSD
  2004-05-30  7:25             ` Markus Niemistö
@ 2004-05-30  9:50               ` Antony T Curtis
  2004-05-30 14:41                 ` Bartosz Fabianowski
  0 siblings, 1 reply; 32+ messages in thread
From: Antony T Curtis @ 2004-05-30  9:50 UTC (permalink / raw)
  To: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 1011 bytes --]

On Sun, 2004-05-30 at 08:25, Markus Niemistö wrote:
> On Sun, 30 May 2004 00:09:16 +0100
> Antony T Curtis <antony.t.curtis@ntlworld.com> wrote:
> 
> > Sure... I'll generate some diffs soon...
> > Meanwhile, I've done a few more mods so that QEMU can use FreeBSD's
> > devices... so that I can specify put "-cdrom /dev/cdrom" on the
> > command line - successfully booted off a FreeBSD install cdrom :D
> 
> The patch you sent doesn't deal with these issues, right? Could you
> please make a patch and send it to the list. I've occasionally tried to
> fix using devices but the patches I've made worked only partially.
> 
> Was the problem with CDs due to qemu not reading 2048 blocks or was
> there something else?

Here is the diffs I am using... What it fixes is the following...

It uses the FreeBSD ioctls to determine the size of the device and when
reading the 'header', it reads 2048 bytes. 

A similar fix has to be done to qemu-mkcow for it to work.
-- 
Antony T Curtis <antony.t.curtis@ntlworld.com>

[-- Attachment #2: qemu-blk-fbsd.patch --]
[-- Type: text/x-patch, Size: 5799 bytes --]

diff -BcNpPr -C 4 qemu-0.5.5/block.c qemu-0.5.5-fbsd/block.c
*** qemu-0.5.5/block.c	Sat May  8 15:51:18 2004
--- qemu-0.5.5-fbsd/block.c	Sun May 30 01:03:08 2004
***************
*** 26,33 ****
--- 26,40 ----
  #ifndef _WIN32
  #include <sys/mman.h>
  #endif
  
+ #ifdef __FreeBSD__
+ #include <sys/types.h>
+ #include <sys/stat.h>
+ #include <sys/ioctl.h>
+ #include <sys/disk.h>
+ #endif
+ 
  #include "cow.h"
  
  struct BlockDriverState {
      int fd; /* if -1, only COW mappings */
*************** BlockDriverState *bdrv_new(const char *d
*** 80,88 ****
  int bdrv_open(BlockDriverState *bs, const char *filename, int snapshot)
  {
      int fd;
      int64_t size;
!     struct cow_header_v2 cow_header;
  #ifndef _WIN32
      char template[] = "/tmp/vl.XXXXXX";
      int cow_fd;
      struct stat st;
--- 87,98 ----
  int bdrv_open(BlockDriverState *bs, const char *filename, int snapshot)
  {
      int fd;
      int64_t size;
!     union {
!         struct cow_header_v2 header;
!         uint8_t buffer[512*4];
!     } cow;
  #ifndef _WIN32
      char template[] = "/tmp/vl.XXXXXX";
      int cow_fd;
      struct stat st;
*************** int bdrv_open(BlockDriverState *bs, cons
*** 115,169 ****
              bs->read_only = 1;
      }
      bs->fd = fd;
  
      /* see if it is a cow image */
!     if (read(fd, &cow_header, sizeof(cow_header)) != sizeof(cow_header)) {
          fprintf(stderr, "%s: could not read header\n", filename);
          goto fail;
      }
  #ifndef _WIN32
!     if (be32_to_cpu(cow_header.magic) == COW_MAGIC &&
!         be32_to_cpu(cow_header.version) == COW_VERSION) {
          /* cow image found */
!         size = cow_header.size;
  #ifndef WORDS_BIGENDIAN
          size = bswap64(size);
  #endif    
          bs->total_sectors = size / 512;
  
          bs->cow_fd = fd;
          bs->fd = -1;
!         if (cow_header.backing_file[0] != '\0') {
!             if (stat(cow_header.backing_file, &st) != 0) {
!                 fprintf(stderr, "%s: could not find original disk image '%s'\n", filename, cow_header.backing_file);
                  goto fail;
              }
!             if (st.st_mtime != be32_to_cpu(cow_header.mtime)) {
!                 fprintf(stderr, "%s: original raw disk image '%s' does not match saved timestamp\n", filename, cow_header.backing_file);
                  goto fail;
              }
!             fd = open(cow_header.backing_file, O_RDONLY | O_LARGEFILE);
              if (fd < 0)
                  goto fail;
              bs->fd = fd;
          }
!         /* mmap the bitmap */
!         bs->cow_bitmap_size = ((bs->total_sectors + 7) >> 3) + sizeof(cow_header);
          bs->cow_bitmap_addr = mmap(get_mmap_addr(bs->cow_bitmap_size), 
                                     bs->cow_bitmap_size, 
                                     PROT_READ | PROT_WRITE,
                                     MAP_SHARED, bs->cow_fd, 0);
          if (bs->cow_bitmap_addr == MAP_FAILED)
              goto fail;
!         bs->cow_bitmap = bs->cow_bitmap_addr + sizeof(cow_header);
          bs->cow_sectors_offset = (bs->cow_bitmap_size + 511) & ~511;
          snapshot = 0;
      } else 
  #endif
      {
          /* standard raw image */
          size = lseek64(fd, 0, SEEK_END);
          bs->total_sectors = size / 512;
          bs->fd = fd;
      }
  
--- 125,189 ----
              bs->read_only = 1;
      }
      bs->fd = fd;
  
+     lseek(fd, 0LL, SEEK_SET);
      /* see if it is a cow image */
!     if (read(fd, &cow.buffer, sizeof(cow.buffer)) != sizeof(cow.buffer)) {
          fprintf(stderr, "%s: could not read header\n", filename);
          goto fail;
      }
  #ifndef _WIN32
!     if (be32_to_cpu(cow.header.magic) == COW_MAGIC &&
!         be32_to_cpu(cow.header.version) == COW_VERSION) {
          /* cow image found */
!         size = cow.header.size;
  #ifndef WORDS_BIGENDIAN
          size = bswap64(size);
  #endif    
          bs->total_sectors = size / 512;
  
          bs->cow_fd = fd;
          bs->fd = -1;
!         if (cow.header.backing_file[0] != '\0') {
!             if (stat(cow.header.backing_file, &st) != 0) {
!                 fprintf(stderr, "%s: could not find original disk image '%s'\n", filename, cow.header.backing_file);
                  goto fail;
              }
!             if (st.st_mtime != be32_to_cpu(cow.header.mtime)) {
!                 fprintf(stderr, "%s: original raw disk image '%s' does not match saved timestamp\n", filename, cow.header.backing_file);
                  goto fail;
              }
!             fd = open(cow.header.backing_file, O_RDONLY | O_LARGEFILE);
              if (fd < 0)
                  goto fail;
              bs->fd = fd;
          }
!         /* mmap thquie bitmap */
!         bs->cow_bitmap_size = ((bs->total_sectors + 7) >> 3) + sizeof(cow.header);
          bs->cow_bitmap_addr = mmap(get_mmap_addr(bs->cow_bitmap_size), 
                                     bs->cow_bitmap_size, 
                                     PROT_READ | PROT_WRITE,
                                     MAP_SHARED, bs->cow_fd, 0);
          if (bs->cow_bitmap_addr == MAP_FAILED)
              goto fail;
!         bs->cow_bitmap = bs->cow_bitmap_addr + sizeof(cow.header);
          bs->cow_sectors_offset = (bs->cow_bitmap_size + 511) & ~511;
          snapshot = 0;
      } else 
  #endif
      {
          /* standard raw image */
+ #ifdef __FreeBSD__
+         if (ioctl(fd, DIOCGMEDIASIZE, (off_t *)&size))
+             size = lseek(fd, 0LL, SEEK_END);
+ #else
          size = lseek64(fd, 0, SEEK_END);
+ #endif
+         if (size<0) {
+             fprintf(stderr,"unable to determine size of device\n");
+             goto fail;
+         }
          bs->total_sectors = size / 512;
          bs->fd = fd;
      }
  

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [Qemu-devel] Running QEMU on FreeBSD
  2004-05-30  9:50               ` Antony T Curtis
@ 2004-05-30 14:41                 ` Bartosz Fabianowski
  2004-05-30 17:27                   ` Antony T Curtis
  0 siblings, 1 reply; 32+ messages in thread
From: Bartosz Fabianowski @ 2004-05-30 14:41 UTC (permalink / raw)
  To: qemu-devel

> Here is the diffs I am using...

Could you make that a unified diff? Context format is horribly hard to 
read if you want to try and understand the changes (as I am trying to 
right now...).

- Bartosz

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [Qemu-devel] Running QEMU on FreeBSD
  2004-05-30 14:41                 ` Bartosz Fabianowski
@ 2004-05-30 17:27                   ` Antony T Curtis
  2004-05-30 18:57                     ` Bartosz Fabianowski
  0 siblings, 1 reply; 32+ messages in thread
From: Antony T Curtis @ 2004-05-30 17:27 UTC (permalink / raw)
  To: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 341 bytes --]

On Sun, 2004-05-30 at 15:41, Bartosz Fabianowski wrote:
> > Here is the diffs I am using...
> 
> Could you make that a unified diff? Context format is horribly hard to 
> read if you want to try and understand the changes (as I am trying to 
> right now...).

Okay... new patch is attached
-- 
Antony T Curtis <antony.t.curtis@ntlworld.com>

[-- Attachment #2: qemu-unified.diff --]
[-- Type: text/x-patch, Size: 12059 bytes --]

diff -urd --exclude=CVS ../cvs/qemu/Makefile qemu-0.5.5/Makefile
--- ../cvs/qemu/Makefile	Mon May 17 21:06:42 2004
+++ qemu-0.5.5/Makefile	Sun May 30 05:26:19 2004
@@ -70,7 +70,7 @@
 
 # documentation
 %.html: %.texi
-	texi2html -monolithic -number $<
+	-texi2html -monolithic -number $<
 
 qemu.1: qemu-doc.texi
 	./texi2pod.pl $< qemu.pod
diff -urd --exclude=CVS ../cvs/qemu/block.c qemu-0.5.5/block.c
--- ../cvs/qemu/block.c	Sat May  8 16:27:20 2004
+++ qemu-0.5.5/block.c	Sun May 30 16:36:53 2004
@@ -27,6 +27,13 @@
 #include <sys/mman.h>
 #endif
 
+#ifdef _BSD
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/ioctl.h>
+#include <sys/disk.h>
+#endif
+
 #include "cow.h"
 
 struct BlockDriverState {
@@ -81,7 +88,10 @@
 {
     int fd;
     int64_t size;
-    struct cow_header_v2 cow_header;
+    union {
+      struct cow_header_v2 cow_header;
+      uint8_t cow_buffer[2048];
+    } cow;
 #ifndef _WIN32
     char template[] = "/tmp/vl.XXXXXX";
     int cow_fd;
@@ -117,15 +127,15 @@
     bs->fd = fd;
 
     /* see if it is a cow image */
-    if (read(fd, &cow_header, sizeof(cow_header)) != sizeof(cow_header)) {
+    if (read(fd, &cow.cow_header, sizeof(cow)) != sizeof(cow)) {
         fprintf(stderr, "%s: could not read header\n", filename);
         goto fail;
     }
 #ifndef _WIN32
-    if (be32_to_cpu(cow_header.magic) == COW_MAGIC &&
-        be32_to_cpu(cow_header.version) == COW_VERSION) {
+    if (be32_to_cpu(cow.cow_header.magic) == COW_MAGIC &&
+        be32_to_cpu(cow.cow_header.version) == COW_VERSION) {
         /* cow image found */
-        size = cow_header.size;
+        size = cow.cow_header.size;
 #ifndef WORDS_BIGENDIAN
         size = bswap64(size);
 #endif    
@@ -133,34 +143,41 @@
 
         bs->cow_fd = fd;
         bs->fd = -1;
-        if (cow_header.backing_file[0] != '\0') {
-            if (stat(cow_header.backing_file, &st) != 0) {
-                fprintf(stderr, "%s: could not find original disk image '%s'\n", filename, cow_header.backing_file);
+        if (cow.cow_header.backing_file[0] != '\0') {
+            if (stat(cow.cow_header.backing_file, &st) != 0) {
+                fprintf(stderr, "%s: could not find original disk image '%s'\n", filename, cow.cow_header.backing_file);
                 goto fail;
             }
-            if (st.st_mtime != be32_to_cpu(cow_header.mtime)) {
-                fprintf(stderr, "%s: original raw disk image '%s' does not match saved timestamp\n", filename, cow_header.backing_file);
+            if (st.st_mtime != be32_to_cpu(cow.cow_header.mtime)) {
+                fprintf(stderr, "%s: original raw disk image '%s' does not match saved timestamp\n", filename, cow.cow_header.backing_file);
                 goto fail;
             }
-            fd = open(cow_header.backing_file, O_RDONLY | O_LARGEFILE);
+            fd = open(cow.cow_header.backing_file, O_RDONLY | O_LARGEFILE);
             if (fd < 0)
                 goto fail;
             bs->fd = fd;
         }
         /* mmap the bitmap */
-        bs->cow_bitmap_size = ((bs->total_sectors + 7) >> 3) + sizeof(cow_header);
+        bs->cow_bitmap_size = ((bs->total_sectors + 7) >> 3) + sizeof(cow.cow_header);
         bs->cow_bitmap_addr = mmap(get_mmap_addr(bs->cow_bitmap_size), 
                                    bs->cow_bitmap_size, 
                                    PROT_READ | PROT_WRITE,
                                    MAP_SHARED, bs->cow_fd, 0);
         if (bs->cow_bitmap_addr == MAP_FAILED)
             goto fail;
-        bs->cow_bitmap = bs->cow_bitmap_addr + sizeof(cow_header);
+        bs->cow_bitmap = bs->cow_bitmap_addr + sizeof(cow.cow_header);
         bs->cow_sectors_offset = (bs->cow_bitmap_size + 511) & ~511;
         snapshot = 0;
     } else 
 #endif
     {
+#ifdef _BSD
+        struct stat sb;
+        if (!fstat(fd,&sb) && (S_IFCHR & sb.st_mode)) {
+            if (ioctl(fd, DIOCGMEDIASIZE, (off_t *)&size))
+                size = lseek(fd, 0LL, SEEK_END);
+        } else
+#endif                      
         /* standard raw image */
         size = lseek64(fd, 0, SEEK_END);
         bs->total_sectors = size / 512;
Only in qemu-0.5.5: block.c.bck
diff -urd --exclude=CVS ../cvs/qemu/configure qemu-0.5.5/configure
--- ../cvs/qemu/configure	Thu May 20 14:23:39 2004
+++ qemu-0.5.5/configure	Sun May 30 05:42:05 2004
@@ -419,9 +419,11 @@
 if [ "$bsd" = "yes" ] ; then
   echo "#define O_LARGEFILE 0" >> $config_h
   echo "#define lseek64 lseek" >> $config_h
+  echo "#define mkstemp64 mkstemp" >> $config_h
   echo "#define ftruncate64 ftruncate" >> $config_h
   echo "#define MAP_ANONYMOUS MAP_ANON" >> $config_h
   echo "#define _BSD 1" >> $config_h
+  echo "#define off64_t off_t" >> $config_h
 fi
 
 for target in $target_list; do 
Only in qemu-0.5.5: qemu.1
diff -urd --exclude=CVS ../cvs/qemu/target-i386/cpu.h qemu-0.5.5/target-i386/cpu.h
--- ../cvs/qemu/target-i386/cpu.h	Thu May 20 15:01:56 2004
+++ qemu-0.5.5/target-i386/cpu.h	Sun May 30 05:16:10 2004
@@ -259,7 +259,7 @@
     CC_OP_NB,
 };
 
-#if (defined(__i386__) || defined(__x86_64__)) && !defined(_BSD)
+#if defined(__i386__) || defined(__x86_64__)
 #define USE_X86LDOUBLE
 #endif
 
diff -urd --exclude=CVS ../cvs/qemu/target-i386/exec.h qemu-0.5.5/target-i386/exec.h
--- ../cvs/qemu/target-i386/exec.h	Sat May 29 12:08:52 2004
+++ qemu-0.5.5/target-i386/exec.h	Sun May 30 05:19:43 2004
@@ -293,6 +293,22 @@
 
 #endif /* !defined(CONFIG_USER_ONLY) */
 
+#if defined(_BSD) && defined(USE_X86LDOUBLE)
+#include <math.h>
+/*int rintl(long double __x);
+long int lrintl(long double __x);
+long long int llrintl(long double __x);
+long double powl(long double __x, long double __y);
+long double logl(long double __x);
+long double tanl(long double __x);
+long double atan2l(long double __y, long double __x);
+long double ceill(long double __x);
+long double floorl(long double __x);
+long double sqrtl(long double __x);
+long double sinl(long double __x);
+long double cosl(long double __x);*/
+#endif
+
 #ifdef USE_X86LDOUBLE
 /* use long double functions */
 #define lrint lrintl
@@ -310,7 +326,7 @@
 #define rint rintl
 #endif
 
-#if !defined(_BSD)
+#if !defined(_BSD) || defined(USE_X86LDOUBLE)
 extern int lrint(CPU86_LDouble x);
 extern int64_t llrint(CPU86_LDouble x);
 #else
diff -urd --exclude=CVS ../cvs/qemu/target-i386/op.c qemu-0.5.5/target-i386/op.c
--- ../cvs/qemu/target-i386/op.c	Sat May 29 12:08:52 2004
+++ qemu-0.5.5/target-i386/op.c	Sun May 30 05:40:54 2004
@@ -1304,6 +1304,149 @@
    functions comes from the LGPL'ed x86 emulator found in the Willows
    TWIN windows emulator. */
 
+#if defined(_BSD) && defined(USE_X86LDOUBLE)
+
+CPU86_LDouble rintl(CPU86_LDouble __x) {
+  CPU86_LDouble __rintres;
+  __asm__ __volatile__
+    ("fistp %0"
+     : "=m" (__rintres) : "t" (__x) : "st");
+  return __rintres;
+}
+
+int lrintl(CPU86_LDouble __x) {
+  int __lrintres;
+  __asm__ __volatile__
+    ("fistpl %0"
+     : "=m" (__lrintres) : "t" (__x) : "st");
+  return __lrintres;
+}
+
+
+int64_t llrintl(CPU86_LDouble __x) {
+  int64_t __llrintres;
+  __asm__ __volatile__
+    ("fistpll %0"
+     : "=m" (__llrintres) : "t" (__x) : "st");
+  return __llrintres;
+}
+
+CPU86_LDouble powl(CPU86_LDouble __x, CPU86_LDouble __y) {
+  register CPU86_LDouble __value;
+  register long double __exponent;
+  __extension__ long long int __p = (long long int) __y;
+  if (__x == 0.0)
+    {
+       if (__y > 0.0)
+         return __y == (double) __p && (__p & 1) != 0 ? __x : 0.0;
+       else if (__y < 0.0)
+         return (__y == (double) __p && (-__p & 1) != 0
+                 ? 1.0 / __x : 1.0 / fabs (__x));
+    }
+  if (__y == (double) __p)
+    {
+      long double __r = 1.0;
+      if (__p == 0)
+        return 1.0;
+      if (__p < 0)
+        {
+          __p = -__p;
+          __x = 1.0 / __x;
+        }
+      while (1)
+        {
+          if (__p & 1)
+            __r *= __x;
+          __p >>= 1;
+          if (__p == 0)
+            return __r;
+          __x *= __x;
+        }
+      /* NOTREACHED */
+    }
+  __asm __volatile__
+    ("fyl2x" : "=t" (__value) : "0" (__x), "u" (1.0) : "st(1)");
+  __asm __volatile__
+    ("fmul      %%st(1)         # y * log2(x)\n\t"
+     "fst       %%st(1)\n\t"
+     "frndint                   # int(y * log2(x))\n\t"
+     "fxch\n\t"
+     "fsub      %%st(1)         # fract(y * log2(x))\n\t"
+     "f2xm1                     # 2^(fract(y * log2(x))) - 1\n\t"
+     : "=t" (__value), "=u" (__exponent) : "0" (__y), "1" (__value));
+  __value += 1.0;
+  __asm __volatile__
+    ("fscale"
+     : "=t" (__value) : "0" (__value), "u" (__exponent));
+  return __value;
+}
+
+CPU86_LDouble logl(CPU86_LDouble __x) {
+  register CPU86_LDouble __result;
+  __asm __volatile__ ("fldln2; fxch; fyl2x" : "=t" (__result) : "0" (__x) : "st(1)");
+  return __result;
+}
+
+CPU86_LDouble tanl(CPU86_LDouble __x) {
+  register CPU86_LDouble __value;
+  register CPU86_LDouble __value2 __attribute__ ((__unused__));
+  __asm __volatile__
+    ("fptan"
+     : "=t" (__value2), "=u" (__value) : "0" (__x));
+  return __value;
+}
+
+CPU86_LDouble atan2l(CPU86_LDouble __y, CPU86_LDouble __x) {
+  register CPU86_LDouble __value;
+  __asm __volatile__
+    ("fpatan"
+     : "=t" (__value) : "0" (__x), "u" (__y) : "st(1)");
+  return __value;
+}
+
+CPU86_LDouble ceill(CPU86_LDouble __x) {
+  register CPU86_LDouble __value;
+  __volatile unsigned short int __cw;
+  __volatile unsigned short int __cwtmp;
+  __asm __volatile ("fnstcw %0" : "=m" (__cw));
+  __cwtmp = (__cw & 0xf3ff) | 0x0800; /* rounding up */
+  __asm __volatile ("fldcw %0" : : "m" (__cwtmp));
+  __asm __volatile ("frndint" : "=t" (__value) : "0" (__x));
+  __asm __volatile ("fldcw %0" : : "m" (__cw));
+  return __value;
+}
+
+CPU86_LDouble floorl(CPU86_LDouble __x) {
+  register CPU86_LDouble __value;
+  __volatile unsigned short int __cw;
+  __volatile unsigned short int __cwtmp;
+  __asm __volatile ("fnstcw %0" : "=m" (__cw));
+  __cwtmp = (__cw & 0xf3ff) | 0x0400; /* rounding down */
+  __asm __volatile ("fldcw %0" : : "m" (__cwtmp));
+  __asm __volatile ("frndint" : "=t" (__value) : "0" (__x));
+  __asm __volatile ("fldcw %0" : : "m" (__cw));
+  return __value;
+}
+
+CPU86_LDouble sqrtl(CPU86_LDouble __x) {
+  register CPU86_LDouble __result;
+  __asm __volatile__ ("fsqrt" : "=t" (__result) : "0" (__x));
+  return __result;
+}
+
+CPU86_LDouble sinl(CPU86_LDouble __x) {
+  register CPU86_LDouble __result;
+  __asm __volatile__ ("fsin" : "=t" (__result) : "0" (__x));
+  return __result;
+}
+
+CPU86_LDouble cosl(CPU86_LDouble __x) {
+  register CPU86_LDouble __result;
+  __asm __volatile__ ("fcos" : "=t" (__result) : "0" (__x));
+  return __result;
+}
+#endif
+
 #if defined(__powerpc__)
 extern CPU86_LDouble copysign(CPU86_LDouble, CPU86_LDouble);
 
diff -urd --exclude=CVS ../cvs/qemu/vl.c qemu-0.5.5/vl.c
--- ../cvs/qemu/vl.c	Wed May 26 23:12:06 2004
+++ qemu-0.5.5/vl.c	Sun May 30 05:30:56 2004
@@ -662,6 +662,14 @@
     case QEMU_TIMER_REALTIME:
 #ifdef _WIN32
         return GetTickCount();
+#elif defined(_BSD)
+        {
+            struct timeval r;
+            if (!gettimeofday(&r, NULL)) {
+                return ((CLK_TCK * 1000LL) * (int64_t)r.tv_sec 
+                      + ((int64_t)r.tv_usec * CLK_TCK) / 1000) / timer_freq;
+            }
+        }        
 #else
         {
             struct tms tp;
@@ -828,6 +836,7 @@
            the emulated kernel requested a too high timer frequency */
         getitimer(ITIMER_REAL, &itv);
 
+#if defined(__linux__)
         if (itv.it_interval.tv_usec > 1000) {
             /* try to use /dev/rtc to have a faster timer */
             if (start_rtc_timer() < 0)
@@ -843,7 +852,9 @@
             sigaction(SIGIO, &act, NULL);
             fcntl(rtc_fd, F_SETFL, O_ASYNC);
             fcntl(rtc_fd, F_SETOWN, getpid());
-        } else {
+        } else 
+#endif
+        {
         use_itimer:
             pit_min_timer_count = ((uint64_t)itv.it_interval.tv_usec * 
                                    PIT_FREQ) / 1000000;

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [Qemu-devel] Running QEMU on FreeBSD
  2004-05-30 17:27                   ` Antony T Curtis
@ 2004-05-30 18:57                     ` Bartosz Fabianowski
  2004-05-30 20:09                       ` Antony T Curtis
  0 siblings, 1 reply; 32+ messages in thread
From: Bartosz Fabianowski @ 2004-05-30 18:57 UTC (permalink / raw)
  To: qemu-devel

Seems like your newest patch merges all the FreeBSD patches floating 
around out there. Good job.

You didn't merge in one small patch of mine though and I am wondering 
why. The patch I am talking about is the one that makes the configure 
script look for "sdl11-config" instead of "sdl-config". I have installed 
the devel/sdl12 port and the name of the executable is "sdl11-config" on 
my system. It must be "sdl-config" on your system since you didn't 
include this little patch. And I am curious as to why you have a 
different file name. How did you install the SDL? From the ports? If so, 
which port?

- Bartosz

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [Qemu-devel] Running QEMU on FreeBSD
  2004-05-30 18:57                     ` Bartosz Fabianowski
@ 2004-05-30 20:09                       ` Antony T Curtis
  2004-05-31  0:36                         ` Bartosz Fabianowski
  0 siblings, 1 reply; 32+ messages in thread
From: Antony T Curtis @ 2004-05-30 20:09 UTC (permalink / raw)
  To: qemu-devel

On Sun, 2004-05-30 at 19:57, Bartosz Fabianowski wrote:
> Seems like your newest patch merges all the FreeBSD patches floating 
> around out there. Good job.
> 
> You didn't merge in one small patch of mine though and I am wondering 
> why. The patch I am talking about is the one that makes the configure 
> script look for "sdl11-config" instead of "sdl-config". I have installed 
> the devel/sdl12 port and the name of the executable is "sdl11-config" on 
> my system. It must be "sdl-config" on your system since you didn't 
> include this little patch. And I am curious as to why you have a 
> different file name. How did you install the SDL? From the ports? If so, 
> which port?

I installed it via the ports but I have a symlink in /usr/local/bin
because of a few things which I build from tarballs.

Most people will not have that symlink so it would be a good idea to add
in your change,

-- 

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [Qemu-devel] Running QEMU on FreeBSD
  2004-05-30 20:09                       ` Antony T Curtis
@ 2004-05-31  0:36                         ` Bartosz Fabianowski
  2004-05-31  1:24                           ` Antony T Curtis
  0 siblings, 1 reply; 32+ messages in thread
From: Bartosz Fabianowski @ 2004-05-31  0:36 UTC (permalink / raw)
  To: qemu-devel

I just discovered another problem with your patch.

Before applying your patch, I was using my own hack that resorted to 
normal precision doubles for FPU emulation. This resulted in incorrect 
rounding as could be easily seen when running Windows Update. The total 
number of megabytes to download was something like 10.99999999999998. 
Obviously, something had gone wrong with precision and rounding.

However, after I have applied your patch, which imports from Linux the 
functions required to use long doubles, the situation got worse. The 
total number of megabytes to be downloaded by Windows Update is now 
shown as NaN. I know from previous installs that it should be a 
moderately sized number, something such as 10 or 20 megabytes. So it's 
not the rounding of an immensely large number or of a ridiculously small 
one that is going wrong. There is some other issue surfacing here that 
makes a perfectly normal-sized floating point number become a NaN.

It's 2:30am here in Europe right now and I won't investigate this 
further tonight. But if you have time to, maybe you can have a look and 
see if you can find the source of this problem.

- Bartosz

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [Qemu-devel] Running QEMU on FreeBSD
  2004-05-31  0:36                         ` Bartosz Fabianowski
@ 2004-05-31  1:24                           ` Antony T Curtis
  2004-05-31  1:42                             ` Bartosz Fabianowski
  2004-06-02 23:18                             ` qemu port (was: Re: [Qemu-devel] Running QEMU on FreeBSD) Juergen Lock
  0 siblings, 2 replies; 32+ messages in thread
From: Antony T Curtis @ 2004-05-31  1:24 UTC (permalink / raw)
  To: qemu-devel

On Mon, 2004-05-31 at 01:36, Bartosz Fabianowski wrote:
> I just discovered another problem with your patch.
> 
> Before applying your patch, I was using my own hack that resorted to 
> normal precision doubles for FPU emulation. This resulted in incorrect 
> rounding as could be easily seen when running Windows Update. The total 
> number of megabytes to download was something like 10.99999999999998. 
> Obviously, something had gone wrong with precision and rounding.
> 
> However, after I have applied your patch, which imports from Linux the 
> functions required to use long doubles, the situation got worse. The 
> total number of megabytes to be downloaded by Windows Update is now 
> shown as NaN. I know from previous installs that it should be a 
> moderately sized number, something such as 10 or 20 megabytes. So it's 
> not the rounding of an immensely large number or of a ridiculously small 
> one that is going wrong. There is some other issue surfacing here that 
> makes a perfectly normal-sized floating point number become a NaN.

Replace the rintl() function in target-i386/op.c with the following:

CPU86_LDouble rintl(CPU86_LDouble __x) {
  register CPU86_LDouble __result;
  __asm __volatile__ ("frndint" : "=t" (__result) : "0" (__x));
  return __result;
}


> It's 2:30am here in Europe right now and I won't investigate this 
> further tonight. But if you have time to, maybe you can have a look and 
> see if you can find the source of this problem.
> 
> - Bartosz
> 
> 
> _______________________________________________
> Qemu-devel mailing list
> Qemu-devel@nongnu.org
> http://lists.nongnu.org/mailman/listinfo/qemu-devel
>  FLAGS (\Seen))
-- 

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [Qemu-devel] Running QEMU on FreeBSD
  2004-05-31  1:24                           ` Antony T Curtis
@ 2004-05-31  1:42                             ` Bartosz Fabianowski
  2004-05-31  1:59                               ` Kyle Hayes
                                                 ` (3 more replies)
  2004-06-02 23:18                             ` qemu port (was: Re: [Qemu-devel] Running QEMU on FreeBSD) Juergen Lock
  1 sibling, 4 replies; 32+ messages in thread
From: Bartosz Fabianowski @ 2004-05-31  1:42 UTC (permalink / raw)
  To: qemu-devel

This fixes the NaN, but reverts to what my hack did - weird rounding. 
The total download size for some updates I selected is now reported as 
1.6000000000000003 (that's 14 zeros in between). Not quite sure what's 
going wrong here...

- Bartosz

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [Qemu-devel] Running QEMU on FreeBSD
  2004-05-31  1:42                             ` Bartosz Fabianowski
@ 2004-05-31  1:59                               ` Kyle Hayes
  2004-05-31 12:15                                 ` Bartosz Fabianowski
  2004-05-31  9:38                               ` Antony T Curtis
                                                 ` (2 subsequent siblings)
  3 siblings, 1 reply; 32+ messages in thread
From: Kyle Hayes @ 2004-05-31  1:59 UTC (permalink / raw)
  To: qemu-devel

On Sunday 30 May 2004 18:42, Bartosz Fabianowski wrote:
> This fixes the NaN, but reverts to what my hack did - weird rounding.
> The total download size for some updates I selected is now reported as
> 1.6000000000000003 (that's 14 zeros in between). Not quite sure what's
> going wrong here...

You're either up very, very late, or very early :-)

I didn't see a patch attached to this email.  Did my mailer drop it?

Best,
Kyle

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [Qemu-devel] Running QEMU on FreeBSD
  2004-05-31  1:42                             ` Bartosz Fabianowski
  2004-05-31  1:59                               ` Kyle Hayes
@ 2004-05-31  9:38                               ` Antony T Curtis
  2004-05-31 20:36                                 ` Bartosz Fabianowski
  2004-05-31 13:54                               ` Antony T Curtis
  2004-05-31 22:56                               ` Brion Vibber
  3 siblings, 1 reply; 32+ messages in thread
From: Antony T Curtis @ 2004-05-31  9:38 UTC (permalink / raw)
  To: qemu-devel

On Mon, 2004-05-31 at 02:42, Bartosz Fabianowski wrote:
> This fixes the NaN, but reverts to what my hack did - weird rounding. 
> The total download size for some updates I selected is now reported as 
> 1.6000000000000003 (that's 14 zeros in between). Not quite sure what's 
> going wrong here...

Hmm... do you know if this same behaviour happens with QEMU running on
Linux or some other host OS?
-- 
Antony T Curtis <antony.t.curtis@ntlworld.com>

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [Qemu-devel] Running QEMU on FreeBSD
  2004-05-31  1:59                               ` Kyle Hayes
@ 2004-05-31 12:15                                 ` Bartosz Fabianowski
  2004-05-31 13:22                                   ` Antony T Curtis
  0 siblings, 1 reply; 32+ messages in thread
From: Bartosz Fabianowski @ 2004-05-31 12:15 UTC (permalink / raw)
  To: kyle, qemu-devel

> You're either up very, very late, or very early :-)

Very late :).

> I didn't see a patch attached to this email.  Did my mailer drop it?

I was referring to Antony's latest patch. It wasn't quite a patch, in 
fact, just the following idea:

Replace the rintl() function in target-i386/op.c with the following:

CPU86_LDouble rintl(CPU86_LDouble __x) {
   register CPU86_LDouble __result;
   __asm __volatile__ ("frndint" : "=t" (__result) : "0" (__x));
   return __result;
}

So what I meant to say is that with this change, the FPU stops reporting 
a NaN when it obviously shouldn't, but starts doing weird rounding 
again. Sorry if my late-night mail wasn't quite clear.

- Bartosz

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [Qemu-devel] Running QEMU on FreeBSD
  2004-05-31 12:15                                 ` Bartosz Fabianowski
@ 2004-05-31 13:22                                   ` Antony T Curtis
  0 siblings, 0 replies; 32+ messages in thread
From: Antony T Curtis @ 2004-05-31 13:22 UTC (permalink / raw)
  To: qemu-devel

On Mon, 2004-05-31 at 13:15, Bartosz Fabianowski wrote:
> > You're either up very, very late, or very early :-)
> 
> Very late :).
> 
> > I didn't see a patch attached to this email.  Did my mailer drop it?
> 
> I was referring to Antony's latest patch. It wasn't quite a patch, in 
> fact, just the following idea:
> 
> Replace the rintl() function in target-i386/op.c with the following:
> 
> CPU86_LDouble rintl(CPU86_LDouble __x) {
>    register CPU86_LDouble __result;
>    __asm __volatile__ ("frndint" : "=t" (__result) : "0" (__x));
>    return __result;
> }
> 
> So what I meant to say is that with this change, the FPU stops reporting 
> a NaN when it obviously shouldn't, but starts doing weird rounding 
> again. Sorry if my late-night mail wasn't quite clear.

I think the errors are being introduced in the routines in
target-i386/helper.c

I'm going to investigate replacing them with more 'native' operations
-- 
Antony T Curtis <antony.t.curtis@ntlworld.com>

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [Qemu-devel] Running QEMU on FreeBSD
  2004-05-31  1:42                             ` Bartosz Fabianowski
  2004-05-31  1:59                               ` Kyle Hayes
  2004-05-31  9:38                               ` Antony T Curtis
@ 2004-05-31 13:54                               ` Antony T Curtis
  2004-05-31 20:31                                 ` Bartosz Fabianowski
  2004-05-31 22:56                               ` Brion Vibber
  3 siblings, 1 reply; 32+ messages in thread
From: Antony T Curtis @ 2004-05-31 13:54 UTC (permalink / raw)
  To: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 514 bytes --]

On Mon, 2004-05-31 at 02:42, Bartosz Fabianowski wrote:
> This fixes the NaN, but reverts to what my hack did - weird rounding. 
> The total download size for some updates I selected is now reported as 
> 1.6000000000000003 (that's 14 zeros in between). Not quite sure what's 
> going wrong here...

Ok... I am curious if the following diff helps it (or makes it worse)
It is just a quick hack to use the native fpu instructions instead of
manual calculation...

-- 
Antony T Curtis <antony.t.curtis@ntlworld.com>

[-- Attachment #2: qemu-fpu.diff --]
[-- Type: text/x-patch, Size: 3205 bytes --]

--- /home/antony/cvs/qemu/target-i386/helper.c	Sat May 29 12:08:52 2004
+++ target-i386/helper.c	Mon May 31 15:40:13 2004
@@ -2105,7 +2105,12 @@
 
 void helper_f2xm1(void)
 {
+#ifdef USE_X86LDOUBLE
+    __asm __volatile__
+      ("f2xm1" : "=t" (ST0) : "0" (ST0));
+#else
     ST0 = pow(2.0,ST0) - 1.0;
+#endif
 }
 
 void helper_fyl2x(void)
@@ -2114,8 +2119,14 @@
     
     fptemp = ST0;
     if (fptemp>0.0){
+#ifdef USE_X86LDOUBLE
+        __asm __volatile__
+          ("fyl2x"
+           : "=t" (ST1) : "0" (fptemp) , "u" (ST1));
+#else
         fptemp = log(fptemp)/log(2.0);	 /* log2(ST) */
         ST1 *= fptemp;
+#endif
         fpop();
     } else { 
         env->fpus &= (~0x4700);
@@ -2165,6 +2176,19 @@
 
 void helper_fprem1(void)
 {
+#ifdef USE_X86LDOUBLE
+    int flags;
+    __asm __volatile__
+      ("fprem1\n\t"
+       "fnstsw %%ax\n\t"
+       : "=t" (ST0), "=ax" (flags) : "0" (ST0) , "u" (ST1));
+    if (flags & 0x400) 
+        env->fpus |= 0x400;
+    else {
+        env->fpus &= (~0x4700);
+        env->fpus |= flags & 0x07;
+    }
+#else
     CPU86_LDouble dblq, fpsrcop, fptemp;
     CPU86_LDoubleU fpsrcop1, fptemp1;
     int expdif;
@@ -2194,10 +2218,24 @@
             floor(fpsrcop): ceil(fpsrcop);
         ST0 -= (ST1 * fpsrcop * fptemp);
     }
+#endif
 }
 
 void helper_fprem(void)
 {
+#ifdef USE_X86LDOUBLE
+    int flags;
+    __asm __volatile__
+      ("fprem\n\t"
+       "fnstsw %%ax\n\t"
+       : "=t" (ST0), "=ax" (flags) : "0" (ST0) , "u" (ST1));
+    if (flags & 0x400) 
+        env->fpus |= 0x400;
+    else {
+        env->fpus &= (~0x4700);
+        env->fpus |= flags & 0x07;
+    }
+#else
     CPU86_LDouble dblq, fpsrcop, fptemp;
     CPU86_LDoubleU fpsrcop1, fptemp1;
     int expdif;
@@ -2205,6 +2243,7 @@
     
     fpsrcop = ST0;
     fptemp = ST1;
+
     fpsrcop1.d = fpsrcop;
     fptemp1.d = fptemp;
     expdif = EXPD(fpsrcop1) - EXPD(fptemp1);
@@ -2227,6 +2266,7 @@
             -(floor(fabs(fpsrcop))): floor(fpsrcop);
         ST0 -= (ST1 * fpsrcop * fptemp);
     }
+#endif
 }
 
 void helper_fyl2xp1(void)
@@ -2235,8 +2275,13 @@
 
     fptemp = ST0;
     if ((fptemp+1.0)>0.0) {
+#ifdef USE_X86LDOUBLE
+        __asm __volatile__
+          ("fyl2xp1" : "=t" (ST1) : "0" (fptemp) , "u" (ST1));
+#else
         fptemp = log(fptemp+1.0) / log(2.0); /* log2(ST+1.0) */
         ST1 *= fptemp;
+#endif
         fpop();
     } else { 
         env->fpus &= (~0x4700);
@@ -2264,11 +2309,17 @@
     if ((fptemp > MAXTAN)||(fptemp < -MAXTAN)) {
         env->fpus |= 0x400;
     } else {
+#ifdef USE_X86LDOUBLE
+        __asm __volatile__
+          ("fsincos" 
+           : "=t" (ST0) , "=u" (ST1) : "0" (ST0));
+#else
         ST0 = sin(fptemp);
         fpush();
         ST0 = cos(fptemp);
         env->fpus &= (~0x400);  /* C2 <-- 0 */
         /* the above code is for  |arg| < 2**63 only */
+#endif
     }
 }
 
@@ -2301,11 +2352,18 @@
 
 void helper_fscale(void)
 {
+#ifdef USE_X86LDOUBLE
+    __asm __volatile__
+      ("fscale" 
+       : "=t" (ST0) : "0" (ST0), "u" (ST1));
+#else
     CPU86_LDouble fpsrcop, fptemp;
 
     fpsrcop = 2.0;
     fptemp = pow(fpsrcop,ST1);
     ST0 *= fptemp;
+#endif
+
 }
 
 void helper_fsin(void)

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [Qemu-devel] Running QEMU on FreeBSD
  2004-05-31 13:54                               ` Antony T Curtis
@ 2004-05-31 20:31                                 ` Bartosz Fabianowski
  2004-05-31 22:15                                   ` Antony T Curtis
  0 siblings, 1 reply; 32+ messages in thread
From: Bartosz Fabianowski @ 2004-05-31 20:31 UTC (permalink / raw)
  To: qemu-devel

> Ok... I am curious if the following diff helps it (or makes it worse)
> It is just a quick hack to use the native fpu instructions instead of
> manual calculation...

Sorry I didn't have time to try it before. Now I have applied the diff 
and recompiled. It's back to NaN megabytes, which is really weird, as 
Windows 98, when run natively on this very computer, with this very FPU, 
reports the right numbers...

- Bartosz

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [Qemu-devel] Running QEMU on FreeBSD
  2004-05-31  9:38                               ` Antony T Curtis
@ 2004-05-31 20:36                                 ` Bartosz Fabianowski
  0 siblings, 0 replies; 32+ messages in thread
From: Bartosz Fabianowski @ 2004-05-31 20:36 UTC (permalink / raw)
  To: qemu-devel

> Hmm... do you know if this same behaviour happens with QEMU running on
> Linux or some other host OS?

Unfortunately, I only have FreeBSD installed on my computer and can't 
test this :(.

- Bartosz

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [Qemu-devel] Running QEMU on FreeBSD
  2004-05-31 20:31                                 ` Bartosz Fabianowski
@ 2004-05-31 22:15                                   ` Antony T Curtis
  0 siblings, 0 replies; 32+ messages in thread
From: Antony T Curtis @ 2004-05-31 22:15 UTC (permalink / raw)
  To: qemu-devel

On Mon, 2004-05-31 at 21:31, Bartosz Fabianowski wrote:
> > Ok... I am curious if the following diff helps it (or makes it worse)
> > It is just a quick hack to use the native fpu instructions instead of
> > manual calculation...
> 
> Sorry I didn't have time to try it before. Now I have applied the diff 
> and recompiled. It's back to NaN megabytes, which is really weird, as 
> Windows 98, when run natively on this very computer, with this very FPU, 
> reports the right numbers...

Hmm... my code is obviously broken then.

But I still personally think that there is some error being introduced
by 'emulating' those floating point instructions rather than using the
actual ones.

-- 

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [Qemu-devel] Running QEMU on FreeBSD
  2004-05-31  1:42                             ` Bartosz Fabianowski
                                                 ` (2 preceding siblings ...)
  2004-05-31 13:54                               ` Antony T Curtis
@ 2004-05-31 22:56                               ` Brion Vibber
  2004-05-31 23:01                                 ` Bartosz Fabianowski
  3 siblings, 1 reply; 32+ messages in thread
From: Brion Vibber @ 2004-05-31 22:56 UTC (permalink / raw)
  To: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 557 bytes --]

Bartosz Fabianowski wrote:
> This fixes the NaN, but reverts to what my hack did - weird rounding. 
> The total download size for some updates I selected is now reported as 
> 1.6000000000000003 (that's 14 zeros in between). Not quite sure what's 
> going wrong here...

For what it's worth, I regularly see the same thing running Windows XP 
in Virtual PC (Macintosh host). Not ideal, but somebody thinks it's good 
enough for a shipping product... That somebody is Microsoft, though, so 
take with a grain of salt. ;)

-- brion vibber (brion @ pobox.com)

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 253 bytes --]

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [Qemu-devel] Running QEMU on FreeBSD
  2004-05-31 22:56                               ` Brion Vibber
@ 2004-05-31 23:01                                 ` Bartosz Fabianowski
  0 siblings, 0 replies; 32+ messages in thread
From: Bartosz Fabianowski @ 2004-05-31 23:01 UTC (permalink / raw)
  To: qemu-devel

> For what it's worth, I regularly see the same thing running Windows XP 
> in Virtual PC (Macintosh host). Not ideal, but somebody thinks it's good 
> enough for a shipping product... That somebody is Microsoft, though, so 
> take with a grain of salt. ;)

I think I read somewhere in QEMU's documentation that the actual x86 
uses a non-standard representation for floating point numbers that is 
neither faithfully represented by double nor by long double. So unless 
you are willing to sacrifice heaps of speed for perfect emulation, I 
guess we will have to live with that.

- Bartosz

^ permalink raw reply	[flat|nested] 32+ messages in thread

* qemu port (was: Re: [Qemu-devel] Running QEMU on FreeBSD)
  2004-05-31  1:24                           ` Antony T Curtis
  2004-05-31  1:42                             ` Bartosz Fabianowski
@ 2004-06-02 23:18                             ` Juergen Lock
  2004-06-02 23:54                               ` [Qemu-devel] Re: qemu port Bartosz Fabianowski
  2004-06-05 21:04                               ` [Qemu-devel] FreeSBIE timer (was: Re: qemu port) Juergen Lock
  1 sibling, 2 replies; 32+ messages in thread
From: Juergen Lock @ 2004-06-02 23:18 UTC (permalink / raw)
  To: Antony T Curtis; +Cc: qemu-devel

On Mon, May 31, 2004 at 09:46:21AM +0000, Antony T Curtis wrote:
> ...

> Replace the rintl() function in target-i386/op.c with the following:
> 
> CPU86_LDouble rintl(CPU86_LDouble __x) {
>   register CPU86_LDouble __result;
>   __asm __volatile__ ("frndint" : "=t" (__result) : "0" (__x));
>   return __result;
> }

OK, I've now taken this and the other FreeBSD patches, added a few
small ones of my own and made a port, it can be fetched at
	http://www.freebsd.org/cgi/query-pr.cgi?pr=67506&f=raw
(and hopefully will be committed soon.)

 I've noticed the following things tho:

- needs to run as root in order to use /dev/tap* networking (why?)
- slirp (usermode networking) compiles but doesn't seem to work for me
- seems to have a timer problem (time sleep 1 takes 49 seconds and
booting sleeps for minutes at the acd0 probe), but only on _some_ guest
systems (FreeSBIE, knoppix.)  An installed 5.2.1 guest system works ok
(this also doesn't happen with linux as host.)  And enabling /dev/rtc doesn't
help either... (not included since it needs a patch to emulators/rtc.)
- using physical media doesn't work on 4.x hosts (missing DIOCGMEDIASIZE
ioctl)

 Testers and anyone who has ideas about these problems welcome...

	Juergen

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [Qemu-devel] Re: qemu port
  2004-06-02 23:18                             ` qemu port (was: Re: [Qemu-devel] Running QEMU on FreeBSD) Juergen Lock
@ 2004-06-02 23:54                               ` Bartosz Fabianowski
  2004-06-03 17:10                                 ` Gianni Tedesco
  2004-06-04 18:44                                 ` Juergen Lock
  2004-06-05 21:04                               ` [Qemu-devel] FreeSBIE timer (was: Re: qemu port) Juergen Lock
  1 sibling, 2 replies; 32+ messages in thread
From: Bartosz Fabianowski @ 2004-06-02 23:54 UTC (permalink / raw)
  To: qemu-devel

> OK, I've now taken this and the other FreeBSD patches, added a few 
> small ones of my own and made a port [...]

Awesome! A port was my original idea and the reason for why I started
tinkering with QEMU in the first place.

> - needs to run as root in order to use /dev/tap* networking (why?)

I haven't looked at your port yet, but my own compilation of QEMU has
the same problem. It seems to me that this is because on each
invocation, QEMU creates a new tap device. Just run QEMU a few times (as
root) and then look at the output of ifconfig. Each invocation will have
produced a new tap device. Since normal users probably have no
permission to create device nodes, QEMU fails to create its required tap
device and therefore tap networking doesn't work. A fix for this would
be to create a certain amount of tap device nodes at FreeBSD start up
and then to have QEMU recycle the nodes it doesn't need any more. Then
again, maybe I am totally wrong on what is causing this.

> - using physical media doesn't work on 4.x hosts (missing
> DIOCGMEDIASIZE ioctl)

This is the place where it's actually used:

if (ioctl(fd, DIOCGMEDIASIZE, (off_t *)&size))
     size = lseek(fd, 0LL, SEEK_END);

This ioctl checks whether the total size of the medium can be retrieved
and thus only succeeds if there is a medium in the drive. So the ioctl
effectively just checks whether there is a medium. The size is then
retrieved separately using lseek.

I haven't tried compiling or running this, but my idea would be to try
something like this instead:
     if((size = lseek(fd, 0LL, SEEK_END)) < 0)
         size = 0;

Now, lseek is always called. If there is no medium, lseek should fail,
returning some negative value. In this case, the size is set to zero to
indicate failure. Otherwise, the size determined by lseek is used.

- Bartosz

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [Qemu-devel] Re: qemu port
  2004-06-02 23:54                               ` [Qemu-devel] Re: qemu port Bartosz Fabianowski
@ 2004-06-03 17:10                                 ` Gianni Tedesco
  2004-06-04 18:44                                 ` Juergen Lock
  1 sibling, 0 replies; 32+ messages in thread
From: Gianni Tedesco @ 2004-06-03 17:10 UTC (permalink / raw)
  To: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 524 bytes --]

On Thu, 2004-06-03 at 01:54 +0200, Bartosz Fabianowski wrote:
> I haven't tried compiling or running this, but my idea would be to try
> something like this instead:
>      if((size = lseek(fd, 0LL, SEEK_END)) < 0)
>          size = 0;

This is the preferred method in Linux now aswell (over and above
BLKGETSIZE(64) ioctls).

-- 
// Gianni Tedesco (gianni at scaramanga dot co dot uk)
lynx --source www.scaramanga.co.uk/scaramanga.asc | gpg --import
8646BE7D: 6D9F 2287 870E A2C9 8F60 3A3C 91B5 7669 8646 BE7D

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [Qemu-devel] Re: qemu port
  2004-06-02 23:54                               ` [Qemu-devel] Re: qemu port Bartosz Fabianowski
  2004-06-03 17:10                                 ` Gianni Tedesco
@ 2004-06-04 18:44                                 ` Juergen Lock
  1 sibling, 0 replies; 32+ messages in thread
From: Juergen Lock @ 2004-06-04 18:44 UTC (permalink / raw)
  To: Bartosz Fabianowski; +Cc: qemu-devel

On Thu, Jun 03, 2004 at 12:21:27AM +0000, Bartosz Fabianowski wrote:
> > OK, I've now taken this and the other FreeBSD patches, added a few 
> > small ones of my own and made a port [...]
> 
> Awesome! A port was my original idea and the reason for why I started
> tinkering with QEMU in the first place.
> 
> > - needs to run as root in order to use /dev/tap* networking (why?)
> 
> I haven't looked at your port yet, but my own compilation of QEMU has
> the same problem.  ...

Problem solved: its a redundant(?) uid check in the if_tap module
(btw at least on 4.9 i have to cycle thru the available /dev/tap[0123]
device nodes myself, see patch-bt)

> > - using physical media doesn't work on 4.x hosts (missing
> > DIOCGMEDIASIZE ioctl)
> 
> This is the place where it's actually used:
> 
> if (ioctl(fd, DIOCGMEDIASIZE, (off_t *)&size))
>      size = lseek(fd, 0LL, SEEK_END);
> 
> This ioctl checks whether the total size of the medium can be retrieved
> and thus only succeeds if there is a medium in the drive. So the ioctl
> effectively just checks whether there is a medium. The size is then
> retrieved separately using lseek.
>...

 Heh. :)  No.  ioctl() returns 0 on success not on failure, so
only if the ioctl fails is the size retrieved via lseek (and this
lseek method doesnt work on pyhsical devices, therefore the ioctl.)

	Juergen

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [Qemu-devel] FreeSBIE timer (was: Re: qemu port)
  2004-06-02 23:18                             ` qemu port (was: Re: [Qemu-devel] Running QEMU on FreeBSD) Juergen Lock
  2004-06-02 23:54                               ` [Qemu-devel] Re: qemu port Bartosz Fabianowski
@ 2004-06-05 21:04                               ` Juergen Lock
  1 sibling, 0 replies; 32+ messages in thread
From: Juergen Lock @ 2004-06-05 21:04 UTC (permalink / raw)
  To: qemu-devel

In article <20040603011805.A40432@saturn.kn-bremen.de> I wrioe:
>...
>- seems to have a timer problem (time sleep 1 takes 49 seconds and
>booting sleeps for minutes at the acd0 probe), but only on _some_ guest
>systems (FreeSBIE, knoppix.)  An installed 5.2.1 guest system works ok
>(this also doesn't happen with linux as host.)  And enabling /dev/rtc doesn't
>help either... (not included since it needs a patch to emulators/rtc.)

I finally found out whats going on there by looking at the FreeSBIE
kernel config:
	http://cvs.gufi.org/cgi/cvsweb.cgi/freesbie/files/FREESBIE.5?rev=1.15&content-type=text/x-cvsweb-markup
 It uses:
	options	    HZ=5000

 And the on the linux host the problem is just less obvious because
I'm running a 2.6 kernel there which by default uses 1000 (AFAIK),
instead of 100 like FreeBSD by default uses.

 Heh :)
	Juergen

^ permalink raw reply	[flat|nested] 32+ messages in thread

end of thread, other threads:[~2004-06-05 21:01 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-05-29 21:25 [Qemu-devel] Running QEMU on FreeBSD Antony T Curtis
2004-05-29 21:39 ` Bartosz Fabianowski
2004-05-29 21:50   ` Antony T Curtis
2004-05-29 21:58     ` Bartosz Fabianowski
2004-05-29 22:09       ` Antony T Curtis
2004-05-29 22:24         ` Bartosz Fabianowski
2004-05-29 23:09           ` Antony T Curtis
2004-05-30  3:53             ` Antony T Curtis
2004-05-30  7:25             ` Markus Niemistö
2004-05-30  9:50               ` Antony T Curtis
2004-05-30 14:41                 ` Bartosz Fabianowski
2004-05-30 17:27                   ` Antony T Curtis
2004-05-30 18:57                     ` Bartosz Fabianowski
2004-05-30 20:09                       ` Antony T Curtis
2004-05-31  0:36                         ` Bartosz Fabianowski
2004-05-31  1:24                           ` Antony T Curtis
2004-05-31  1:42                             ` Bartosz Fabianowski
2004-05-31  1:59                               ` Kyle Hayes
2004-05-31 12:15                                 ` Bartosz Fabianowski
2004-05-31 13:22                                   ` Antony T Curtis
2004-05-31  9:38                               ` Antony T Curtis
2004-05-31 20:36                                 ` Bartosz Fabianowski
2004-05-31 13:54                               ` Antony T Curtis
2004-05-31 20:31                                 ` Bartosz Fabianowski
2004-05-31 22:15                                   ` Antony T Curtis
2004-05-31 22:56                               ` Brion Vibber
2004-05-31 23:01                                 ` Bartosz Fabianowski
2004-06-02 23:18                             ` qemu port (was: Re: [Qemu-devel] Running QEMU on FreeBSD) Juergen Lock
2004-06-02 23:54                               ` [Qemu-devel] Re: qemu port Bartosz Fabianowski
2004-06-03 17:10                                 ` Gianni Tedesco
2004-06-04 18:44                                 ` Juergen Lock
2004-06-05 21:04                               ` [Qemu-devel] FreeSBIE timer (was: Re: qemu port) Juergen Lock

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).