[PATCH] libs/evtchn: fix build on NetBSD.

Manuel Bouyer posted 1 patch 2 weeks, 1 day ago
Test gitlab-ci failed
Failed in applying to current master (apply log)
tools/libs/evtchn/netbsd.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

[PATCH] libs/evtchn: fix build on NetBSD.

Posted by Manuel Bouyer 2 weeks, 1 day ago
From: Manuel Bouyer <bouyer@netbsd.org>

use xenio3.h for ioctl definitions
read_exact/write_exact seems to not be available here, which cause
a gcc error.
Use plain read/write, the xenevtchn interface won't do partial read/write
on NetBSD anyway so it should be safe.

Signed-off-by: Manuel Bouyer <bouyer@netbsd.org>
Fixes: b7f76a699dc ('tools: Refactor /dev/xen/evtchn wrappers into libxenevtchn.
')

---
 tools/libs/evtchn/netbsd.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/libs/evtchn/netbsd.c b/tools/libs/evtchn/netbsd.c
index 8b8545d2f9..6d4ce28011 100644
--- a/tools/libs/evtchn/netbsd.c
+++ b/tools/libs/evtchn/netbsd.c
@@ -25,10 +25,10 @@
 
 #include <sys/ioctl.h>
 
-#include <xen/sys/evtchn.h>
-
 #include "private.h"
 
+#include <xen/xenio3.h>
+
 #define EVTCHN_DEV_NAME  "/dev/xenevt"
 
 int osdep_evtchn_open(xenevtchn_handle *xce)
@@ -131,7 +131,7 @@ xenevtchn_port_or_error_t xenevtchn_pending(xenevtchn_handle *xce)
     int fd = xce->fd;
     evtchn_port_t port;
 
-    if ( read_exact(fd, (char *)&port, sizeof(port)) == -1 )
+    if ( read(fd, (char *)&port, sizeof(port)) == -1 )
         return -1;
 
     return port;
@@ -140,7 +140,7 @@ xenevtchn_port_or_error_t xenevtchn_pending(xenevtchn_handle *xce)
 int xenevtchn_unmask(xenevtchn_handle *xce, evtchn_port_t port)
 {
     int fd = xce->fd;
-    return write_exact(fd, (char *)&port, sizeof(port));
+    return write(fd, (char *)&port, sizeof(port));
 }
 
 /*
-- 
2.29.2


Re: [PATCH] libs/evtchn: fix build on NetBSD.

Posted by Roger Pau Monné 1 week, 2 days ago
On Tue, Jan 12, 2021 at 07:12:30PM +0100, Manuel Bouyer wrote:
> From: Manuel Bouyer <bouyer@netbsd.org>
> 
> use xenio3.h for ioctl definitions
> read_exact/write_exact seems to not be available here, which cause
> a gcc error.
> Use plain read/write, the xenevtchn interface won't do partial read/write
> on NetBSD anyway so it should be safe.

I would add: This is inline with the rest of the OS specific helpers
that also use plain read/write calls.

> 
> Signed-off-by: Manuel Bouyer <bouyer@netbsd.org>

Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>

Thanks, Roger.