Skip to contentSkip to conversation

Patches for OpenBSD support.

Qemu-devel Brad 2 participants 2 messages Dec 19, 2010 – Dec 20, 2010 Networking

lore
Share & tools
lore

Brad

author
#0 lore raw

Here are a few patches for OpenBSD support.

Quoted 1 line

From 0477858c78d7e377bf6db8a498f7745a937c799d Mon Sep 17 00:00:00 2001

From: Brad Smith <[email protected]>
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(-)
net/tap-bsd.c +6 -2
index efccfe0..2f3efde 100644
@@ -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) {
Signature · 1 line
1.7.3.2
Quoted 1 line

From e3461ce0a937e18d09375a3ec51eed9ad052da49 Mon Sep 17 00:00:00 2001

From: Brad Smith <[email protected]>
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(-)
qemu-timer-common.c +2 -1
index fff4399..755e300 100644
@@ -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) {
Signature · 1 line
1.7.3.2
Quoted 1 line

From 1931e76a3452dc7cf83fa4023d3b2d6e28a9d7b6 Mon Sep 17 00:00:00 2001

From: Brad Smith <[email protected]>
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(-)
exec.c +2 -1
index 42a35e0..e513d16 100644
@@ -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;
Signature · 7 lines
1.7.3.2


-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
#1 lore raw
Quoted 1 line · Brad

Here are a few patches for OpenBSD support.

Thanks. Could you resend each patch separately and add Signed-off-by:
Brad Smith <[email protected]> line before '---' line?