summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRoman Bogorodskiy <bogorodskiy@gmail.com>2012-12-12 11:44:21 +0400
committerEric Blake <eblake@redhat.com>2012-12-12 11:59:53 -0700
commit9a2f36ec04e0436b1ba9f0c21f9be234b25ac579 (patch)
tree2332381b92cb66fc38c0e7e887f5aee8374f0d1b /src
parentb467e9323ca603f6ca773e121dc19c4e9c542eb5 (diff)
downloadlibvirt-9a2f36ec04e0436b1ba9f0c21f9be234b25ac579.tar.gz
Qemu FreeBSD: fix compilation
* 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
Diffstat (limited to 'src')
-rw-r--r--src/qemu/qemu_process.c12
-rw-r--r--src/util/virinitctl.c56
2 files changed, 44 insertions, 24 deletions
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 4418f3330a..cc0e9472ea 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 cdd3dc0482..e8949af3da 100644
--- a/src/util/virinitctl.c
+++ b/src/util/virinitctl.c
@@ -35,6 +35,8 @@
#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+
*
@@ -43,29 +45,29 @@
* Copyright (C) 1995-2004 Miquel van Smoorenburg
*/
-#if defined(__FreeBSD_kernel__)
-# define VIR_INITCTL_FIFO "/etc/.initctl"
-#else
-# define VIR_INITCTL_FIFO "/dev/initctl"
-#endif
-
-#define VIR_INITCTL_MAGIC 0x03091969
-#define VIR_INITCTL_CMD_START 0
-#define VIR_INITCTL_CMD_RUNLVL 1
-#define VIR_INITCTL_CMD_POWERFAIL 2
-#define VIR_INITCTL_CMD_POWERFAILNOW 3
-#define VIR_INITCTL_CMD_POWEROK 4
-#define VIR_INITCTL_CMD_BSD 5
-#define VIR_INITCTL_CMD_SETENV 6
-#define VIR_INITCTL_CMD_UNSETENV 7
-
-#define VIR_INITCTL_CMD_CHANGECONS 12345
-
-#ifdef MAXHOSTNAMELEN
-# define VIR_INITCTL_RQ_HLEN MAXHOSTNAMELEN
-#else
-# define VIR_INITCTL_RQ_HLEN 64
-#endif
+# if defined(__FreeBSD_kernel__)
+# define VIR_INITCTL_FIFO "/etc/.initctl"
+# else
+# define VIR_INITCTL_FIFO "/dev/initctl"
+# endif
+
+# define VIR_INITCTL_MAGIC 0x03091969
+# define VIR_INITCTL_CMD_START 0
+# define VIR_INITCTL_CMD_RUNLVL 1
+# define VIR_INITCTL_CMD_POWERFAIL 2
+# define VIR_INITCTL_CMD_POWERFAILNOW 3
+# define VIR_INITCTL_CMD_POWEROK 4
+# define VIR_INITCTL_CMD_BSD 5
+# define VIR_INITCTL_CMD_SETENV 6
+# define VIR_INITCTL_CMD_UNSETENV 7
+
+# define VIR_INITCTL_CMD_CHANGECONS 12345
+
+# ifdef MAXHOSTNAMELEN
+# define VIR_INITCTL_RQ_HLEN MAXHOSTNAMELEN
+# else
+# define VIR_INITCTL_RQ_HLEN 64
+# endif
/*
* This is what BSD 4.4 uses when talking to init.
@@ -161,3 +163,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