From patchwork Wed May 18 18:58:06 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Pekka Enberg X-Patchwork-Id: 794742 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p4IIwFUr019864 for ; Wed, 18 May 2011 18:58:15 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933583Ab1ERS6L (ORCPT ); Wed, 18 May 2011 14:58:11 -0400 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 Received: from localhost (localhost [127.0.0.1]) by filtteri5.pp.htv.fi (Postfix) with ESMTP id 625755A6260; Wed, 18 May 2011 21:58:08 +0300 (EEST) X-Virus-Scanned: Debian amavisd-new at pp.htv.fi Received: from smtp5.welho.com ([213.243.153.39]) by localhost (filtteri5.pp.htv.fi [213.243.153.188]) (amavisd-new, port 10024) with ESMTP id u2QHkY5usrPQ; Wed, 18 May 2011 21:58:08 +0300 (EEST) Received: from localhost.localdomain (cs181148025.pp.htv.fi [82.181.148.25]) by smtp5.welho.com (Postfix) with ESMTP id D5BEF5BC00A; Wed, 18 May 2011 21:58:07 +0300 (EEST) From: Pekka Enberg To: kvm@vger.kernel.org Cc: Pekka Enberg , Asias He , Avi Kivity , Cyrill Gorcunov , Ingo Molnar , Prasad Joshi , Sasha Levin 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> X-Mailer: git-send-email 1.7.0.4 MIME-Version: 1.0 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Wed, 18 May 2011 18:58:15 +0000 (UTC) "bornto befrag " 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 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" +#include #include -#include #include #include #include +#include + /* 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;