[libvirt] [PATCH] resctl: stub out functions with Linux-only APIs used

Daniel P. Berrangé berrange at redhat.com
Thu Jan 25 17:44:04 UTC 2018


The flock() function and d_type field in struct dirent are not portable
to the mingw platform.

Signed-off-by: Daniel P. Berrangé <berrange at redhat.com>
---

  * Pushed as CI build fix

 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.14.3




More information about the libvir-list mailing list