From: Pekka Enberg Subject: [RFC/PATCH] kvm tools: Use preadv/pwritev syscalls directly Date: Wed, 18 May 2011 21:58:06 +0300 Message-ID: <1305745086-7868-1-git-send-email-penberg@kernel.org> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: Pekka Enberg , Asias He , Avi Kivity , Cyrill Gorcunov , Ingo Molnar , Prasad Joshi , Sasha Levin To: kvm@vger.kernel.org Return-path: Received: from filtteri5.pp.htv.fi ([213.243.153.188]:39583 "EHLO filtteri5.pp.htv.fi" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933573Ab1ERS6K (ORCPT ); Wed, 18 May 2011 14:58:10 -0400 Sender: kvm-owner@vger.kernel.org List-ID: "bornto befrag " reported the following compilat= ion 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 =E2=80=98xpreadv=E2=80=99: > read-write.c:255: error: implicit declaration of function =E2=80=98= preadv=E2=80=99 > read-write.c:255: error: nested extern declaration of =E2=80=98prea= dv=E2=80=99 > read-write.c: In function =E2=80=98xpwritev=E2=80=99: > read-write.c:268: error: implicit declaration of function =E2=80=98= pwritev=E2=80=99 > read-write.c:268: error: nested extern declaration of =E2=80=98pwri= tev=E2=80=99 > 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 pr= oblem is that glibc 2.7 doesn't have preadv()/pwritev() definitions. Therefore, use the system calls directly to fix the issue. Cc: Asias He Cc: Avi Kivity Cc: Cyrill Gorcunov Cc: Ingo Molnar Cc: Prasad Joshi Cc: Sasha Levin Reported-by: Signed-off-by: Pekka Enberg --- 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" =20 +#include #include -#include #include #include #include =20 +#include + /* Same as read(2) except that this function never returns EAGAIN or E= INTR. */ 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; } =20 +static inline ssize_t sys_preadv(int fd, const struct iovec *iovec, in= t 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 off= set) { ssize_t nr; =20 restart: - nr =3D preadv(fd, iov, iovcnt, offset); + nr =3D sys_preadv(fd, iov, iovcnt, offset); if ((nr < 0) && ((errno =3D=3D EAGAIN) || (errno =3D=3D EINTR))) goto restart; =20 return nr; } =20 +static inline ssize_t sys_pwritev(int fd, const struct iovec *iovec, i= nt count, off_t offset) +{ + return syscall(__NR_pwritev, fd, iovec, count, offset); +} + /* Same as pwritev(2) except that this function never returns EAGAIN o= r EINTR. */ ssize_t xpwritev(int fd, const struct iovec *iov, int iovcnt, off_t of= fset) { ssize_t nr; =20 restart: - nr =3D pwritev(fd, iov, iovcnt, offset); + nr =3D sys_pwritev(fd, iov, iovcnt, offset); if ((nr < 0) && ((errno =3D=3D EAGAIN) || (errno =3D=3D EINTR))) goto restart; =20 --=20 1.7.0.4