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

Daniel P. Berrangé posted 1 patch 6 years, 2 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/20180125174404.32511-1-berrange@redhat.com
src/util/virresctrl.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 47 insertions(+)
[libvirt] [PATCH] resctl: stub out functions with Linux-only APIs used
Posted by Daniel P. Berrangé 6 years, 2 months ago
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>
---

  * 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

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] resctl: stub out functions with Linux-only APIs used
Posted by Martin Kletzander 6 years, 1 month ago
On Thu, Jan 25, 2018 at 05:44:04PM +0000, Daniel P. Berrangé wrote:
>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>
>---
>
>  * Pushed as CI build fix
>

Thanks for that.  I have not seen a failure on travis, but I missed the ones on
ci.centos.org.  However I think all of the functionality is probably pointless
on non-Linux, so I'll disable the whole resctrl for that in a series I'm
preparing.  Thanks for this.--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] resctl: stub out functions with Linux-only APIs used
Posted by Daniel P. Berrangé 6 years, 1 month ago
On Mon, Jan 29, 2018 at 08:59:35AM +0100, Martin Kletzander wrote:
> On Thu, Jan 25, 2018 at 05:44:04PM +0000, Daniel P. Berrangé wrote:
> > 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>
> > ---
> > 
> >  * Pushed as CI build fix
> > 
> 
> Thanks for that.  I have not seen a failure on travis, but I missed the ones on
> ci.centos.org.  However I think all of the functionality is probably pointless
> on non-Linux, so I'll disable the whole resctrl for that in a series I'm
> preparing.  Thanks for this.

Yes, I thought about figuring out a way to compile out the entire file,
but I wanted to avoid adding lots of #ifdefs in either the header file,
or the QEMU source. So I decided it was better to do the minimal fix of
just stubbing the virresctrl.c file pieces that broke. 

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] resctl: stub out functions with Linux-only APIs used
Posted by Martin Kletzander 6 years, 1 month ago
On Wed, Jan 31, 2018 at 01:28:32PM +0000, Daniel P. Berrangé wrote:
>On Mon, Jan 29, 2018 at 08:59:35AM +0100, Martin Kletzander wrote:
>> On Thu, Jan 25, 2018 at 05:44:04PM +0000, Daniel P. Berrangé wrote:
>> > 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>
>> > ---
>> >
>> >  * Pushed as CI build fix
>> >
>>
>> Thanks for that.  I have not seen a failure on travis, but I missed the ones on
>> ci.centos.org.  However I think all of the functionality is probably pointless
>> on non-Linux, so I'll disable the whole resctrl for that in a series I'm
>> preparing.  Thanks for this.
>
>Yes, I thought about figuring out a way to compile out the entire file,
>but I wanted to avoid adding lots of #ifdefs in either the header file,
>or the QEMU source. So I decided it was better to do the minimal fix of
>just stubbing the virresctrl.c file pieces that broke.
>

No problem, I have a cleanup ready, I'll send it later on.  Thanks for the fix,
though.

>Regards,
>Daniel
>-- 
>|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
>|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
>|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list