"bornto befrag <[email protected]>" reported the following compilation
error:
> When i compile i kvm native tool tools/kvm && make i get this
>
> CC read-write.o
> cc1: warnings being treated as errors
> read-write.c: In function ‘xpreadv’:
> read-write.c:255: error: implicit declaration of function ‘preadv’
> read-write.c:255: error: nested extern declaration of ‘preadv’
> read-write.c: In function ‘xpwritev’:
> read-write.c:268: error: implicit declaration of function ‘pwritev’
> read-write.c:268: error: nested extern declaration of ‘pwritev’
> make: *** [read-write.o] Error 1
Commit 28f95a5 ("kvm tools: Fix includes for preadv/pwritev") attempted to fix
the issue by adding a missing include. However, as it turns out, the problem
is that glibc 2.7 doesn't have preadv()/pwritev() definitions.
Therefore, use the system calls directly to fix the issue.
Cc: Asias He <[email protected]>
Cc: Avi Kivity <[email protected]>
Cc: Cyrill Gorcunov <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Prasad Joshi <[email protected]>
Cc: Sasha Levin <[email protected]>
Reported-by: <[email protected]>
Signed-off-by: Pekka Enberg <[email protected]>
---
tools/kvm/read-write.c | 18 +++++++++++++++---
1 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/tools/kvm/read-write.c b/tools/kvm/read-write.c
index 7e233b5..dc8c076 100644
--- a/tools/kvm/read-write.c
+++ b/tools/kvm/read-write.c
@@ -1,11 +1,13 @@
#include "kvm/read-write.h"
+#include <sys/syscall.h>
#include <sys/types.h>
-#include <sys/uio.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
+#include <asm/unistd.h>
+
/* Same as read(2) except that this function never returns EAGAIN or EINTR. */
ssize_t xread(int fd, void *buf, size_t count)
{
@@ -247,26 +249,36 @@ ssize_t writev_in_full(int fd, const struct iovec *iov,
int iovcnt)
return total;
}
+static inline ssize_t sys_preadv(int fd, const struct iovec *iovec, int count,
off_t offset)
+{
+ return syscall(__NR_preadv, fd, iovec, count, offset);
+}
+
/* Same as preadv(2) except that this function never returns EAGAIN or EINTR.
*/
ssize_t xpreadv(int fd, const struct iovec *iov, int iovcnt, off_t offset)
{
ssize_t nr;
restart:
- nr = preadv(fd, iov, iovcnt, offset);
+ nr = sys_preadv(fd, iov, iovcnt, offset);
if ((nr < 0) && ((errno == EAGAIN) || (errno == EINTR)))
goto restart;
return nr;
}
+static inline ssize_t sys_pwritev(int fd, const struct iovec *iovec, int
count, off_t offset)
+{
+ return syscall(__NR_pwritev, fd, iovec, count, offset);
+}
+
/* Same as pwritev(2) except that this function never returns EAGAIN or EINTR.
*/
ssize_t xpwritev(int fd, const struct iovec *iov, int iovcnt, off_t offset)
{
ssize_t nr;
restart:
- nr = pwritev(fd, iov, iovcnt, offset);
+ nr = sys_pwritev(fd, iov, iovcnt, offset);
if ((nr < 0) && ((errno == EAGAIN) || (errno == EINTR)))
goto restart;
--
1.7.0.4
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html