[libvirt] [PATCH 0/2] qemu driver FreeBSD support: fix compilation, second round

Second version of the patch which addresses issues pointed out by the reviewers. Roman Bogorodskiy (2): Drop mntent.h include. Qemu FreeBSD: fix compilation configure.ac | 42 ++++++++++++++++++++++++++++++------------ src/qemu/qemu_conf.c | 1 - src/qemu/qemu_process.c | 12 +++++++++++- src/util/virinitctl.c | 9 +++++++++ 4 files changed, 50 insertions(+), 14 deletions(-) -- 1.7.11.5

It's no longer used and also causes build fail on FreeBSD. --- src/qemu/qemu_conf.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 8d380a1..e95609c 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -34,7 +34,6 @@ #include <sys/wait.h> #include <arpa/inet.h> #include <sys/utsname.h> -#include <mntent.h> #include "virterror_internal.h" #include "qemu_conf.h" -- 1.7.11.5

On Wed, Dec 12, 2012 at 11:44:20AM +0400, Roman Bogorodskiy wrote:
It's no longer used and also causes build fail on FreeBSD. --- src/qemu/qemu_conf.c | 1 - 1 file changed, 1 deletion(-)
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 8d380a1..e95609c 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -34,7 +34,6 @@ #include <sys/wait.h> #include <arpa/inet.h> #include <sys/utsname.h> -#include <mntent.h>
#include "virterror_internal.h" #include "qemu_conf.h"
ACK Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

* Autotools changes: - Don't assume Qemu is Linux-only - Check Linux headers only on Linux - Disable firewalld on FreeBSD * Initctl: Initctl seem to present only on Linux, so stub it on other platforms * Raw I/O: Linux-only as well * Headers cleanup --- configure.ac | 42 ++++++++++++++++++++++++++++++------------ src/qemu/qemu_process.c | 12 +++++++++++- src/util/virinitctl.c | 9 +++++++++ 3 files changed, 50 insertions(+), 13 deletions(-) diff --git a/configure.ac b/configure.ac index a695e52..bf32f95 100644 --- a/configure.ac +++ b/configure.ac @@ -360,10 +360,11 @@ dnl are also linux specific. The "network" and storage_fs drivers are known dnl to not work on MacOS X presently, so we also make a note if compiling dnl for that -with_linux=no with_osx=no +with_linux=no with_osx=no with_freebsd=no case $host in *-*-linux*) with_linux=yes ;; *-*-darwin*) with_osx=yes ;; + *-*-freebsd*) with_freebsd=yes ;; esac if test $with_linux = no; then @@ -371,14 +372,19 @@ if test $with_linux = no; then then with_lxc=no fi - if test "x$with_qemu" != xyes - then - with_qemu=no - fi with_dtrace=no fi +if test $with_freebsd = yes; then + with_firewalld=no +fi + +if test $with_osx = yes; then + with_qemu=no +fi + AM_CONDITIONAL([WITH_LINUX], [test "$with_linux" = "yes"]) +AM_CONDITIONAL([WITH_FREEBSD], [test "$with_freebsd" = "yes"]) dnl Allow to build without Xen, QEMU/KVM, test or remote driver AC_ARG_WITH([xen], @@ -949,9 +955,11 @@ fi dnl dnl check for kernel headers required by src/bridge.c dnl -if test "$with_qemu" = "yes" || test "$with_lxc" = "yes" ; then - AC_CHECK_HEADERS([linux/param.h linux/sockios.h linux/if_bridge.h linux/if_tun.h],, - AC_MSG_ERROR([You must install kernel-headers in order to compile libvirt with QEMU or LXC support])) +if test "$with_linux" = "yes"; then + if test "$with_qemu" = "yes" || test "$with_lxc" = "yes" ; then + AC_CHECK_HEADERS([linux/param.h linux/sockios.h linux/if_bridge.h linux/if_tun.h],, + AC_MSG_ERROR([You must install kernel-headers in order to compile libvirt with QEMU or LXC support])) + fi fi @@ -2880,14 +2888,24 @@ if test "x$with_libblkid" = "xyes"; then fi AM_CONDITIONAL([HAVE_LIBBLKID], [test "x$with_libblkid" = "xyes"]) +if test $with_freebsd = yes; then + default_qemu_user=root + default_qemu_group=wheel +else + default_qemu_user=root + default_qemu_group=root +fi + AC_ARG_WITH([qemu-user], - AC_HELP_STRING([--with-qemu-user], [username to run QEMU system instance as @<:@default=root@:>@]), + AC_HELP_STRING([--with-qemu-user], + [username to run QEMU system instance as @<:@default=platform dependent@:>@]), [QEMU_USER=${withval}], - [QEMU_USER=root]) + [QEMU_USER=${default_qemu_user}]) AC_ARG_WITH([qemu-group], - AC_HELP_STRING([--with-qemu-group], [groupname to run QEMU system instance as @<:@default=root@:>@]), + AC_HELP_STRING([--with-qemu-group], + [groupname to run QEMU system instance as @<:@default=platform dependent@:>@]), [QEMU_GROUP=${withval}], - [QEMU_GROUP=root]) + [QEMU_GROUP=${default_qemu_group}]) AC_DEFINE_UNQUOTED([QEMU_USER], ["$QEMU_USER"], [QEMU user account]) AC_DEFINE_UNQUOTED([QEMU_GROUP], ["$QEMU_GROUP"], [QEMU group account]) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 4418f33..cc0e947 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -27,7 +27,12 @@ #include <sys/stat.h> #include <sys/time.h> #include <sys/resource.h> -#include <linux/capability.h> +#if defined(__linux__) +# include <linux/capability.h> +#elif defined(__FreeBSD__) +# include <sys/param.h> +# include <sys/cpuset.h> +#endif #include "qemu_process.h" #include "qemu_domain.h" @@ -3716,7 +3721,12 @@ int qemuProcessStart(virConnectPtr conn, /* in case a certain disk is desirous of CAP_SYS_RAWIO, add this */ for (i = 0; i < vm->def->ndisks; i++) { if (vm->def->disks[i]->rawio == 1) +#ifdef CAP_SYS_RAWIO virCommandAllowCap(cmd, CAP_SYS_RAWIO); +#else + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Raw I/O is not supported on this platform")); +#endif } virCommandSetPreExecHook(cmd, qemuProcessHook, &hookData); diff --git a/src/util/virinitctl.c b/src/util/virinitctl.c index cdd3dc0..ae2f525 100644 --- a/src/util/virinitctl.c +++ b/src/util/virinitctl.c @@ -35,6 +35,7 @@ #define VIR_FROM_THIS VIR_FROM_INITCTL +#if defined(__linux__) || (defined(__FreeBSD_kernel__) && !(defined(__FreeBSD__))) /* These constants & struct definitions are taken from * systemd, under terms of LGPLv2+ * @@ -161,3 +162,11 @@ cleanup: VIR_FORCE_CLOSE(fd); return ret; } +#else +int virInitctlSetRunLevel(virInitctlRunLevel level ATTRIBUTE_UNUSED, + const char *vroot ATTRIBUTE_UNUSED) +{ + virReportError(VIR_ERR_NO_SUPPORT, "%s", __FUNCTION__); + return -1; +} +#endif -- 1.7.11.5

On Wed, Dec 12, 2012 at 11:44:21AM +0400, Roman Bogorodskiy wrote:
* Autotools changes: - Don't assume Qemu is Linux-only - Check Linux headers only on Linux - Disable firewalld on FreeBSD * Initctl: Initctl seem to present only on Linux, so stub it on other platforms * Raw I/O: Linux-only as well * Headers cleanup --- configure.ac | 42 ++++++++++++++++++++++++++++++------------ src/qemu/qemu_process.c | 12 +++++++++++- src/util/virinitctl.c | 9 +++++++++ 3 files changed, 50 insertions(+), 13 deletions(-)
diff --git a/configure.ac b/configure.ac index a695e52..bf32f95 100644 --- a/configure.ac +++ b/configure.ac @@ -360,10 +360,11 @@ dnl are also linux specific. The "network" and storage_fs drivers are known dnl to not work on MacOS X presently, so we also make a note if compiling dnl for that
-with_linux=no with_osx=no +with_linux=no with_osx=no with_freebsd=no case $host in *-*-linux*) with_linux=yes ;; *-*-darwin*) with_osx=yes ;; + *-*-freebsd*) with_freebsd=yes ;; esac
if test $with_linux = no; then @@ -371,14 +372,19 @@ if test $with_linux = no; then then with_lxc=no fi - if test "x$with_qemu" != xyes - then - with_qemu=no - fi with_dtrace=no fi
+if test $with_freebsd = yes; then + with_firewalld=no +fi + +if test $with_osx = yes; then + with_qemu=no +fi + AM_CONDITIONAL([WITH_LINUX], [test "$with_linux" = "yes"]) +AM_CONDITIONAL([WITH_FREEBSD], [test "$with_freebsd" = "yes"])
dnl Allow to build without Xen, QEMU/KVM, test or remote driver AC_ARG_WITH([xen], @@ -949,9 +955,11 @@ fi dnl dnl check for kernel headers required by src/bridge.c dnl -if test "$with_qemu" = "yes" || test "$with_lxc" = "yes" ; then - AC_CHECK_HEADERS([linux/param.h linux/sockios.h linux/if_bridge.h linux/if_tun.h],, - AC_MSG_ERROR([You must install kernel-headers in order to compile libvirt with QEMU or LXC support])) +if test "$with_linux" = "yes"; then + if test "$with_qemu" = "yes" || test "$with_lxc" = "yes" ; then + AC_CHECK_HEADERS([linux/param.h linux/sockios.h linux/if_bridge.h linux/if_tun.h],, + AC_MSG_ERROR([You must install kernel-headers in order to compile libvirt with QEMU or LXC support])) + fi fi
@@ -2880,14 +2888,24 @@ if test "x$with_libblkid" = "xyes"; then fi AM_CONDITIONAL([HAVE_LIBBLKID], [test "x$with_libblkid" = "xyes"])
+if test $with_freebsd = yes; then + default_qemu_user=root + default_qemu_group=wheel +else + default_qemu_user=root + default_qemu_group=root +fi + AC_ARG_WITH([qemu-user], - AC_HELP_STRING([--with-qemu-user], [username to run QEMU system instance as @<:@default=root@:>@]), + AC_HELP_STRING([--with-qemu-user], + [username to run QEMU system instance as @<:@default=platform dependent@:>@]), [QEMU_USER=${withval}], - [QEMU_USER=root]) + [QEMU_USER=${default_qemu_user}]) AC_ARG_WITH([qemu-group], - AC_HELP_STRING([--with-qemu-group], [groupname to run QEMU system instance as @<:@default=root@:>@]), + AC_HELP_STRING([--with-qemu-group], + [groupname to run QEMU system instance as @<:@default=platform dependent@:>@]), [QEMU_GROUP=${withval}], - [QEMU_GROUP=root]) + [QEMU_GROUP=${default_qemu_group}]) AC_DEFINE_UNQUOTED([QEMU_USER], ["$QEMU_USER"], [QEMU user account]) AC_DEFINE_UNQUOTED([QEMU_GROUP], ["$QEMU_GROUP"], [QEMU group account])
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 4418f33..cc0e947 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -27,7 +27,12 @@ #include <sys/stat.h> #include <sys/time.h> #include <sys/resource.h> -#include <linux/capability.h> +#if defined(__linux__) +# include <linux/capability.h> +#elif defined(__FreeBSD__) +# include <sys/param.h> +# include <sys/cpuset.h> +#endif
#include "qemu_process.h" #include "qemu_domain.h" @@ -3716,7 +3721,12 @@ int qemuProcessStart(virConnectPtr conn, /* in case a certain disk is desirous of CAP_SYS_RAWIO, add this */ for (i = 0; i < vm->def->ndisks; i++) { if (vm->def->disks[i]->rawio == 1) +#ifdef CAP_SYS_RAWIO virCommandAllowCap(cmd, CAP_SYS_RAWIO); +#else + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Raw I/O is not supported on this platform")); +#endif }
virCommandSetPreExecHook(cmd, qemuProcessHook, &hookData); diff --git a/src/util/virinitctl.c b/src/util/virinitctl.c index cdd3dc0..ae2f525 100644 --- a/src/util/virinitctl.c +++ b/src/util/virinitctl.c @@ -35,6 +35,7 @@
#define VIR_FROM_THIS VIR_FROM_INITCTL
+#if defined(__linux__) || (defined(__FreeBSD_kernel__) && !(defined(__FreeBSD__))) /* These constants & struct definitions are taken from * systemd, under terms of LGPLv2+ * @@ -161,3 +162,11 @@ cleanup: VIR_FORCE_CLOSE(fd); return ret; } +#else +int virInitctlSetRunLevel(virInitctlRunLevel level ATTRIBUTE_UNUSED, + const char *vroot ATTRIBUTE_UNUSED) +{ + virReportError(VIR_ERR_NO_SUPPORT, "%s", __FUNCTION__); + return -1; +} +#endif
ACK Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

On 12/12/2012 03:31 AM, Daniel P. Berrange wrote:
On Wed, Dec 12, 2012 at 11:44:21AM +0400, Roman Bogorodskiy wrote:
* Autotools changes: - Don't assume Qemu is Linux-only - Check Linux headers only on Linux - Disable firewalld on FreeBSD * Initctl: Initctl seem to present only on Linux, so stub it on other platforms * Raw I/O: Linux-only as well * Headers cleanup
ACK
Pushed these two (after fixing the 'make syntax-check' errors with 'cppi' installed). It should also solve the build error for OS X reported here: https://www.redhat.com/archives/libvir-list/2012-December/msg00743.html -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

Eric Blake wrote:
On 12/12/2012 03:31 AM, Daniel P. Berrange wrote:
On Wed, Dec 12, 2012 at 11:44:21AM +0400, Roman Bogorodskiy wrote:
* Autotools changes: - Don't assume Qemu is Linux-only - Check Linux headers only on Linux - Disable firewalld on FreeBSD * Initctl: Initctl seem to present only on Linux, so stub it on other platforms * Raw I/O: Linux-only as well * Headers cleanup
ACK
Pushed these two (after fixing the 'make syntax-check' errors with 'cppi' installed). It should also solve the build error for OS X reported here: https://www.redhat.com/archives/libvir-list/2012-December/msg00743.html
Thanks! Roman Bogorodskiy
participants (3)
-
Daniel P. Berrange
-
Eric Blake
-
Roman Bogorodskiy