[RFC/PATCH] kvm tools: Use preadv/pwritev syscalls directly

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"bornto befrag <born2befrag@xxxxxxxxx>" 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 <asias.hejun@xxxxxxxxx>
Cc: Avi Kivity <avi@xxxxxxxxxx>
Cc: Cyrill Gorcunov <gorcunov@xxxxxxxxx>
Cc: Ingo Molnar <mingo@xxxxxxx>
Cc: Prasad Joshi <prasadjoshi124@xxxxxxxxx>
Cc: Sasha Levin <levinsasha928@xxxxxxxxx>
Reported-by: <born2befrag@xxxxxxxxx>
Signed-off-by: Pekka Enberg <penberg@xxxxxxxxxx>
---
 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 majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux