Hi,
Here are some patches to get libvirt building on OpenBSD. I tested basic functionality
with virt-manager though there appear to be some rough edges to fix/polish (could also be
in virt-manager). At least basic libvirt usage should work on OpenBSD now.
Jasper Lievisse Adriaanse (4):
Define DYNLIB_NAME on OpenBSD.
Fixup some headers in virnetdevbridge.c, needed for OpenBSD.
Check for sys/ucred.h and adjust virnetsocket.c for OpenBSD
compilation.
There's no librt on OpenBSD.
configure.ac | 10 ++++++++--
src/rpc/virnetsocket.c | 10 ++++++++++
src/util/virnetdevbridge.c | 9 +++++++++
src/vbox/vbox_XPCOMCGlue.c | 2 +-
4 files changed, 28 insertions(+), 3 deletions(-)
--
1.7.6
Show replies by date
---
src/vbox/vbox_XPCOMCGlue.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/vbox/vbox_XPCOMCGlue.c b/src/vbox/vbox_XPCOMCGlue.c
index e7e9c37..63470ae 100644
--- a/src/vbox/vbox_XPCOMCGlue.c
+++ b/src/vbox/vbox_XPCOMCGlue.c
@@ -48,7 +48,7 @@
/*******************************************************************************
* Defined Constants And Macros *
*******************************************************************************/
-#if defined(__linux__) || defined(__linux_gnu__) || defined(__sun__) ||
defined(__FreeBSD__)
+#if defined(__linux__) || defined(__linux_gnu__) || defined(__sun__) ||
defined(__FreeBSD__) || defined(__OpenBSD__)
# define DYNLIB_NAME "VBoxXPCOMC.so"
#elif defined(__APPLE__)
# define DYNLIB_NAME "VBoxXPCOMC.dylib"
--
1.7.6
---
src/util/virnetdevbridge.c | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/src/util/virnetdevbridge.c b/src/util/virnetdevbridge.c
index 7b11bee..8559223 100644
--- a/src/util/virnetdevbridge.c
+++ b/src/util/virnetdevbridge.c
@@ -30,6 +30,15 @@
#include "intprops.h"
#include <sys/ioctl.h>
+
+#ifdef HAVE_SYS_PARAM_H
+# include <sys/param.h>
+#endif
+
+#ifdef HAVE_SYS_SOCKET_H
+# include <sys/socket.h>
+#endif
+
#ifdef HAVE_NET_IF_H
# include <net/if.h>
#endif
--
1.7.6
---
configure.ac | 2 +-
src/rpc/virnetsocket.c | 10 ++++++++++
2 files changed, 11 insertions(+), 1 deletions(-)
diff --git a/configure.ac b/configure.ac
index e0d00d5..7ba1e9c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -197,7 +197,7 @@ dnl Availability of various common headers (non-fatal if missing).
AC_CHECK_HEADERS([pwd.h paths.h regex.h sys/un.h \
sys/poll.h syslog.h mntent.h net/ethernet.h linux/magic.h \
sys/un.h sys/syscall.h netinet/tcp.h ifaddrs.h libtasn1.h \
- net/if.h execinfo.h])
+ net/if.h execinfo.h sys/ucred.h])
dnl We need to decide at configure time if libvirt will use real atomic
dnl operations ("lock free") or emulated ones with a mutex.
diff --git a/src/rpc/virnetsocket.c b/src/rpc/virnetsocket.c
index 5a48300..0457710 100644
--- a/src/rpc/virnetsocket.c
+++ b/src/rpc/virnetsocket.c
@@ -31,6 +31,10 @@
#include <fcntl.h>
#include <netdb.h>
+#ifdef HAVE_SYS_UCRED_H
+# include <sys/ucred.h>
+#endif
+
#ifdef HAVE_NETINET_TCP_H
# include <netinet/tcp.h>
#endif
@@ -999,9 +1003,15 @@ int virNetSocketGetUNIXIdentity(virNetSocketPtr sock,
return -1;
}
+#if defined(__OpenBSD__)
+ *pid = getpid();
+ *uid = cr.cr_uid;
+ *gid = cr.cr_gid;
+#else
*pid = cr.pid;
*uid = cr.uid;
*gid = cr.gid;
+#endif
virMutexUnlock(&sock->lock);
return 0;
--
1.7.6
---
configure.ac | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/configure.ac b/configure.ac
index 7ba1e9c..701ab50 100644
--- a/configure.ac
+++ b/configure.ac
@@ -188,7 +188,13 @@ RT_LIBS=
LIBS="$LIBS $LIB_PTHREAD -lrt"
AC_CHECK_FUNC([clock_gettime],[
AC_DEFINE([HAVE_CLOCK_GETTIME],[],[Defined if clock_gettime() exists in librt.so])
- RT_LIBS=-lrt
+ case "$host" in
+ *-*-openbsd*)
+ ;;
+ *)
+ RT_LIBS=-lrt
+ ;;
+ esac
])
LIBS=$old_libs
AC_SUBST(RT_LIBS)
--
1.7.6