From bd6a2a903f008eef19caa703303492920878174e Mon Sep 17 00:00:00 2001
Message-Id: <bd6a2a903f008eef19caa703303492920878174e@dist-git>
From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= <berrange@redhat.com>
Date: Wed, 31 Jan 2018 16:32:34 +0100
Subject: [PATCH] resctl: stub out functions with Linux-only APIs used
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The flock() function and d_type field in struct dirent are not portable
to the mingw platform.
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
(cherry picked from commit a020ab03fdfc3f95ef8d52908bcfc1aac22a8316)
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
https://bugzilla.redhat.com/show_bug.cgi?id=1289368
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
---
src/util/virresctrl.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 47 insertions(+)
diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c
index e252aefe31..754820ee46 100644
--- a/src/util/virresctrl.c
+++ b/src/util/virresctrl.c
@@ -295,6 +295,7 @@ virResctrlAllocNew(void)
/* Common functions */
+#ifdef __linux__
static int
virResctrlLockInternal(int op)
{
@@ -321,6 +322,20 @@ virResctrlLockWrite(void)
return virResctrlLockInternal(LOCK_EX);
}
+#else
+
+static inline int
+virResctrlLockWrite(void)
+{
+ virReportSystemError(ENOSYS, "%s",
+ _("resctrlfs not supported on this platform"));
+ return -1;
+}
+
+#endif
+
+
+
static int
virResctrlUnlock(int fd)
@@ -328,6 +343,7 @@ virResctrlUnlock(int fd)
if (fd == -1)
return 0;
+#ifdef __linux__
/* The lock gets unlocked by closing the fd, which we need to do anyway in
* order to clean up properly */
if (VIR_CLOSE(fd) < 0) {
@@ -338,6 +354,7 @@ virResctrlUnlock(int fd)
virReportSystemError(errno, "%s", _("Cannot unlock resctrlfs"));
return -1;
}
+#endif /* ! __linux__ */
return 0;
}
@@ -369,6 +386,8 @@ virResctrlInfoIsEmpty(virResctrlInfoPtr resctrl)
}
+#ifdef __linux__
+
int
virResctrlGetInfo(virResctrlInfoPtr resctrl)
{
@@ -495,6 +514,18 @@ virResctrlGetInfo(virResctrlInfoPtr resctrl)
return ret;
}
+#else /* ! __linux__ */
+
+int
+virResctrlGetInfo(virResctrlInfoPtr resctrl ATTRIBUTE_UNUSED)
+{
+ virReportSystemError(ENOSYS, "%s",
+ _("Cache tune not supported on this platform"));
+ return -1;
+}
+
+#endif /* ! __linux__ */
+
int
virResctrlInfoGetCache(virResctrlInfoPtr resctrl,
@@ -632,6 +663,8 @@ virResctrlAllocGetType(virResctrlAllocPtr resctrl,
}
+#ifdef __linux__
+
static int
virResctrlAllocUpdateMask(virResctrlAllocPtr resctrl,
unsigned int level,
@@ -659,6 +692,8 @@ virResctrlAllocUpdateMask(virResctrlAllocPtr resctrl,
return virBitmapCopy(a_type->masks[cache], mask);
}
+#endif
+
static int
virResctrlAllocUpdateSize(virResctrlAllocPtr resctrl,
@@ -878,6 +913,8 @@ virResctrlAllocFormat(virResctrlAllocPtr resctrl)
}
+#ifdef __linux__
+
static int
virResctrlAllocParseProcessCache(virResctrlInfoPtr resctrl,
virResctrlAllocPtr alloc,
@@ -1180,7 +1217,17 @@ virResctrlAllocGetUnused(virResctrlInfoPtr resctrl)
goto cleanup;
}
+#else /* ! __linux__ */
+virResctrlAllocPtr
+virResctrlAllocGetUnused(virResctrlInfoPtr resctrl ATTRIBUTE_UNUSED)
+{
+ virReportSystemError(ENOSYS, "%s",
+ _("Cache tune not supported on this platform"));
+ return NULL;
+}
+
+#endif /* ! __linux__ */
static int
virResctrlAllocSetMask(virResctrlAllocPerTypePtr a_type,
--
2.16.1