Patchwork Patches for OpenBSD support.

login
register
mail settings
Submitter Brad
Date Dec. 19, 2010, 8:59 p.m.
Message ID <20101219205958.GA30398@rox.home.comstyle.com>
Download mbox | patch
Permalink /patch/76156/
State New
Headers show

Comments

Brad - Dec. 19, 2010, 8:59 p.m.
Here are a few patches for OpenBSD support.


From 0477858c78d7e377bf6db8a498f7745a937c799d Mon Sep 17 00:00:00 2001
From: Brad Smith <brad@comstyle.com>
Date: Sun, 19 Dec 2010 15:17:42 -0500
Subject: [PATCH 1/3] Add support for OpenBSD to QEMU's tap driver.

---
 net/tap-bsd.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
Blue Swirl - Dec. 20, 2010, 8:24 p.m.
On Sun, Dec 19, 2010 at 8:59 PM, Brad <brad@comstyle.com> wrote:
> Here are a few patches for OpenBSD support.

Thanks. Could you resend each patch separately and add Signed-off-by:
Brad Smith <brad@comstyle.com> line before '---' line?

Patch

diff --git a/net/tap-bsd.c b/net/tap-bsd.c
index efccfe0..2f3efde 100644
--- a/net/tap-bsd.c
+++ b/net/tap-bsd.c
@@ -43,8 +43,8 @@  int tap_open(char *ifname, int ifname_size, int *vnet_hdr, int vnet_hdr_required
     char *dev;
     struct stat s;
 
-#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
-    /* if no ifname is given, always start the search from tap0. */
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__)
+    /* if no ifname is given, always start the search from tap0/tun0. */
     int i;
     char dname[100];
 
@@ -52,7 +52,11 @@  int tap_open(char *ifname, int ifname_size, int *vnet_hdr, int vnet_hdr_required
         if (*ifname) {
             snprintf(dname, sizeof dname, "/dev/%s", ifname);
         } else {
+#if defined(__OpenBSD__)
+            snprintf(dname, sizeof dname, "/dev/tun%d", i);
+#else
             snprintf(dname, sizeof dname, "/dev/tap%d", i);
+#endif
         }
         TFR(fd = open(dname, O_RDWR));
         if (fd >= 0) {
-- 
1.7.3.2


From e3461ce0a937e18d09375a3ec51eed9ad052da49 Mon Sep 17 00:00:00 2001
From: Brad Smith <brad@comstyle.com>
Date: Sun, 19 Dec 2010 15:19:02 -0500
Subject: [PATCH 2/3] Add OpenBSD to ifdef list since it has CLOCK_MONOTONIC.

---
 qemu-timer-common.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/qemu-timer-common.c b/qemu-timer-common.c
index fff4399..755e300 100644
--- a/qemu-timer-common.c
+++ b/qemu-timer-common.c
@@ -50,7 +50,8 @@  static void __attribute__((constructor)) init_get_clock(void)
 {
     use_rt_clock = 0;
 #if defined(__linux__) || (defined(__FreeBSD__) && __FreeBSD_version >= 500000) \
-    || defined(__DragonFly__) || defined(__FreeBSD_kernel__)
+    || defined(__DragonFly__) || defined(__FreeBSD_kernel__) \
+    || defined(__OpenBSD__)
     {
         struct timespec ts;
         if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0) {
-- 
1.7.3.2


From 1931e76a3452dc7cf83fa4023d3b2d6e28a9d7b6 Mon Sep 17 00:00:00 2001
From: Brad Smith <brad@comstyle.com>
Date: Sun, 19 Dec 2010 15:21:21 -0500
Subject: [PATCH 3/3] Use mmap() within code_gen_alloc() for OpenBSD.

---
 exec.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/exec.c b/exec.c
index 42a35e0..e513d16 100644
--- a/exec.c
+++ b/exec.c
@@ -517,7 +517,8 @@  static void code_gen_alloc(unsigned long tb_size)
             exit(1);
         }
     }
-#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
+#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) \
+    || defined(__DragonFly__) || defined(__OpenBSD__)
     {
         int flags;
         void *addr = NULL;