All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] Support for DragonFly BSD
@ 2009-03-06  9:12 Hasso Tepper
  2009-03-06  9:37 ` malc
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Hasso Tepper @ 2009-03-06  9:12 UTC (permalink / raw)
  To: qemu-devel

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

The attached patch against trunk allows qemu to compile and work on 
DragonFly BSD platform (BSD usermode emulation targets disabled though). 
The patch is mostly straightforward, only few comments.

* Missing "monitor.h" include is a recent regression in trunk and with 
  this snippet removed the patch applies cleanly to the 0.10.0.

* Using /usr/bin/env should be generally a good idea. Most systems besides 
  Linux doesn't have perl in /usr/bin.


regards,
 
-- 
Hasso Tepper

[-- Attachment #2: qemu-dragonfly-support.patch --]
[-- Type: text/x-diff, Size: 8874 bytes --]

Index: savevm.c
===================================================================
--- savevm.c	(revision 6718)
+++ savevm.c	(working copy)
@@ -63,7 +63,7 @@
 #include <sys/select.h>
 #ifdef _BSD
 #include <sys/stat.h>
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__DragonFly__)
 #include <libutil.h>
 #else
 #include <util.h>
Index: usb-bsd.c
===================================================================
--- usb-bsd.c	(revision 6718)
+++ usb-bsd.c	(working copy)
@@ -27,6 +27,7 @@
 #include "qemu-common.h"
 #include "console.h"
 #include "hw/usb.h"
+#include "monitor.h"
 
 /* usb.h declares these */
 #undef USB_SPEED_HIGH
@@ -34,7 +35,11 @@
 #undef USB_SPEED_LOW
 
 #include <sys/ioctl.h>
+#ifndef __DragonFly__
 #include <dev/usb/usb.h>
+#else
+#include <bus/usb/usb.h>
+#endif
 #include <signal.h>
 
 /* This value has maximum potential at 16.
@@ -68,7 +73,7 @@ static int ensure_ep_open(USBHostDevice 
     ep = UE_GET_ADDR(ep);
 
     if (dev->ep_fd[ep] < 0) {
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__DragonFly__)
         snprintf(buf, sizeof(buf) - 1, "%s.%d", dev->devpath, ep);
 #else
         snprintf(buf, sizeof(buf) - 1, "%s.%02d", dev->devpath, ep);
@@ -321,7 +326,7 @@ USBDevice *usb_host_device_open(const ch
         return NULL;
     }
 
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || 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]);
@@ -411,7 +416,7 @@ static int usb_host_scan(void *opaque, U
             if (strncmp(bus_info.udi_devnames[0], "ugen", 4) != 0)
                 continue;
 
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || 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]);
Index: osdep.c
===================================================================
--- osdep.c	(revision 6718)
+++ osdep.c	(working copy)
@@ -90,7 +90,7 @@ static void *kqemu_vmalloc(size_t size)
     void *ptr;
 
 /* no need (?) for a dummy file on OpenBSD/FreeBSD */
-#if defined(__OpenBSD__) || defined(__FreeBSD__)
+#if defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__DragonFly__)
     int map_anon = MAP_ANON;
 #else
     int map_anon = 0;
@@ -157,7 +157,7 @@ static void *kqemu_vmalloc(size_t size)
     }
     size = (size + 4095) & ~4095;
     ftruncate(phys_ram_fd, phys_ram_size + size);
-#endif /* !(__OpenBSD__ || __FreeBSD__) */
+#endif /* !(__OpenBSD__ || __FreeBSD__ || __DragonFly__) */
     ptr = mmap(NULL,
                size,
                PROT_WRITE | PROT_READ, map_anon | MAP_SHARED,
Index: vl.c
===================================================================
--- vl.c	(revision 6718)
+++ vl.c	(working copy)
@@ -75,7 +75,7 @@
 #include <sys/select.h>
 #ifdef _BSD
 #include <sys/stat.h>
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__DragonFly__)
 #include <libutil.h>
 #else
 #include <util.h>
@@ -756,7 +756,8 @@ static int use_rt_clock;
 static void init_get_clock(void)
 {
     use_rt_clock = 0;
-#if defined(__linux__) || (defined(__FreeBSD__) && __FreeBSD_version >= 500000)
+#if defined(__linux__) || (defined(__FreeBSD__) && __FreeBSD_version >= 500000) \
+    || defined(__DragonFly__)
     {
         struct timespec ts;
         if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0) {
@@ -768,7 +769,8 @@ static void init_get_clock(void)
 
 static int64_t get_clock(void)
 {
-#if defined(__linux__) || (defined(__FreeBSD__) && __FreeBSD_version >= 500000)
+#if defined(__linux__) || (defined(__FreeBSD__) && __FreeBSD_version >= 500000) \
+	|| defined(__DragonFly__)
     if (use_rt_clock) {
         struct timespec ts;
         clock_gettime(CLOCK_MONOTONIC, &ts);
Index: block-raw-posix.c
===================================================================
--- block-raw-posix.c	(revision 6718)
+++ block-raw-posix.c	(working copy)
@@ -63,6 +63,11 @@
 #include <sys/dkio.h>
 #endif
 
+#ifdef __DragonFly__
+#include <sys/ioctl.h>
+#include <sys/diskslice.h>
+#endif
+
 //#define DEBUG_FLOPPY
 
 //#define DEBUG_BLOCK
@@ -762,6 +767,15 @@ static int64_t  raw_getlength(BlockDrive
     if (!fstat(fd, &sb) && (S_IFCHR & sb.st_mode)) {
 #ifdef DIOCGMEDIASIZE
 	if (ioctl(fd, DIOCGMEDIASIZE, (off_t *)&size))
+#elif defined(DIOCGPART)
+        {
+                struct partinfo pi;
+                if (ioctl(fd, DIOCGPART, &pi) == 0)
+                        size = pi.media_size;
+                else
+                        size = 0;
+        }
+        if (size == 0)
 #endif
 #ifdef CONFIG_COCOA
         size = LONG_LONG_MAX;
Index: net.c
===================================================================
--- net.c	(revision 6718)
+++ net.c	(working copy)
@@ -59,7 +59,7 @@
 #include <sys/select.h>
 #ifdef _BSD
 #include <sys/stat.h>
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__DragonFly__)
 #include <libutil.h>
 #else
 #include <util.h>
Index: audio/sdlaudio.c
===================================================================
--- audio/sdlaudio.c	(revision 6718)
+++ audio/sdlaudio.c	(working copy)
@@ -29,7 +29,7 @@
 #ifndef _WIN32
 #ifdef __sun__
 #define _POSIX_PTHREAD_SEMANTICS 1
-#elif defined(__OpenBSD__) || defined(__FreeBSD__)
+#elif defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__DragonFly__)
 #include <pthread.h>
 #endif
 #include <signal.h>
Index: qemu-char.c
===================================================================
--- qemu-char.c	(revision 6718)
+++ qemu-char.c	(working copy)
@@ -67,6 +67,10 @@
 #include <libutil.h>
 #include <dev/ppbus/ppi.h>
 #include <dev/ppbus/ppbconf.h>
+#elif defined(__DragonFly__)
+#include <libutil.h>
+#include <dev/misc/ppi/ppi.h>
+#include <bus/ppbus/ppbconf.h>
 #else
 #include <util.h>
 #endif
@@ -806,7 +810,7 @@ void cfmakeraw (struct termios *termios_
 #endif
 
 #if defined(__linux__) || defined(__sun__) || defined(__FreeBSD__) \
-    || defined(__NetBSD__) || defined(__OpenBSD__)
+    || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
 
 typedef struct {
     int fd;
@@ -934,7 +938,7 @@ static CharDriverState *qemu_chr_open_pt
     PtyCharDriver *s;
     struct termios tty;
     int slave_fd, len;
-#if defined(__OpenBSD__)
+#if defined(__OpenBSD__) || defined(__DragonFly__)
     char pty_name[PATH_MAX];
 #define q_ptsname(x) pty_name
 #else
@@ -1280,7 +1284,7 @@ static CharDriverState *qemu_chr_open_pp
 }
 #endif /* __linux__ */
 
-#if defined(__FreeBSD__)
+#if defined(__FreeBSD__) || defined(__DragonFly__)
 static int pp_ioctl(CharDriverState *chr, int cmd, void *arg)
 {
     int fd = (int)chr->opaque;
@@ -2153,13 +2157,13 @@ CharDriverState *qemu_chr_open(const cha
     if (strstart(filename, "/dev/parport", NULL)) {
         chr = qemu_chr_open_pp(filename);
     } else
-#elif defined(__FreeBSD__)
+#elif defined(__FreeBSD__) || defined(__DragonFly__)
     if (strstart(filename, "/dev/ppi", NULL)) {
         chr = qemu_chr_open_pp(filename);
     } else
 #endif
 #if defined(__linux__) || defined(__sun__) || defined(__FreeBSD__) \
-    || defined(__NetBSD__) || defined(__OpenBSD__)
+    || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
     if (strstart(filename, "/dev/", NULL)) {
         chr = qemu_chr_open_tty(filename);
     } else
Index: exec.c
===================================================================
--- exec.c	(revision 6718)
+++ exec.c	(working copy)
@@ -454,7 +454,7 @@ static void code_gen_alloc(unsigned long
             exit(1);
         }
     }
-#elif defined(__FreeBSD__)
+#elif defined(__FreeBSD__) || defined(__DragonFly__)
     {
         int flags;
         void *addr = NULL;
Index: texi2pod.pl
===================================================================
--- texi2pod.pl	(revision 6718)
+++ texi2pod.pl	(working copy)
@@ -1,4 +1,4 @@
-#! /usr/bin/perl -w
+#! /usr/bin/env perl -w
 
 #   Copyright (C) 1999, 2000, 2001, 2003 Free Software Foundation, Inc.
 
Index: block.c
===================================================================
--- block.c	(revision 6718)
+++ block.c	(working copy)
@@ -35,8 +35,10 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <sys/ioctl.h>
+#ifndef __DragonFly__
 #include <sys/disk.h>
 #endif
+#endif
 
 #define SECTOR_BITS 9
 #define SECTOR_SIZE (1 << SECTOR_BITS)
Index: configure
===================================================================
--- configure	(revision 6718)
+++ configure	(working copy)
@@ -228,6 +228,15 @@ if [ "$cpu" = "i386" -o "$cpu" = "x86_64
     kqemu="yes"
 fi
 ;;
+DragonFly)
+bsd="yes"
+audio_drv_list="oss"
+audio_possible_drivers="oss sdl esd pa"
+if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
+    kqemu="yes"
+fi
+aio="no"
+;;
 NetBSD)
 bsd="yes"
 audio_drv_list="oss"

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

* Re: [Qemu-devel] [PATCH] Support for DragonFly BSD
  2009-03-06  9:12 [Qemu-devel] [PATCH] Support for DragonFly BSD Hasso Tepper
@ 2009-03-06  9:37 ` malc
  2009-03-06 16:36 ` François Revol
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 10+ messages in thread
From: malc @ 2009-03-06  9:37 UTC (permalink / raw)
  To: qemu-devel

On Fri, 6 Mar 2009, Hasso Tepper wrote:

> The attached patch against trunk allows qemu to compile and work on 
> DragonFly BSD platform (BSD usermode emulation targets disabled though). 
> The patch is mostly straightforward, only few comments.
> 
> * Missing "monitor.h" include is a recent regression in trunk and with 
>   this snippet removed the patch applies cleanly to the 0.10.0.
> 
> * Using /usr/bin/env should be generally a good idea. Most systems besides 
>   Linux doesn't have perl in /usr/bin.

Neither is any good actually - NFS unfriendly. Makefile should be changed
instead to run perl on texi2pod.

-- 
mailto:av1474@comtv.ru

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

* Re: [Qemu-devel] [PATCH] Support for DragonFly BSD
  2009-03-06  9:12 [Qemu-devel] [PATCH] Support for DragonFly BSD Hasso Tepper
  2009-03-06  9:37 ` malc
@ 2009-03-06 16:36 ` François Revol
  2009-03-07 10:09 ` Blue Swirl
  2009-03-07 20:11 ` Blue Swirl
  3 siblings, 0 replies; 10+ messages in thread
From: François Revol @ 2009-03-06 16:36 UTC (permalink / raw)
  To: Hasso Tepper; +Cc: qemu-devel

> * Using /usr/bin/env should be generally a good idea. Most systems
> besides
>   Linux doesn't have perl in /usr/bin.

While it's an interesting idea in princible, I found it not working any
better than hardcoding perl or python paths itself... For example, BeOS
has no /usr at all, and has env in /bin, which makes it useless for
really cross-platform use... (it's beyond me why env is not in /bin/
elsewhere anyway.)

Just my 2c.

François.

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

* Re: [Qemu-devel] [PATCH] Support for DragonFly BSD
  2009-03-06  9:12 [Qemu-devel] [PATCH] Support for DragonFly BSD Hasso Tepper
  2009-03-06  9:37 ` malc
  2009-03-06 16:36 ` François Revol
@ 2009-03-07 10:09 ` Blue Swirl
  2009-03-07 20:11 ` Blue Swirl
  3 siblings, 0 replies; 10+ messages in thread
From: Blue Swirl @ 2009-03-07 10:09 UTC (permalink / raw)
  To: qemu-devel

On 3/6/09, Hasso Tepper <hasso@estpak.ee> wrote:
> The attached patch against trunk allows qemu to compile and work on
>  DragonFly BSD platform (BSD usermode emulation targets disabled though).
>  The patch is mostly straightforward, only few comments.
>
>  * Missing "monitor.h" include is a recent regression in trunk and with
>   this snippet removed the patch applies cleanly to the 0.10.0.

We can remove the console.h include as well. I'll commit my fix for this next.

>  * Using /usr/bin/env should be generally a good idea. Most systems besides
>   Linux doesn't have perl in /usr/bin.

Based on the discussions, I think this part should not be applied.

Other parts look OK.

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

* Re: [Qemu-devel] [PATCH] Support for DragonFly BSD
  2009-03-06  9:12 [Qemu-devel] [PATCH] Support for DragonFly BSD Hasso Tepper
                   ` (2 preceding siblings ...)
  2009-03-07 10:09 ` Blue Swirl
@ 2009-03-07 20:11 ` Blue Swirl
  2009-03-08 15:11   ` Hasso Tepper
  3 siblings, 1 reply; 10+ messages in thread
From: Blue Swirl @ 2009-03-07 20:11 UTC (permalink / raw)
  To: qemu-devel

On 3/6/09, Hasso Tepper <hasso@estpak.ee> wrote:
> The attached patch against trunk allows qemu to compile and work on
>  DragonFly BSD platform (BSD usermode emulation targets disabled though).
>  The patch is mostly straightforward, only few comments.
>
>  * Missing "monitor.h" include is a recent regression in trunk and with
>   this snippet removed the patch applies cleanly to the 0.10.0.
>
>  * Using /usr/bin/env should be generally a good idea. Most systems besides
>   Linux doesn't have perl in /usr/bin.

Applied except for the env part, thanks.

Maybe configure should determine the location of Perl and generate
some PERL_PATH stuff in config.mak.

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

* Re: [Qemu-devel] [PATCH] Support for DragonFly BSD
  2009-03-07 20:11 ` Blue Swirl
@ 2009-03-08 15:11   ` Hasso Tepper
  2009-03-08 15:48     ` Andreas Färber
  0 siblings, 1 reply; 10+ messages in thread
From: Hasso Tepper @ 2009-03-08 15:11 UTC (permalink / raw)
  To: qemu-devel

Blue Swirl wrote:
> Applied except for the env part, thanks.

To the 0.10.0 branch as well, please? :)

> Maybe configure should determine the location of Perl and generate
> some PERL_PATH stuff in config.mak.

Yeah, probably the best way. I only wonder what's the portable way to 
determine the location of perl.


regards,

-- 
Hasso Tepper

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

* Re: [Qemu-devel] [PATCH] Support for DragonFly BSD
  2009-03-08 15:11   ` Hasso Tepper
@ 2009-03-08 15:48     ` Andreas Färber
  2009-03-08 16:10       ` Blue Swirl
  0 siblings, 1 reply; 10+ messages in thread
From: Andreas Färber @ 2009-03-08 15:48 UTC (permalink / raw)
  To: qemu-devel


Am 08.03.2009 um 16:11 schrieb Hasso Tepper:

> Blue Swirl wrote:
>> Maybe configure should determine the location of Perl and generate
>> some PERL_PATH stuff in config.mak.
>
> Yeah, probably the best way. I only wonder what's the portable way to
> determine the location of perl.

Some sequence like this?

-perl=/my/perl
$PERL
/usr/bin/env perl
`which perl`
/usr/bin/perl

Andreas

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

* Re: [Qemu-devel] [PATCH] Support for DragonFly BSD
  2009-03-08 15:48     ` Andreas Färber
@ 2009-03-08 16:10       ` Blue Swirl
  2009-03-08 16:20         ` Hasso Tepper
  2009-03-08 18:54         ` malc
  0 siblings, 2 replies; 10+ messages in thread
From: Blue Swirl @ 2009-03-08 16:10 UTC (permalink / raw)
  To: qemu-devel

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

On 3/8/09, Andreas Färber <andreas.faerber@web.de> wrote:
>
>  Am 08.03.2009 um 16:11 schrieb Hasso Tepper:
>
>
> > Blue Swirl wrote:
> >
> > > Maybe configure should determine the location of Perl and generate
> > > some PERL_PATH stuff in config.mak.
> > >
> >
> > Yeah, probably the best way. I only wonder what's the portable way to
> > determine the location of perl.
> >
>
>  Some sequence like this?
>
>  -perl=/my/perl
>  $PERL
>  /usr/bin/env perl
>  `which perl`
>  /usr/bin/perl

How about this patch instead? Perl should be in $PATH. If not, PEBKAC.

[-- Attachment #2: fix_perl.diff --]
[-- Type: plain/text, Size: 836 bytes --]

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

* Re: [Qemu-devel] [PATCH] Support for DragonFly BSD
  2009-03-08 16:10       ` Blue Swirl
@ 2009-03-08 16:20         ` Hasso Tepper
  2009-03-08 18:54         ` malc
  1 sibling, 0 replies; 10+ messages in thread
From: Hasso Tepper @ 2009-03-08 16:20 UTC (permalink / raw)
  To: qemu-devel

Blue Swirl wrote:
> How about this patch instead? Perl should be in $PATH. If not, PEBKAC.

I agree.


-- 
Hasso Tepper

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

* Re: [Qemu-devel] [PATCH] Support for DragonFly BSD
  2009-03-08 16:10       ` Blue Swirl
  2009-03-08 16:20         ` Hasso Tepper
@ 2009-03-08 18:54         ` malc
  1 sibling, 0 replies; 10+ messages in thread
From: malc @ 2009-03-08 18:54 UTC (permalink / raw)
  To: qemu-devel

[-- Attachment #1: Type: TEXT/PLAIN, Size: 720 bytes --]

On Sun, 8 Mar 2009, Blue Swirl wrote:

> On 3/8/09, Andreas FЪЪrber <andreas.faerber@web.de> wrote:
> >
> >  Am 08.03.2009 um 16:11 schrieb Hasso Tepper:
> >
> >
> > > Blue Swirl wrote:
> > >
> > > > Maybe configure should determine the location of Perl and generate
> > > > some PERL_PATH stuff in config.mak.
> > > >
> > >
> > > Yeah, probably the best way. I only wonder what's the portable way to
> > > determine the location of perl.
> > >
> >
> >  Some sequence like this?
> >
> >  -perl=/my/perl
> >  $PERL
> >  /usr/bin/env perl
> >  `which perl`
> >  /usr/bin/perl
> 
> How about this patch instead? Perl should be in $PATH. If not, PEBKAC.

Looks good.

-- 
mailto:av1474@comtv.ru

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

end of thread, other threads:[~2009-03-08 18:54 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-03-06  9:12 [Qemu-devel] [PATCH] Support for DragonFly BSD Hasso Tepper
2009-03-06  9:37 ` malc
2009-03-06 16:36 ` François Revol
2009-03-07 10:09 ` Blue Swirl
2009-03-07 20:11 ` Blue Swirl
2009-03-08 15:11   ` Hasso Tepper
2009-03-08 15:48     ` Andreas Färber
2009-03-08 16:10       ` Blue Swirl
2009-03-08 16:20         ` Hasso Tepper
2009-03-08 18:54         ` malc

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.