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