From patchwork Wed Apr 21 05:57:10 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshiaki Tamura X-Patchwork-Id: 50624 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id BD7F0B6EEB for ; Wed, 21 Apr 2010 16:35:42 +1000 (EST) Received: from localhost ([127.0.0.1]:36075 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O4TX8-0007gj-Kk for incoming@patchwork.ozlabs.org; Wed, 21 Apr 2010 02:35:38 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1O4T0o-0003Hg-7L for qemu-devel@nongnu.org; Wed, 21 Apr 2010 02:02:14 -0400 Received: from [140.186.70.92] (port=36836 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O4T0P-00033u-PC for qemu-devel@nongnu.org; Wed, 21 Apr 2010 02:02:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1O4T0B-0006hD-FV for qemu-devel@nongnu.org; Wed, 21 Apr 2010 02:01:48 -0400 Received: from sh.osrg.net ([192.16.179.4]:35919) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O4T09-0006ds-AE for qemu-devel@nongnu.org; Wed, 21 Apr 2010 02:01:33 -0400 Received: from fs.osrg.net (postfix@fs.osrg.net [10.0.0.12]) by sh.osrg.net (8.14.3/8.14.3/OSRG-NET) with ESMTP id o3L61QCK004091; Wed, 21 Apr 2010 15:01:26 +0900 Received: from localhost (hype-wd0.osrg.net [10.72.1.16]) by fs.osrg.net (Postfix) with ESMTP id 219A03E02F2; Wed, 21 Apr 2010 15:01:25 +0900 (JST) From: Yoshiaki Tamura To: kvm@vger.kernel.org, qemu-devel@nongnu.org Date: Wed, 21 Apr 2010 14:57:10 +0900 Message-Id: <1271829445-5328-6-git-send-email-tamura.yoshiaki@lab.ntt.co.jp> X-Mailer: git-send-email 1.7.0.31.g1df487 In-Reply-To: <1271829445-5328-1-git-send-email-tamura.yoshiaki@lab.ntt.co.jp> References: <1271829445-5328-1-git-send-email-tamura.yoshiaki@lab.ntt.co.jp> X-Dispatcher: imput version 20070423(IM149) Lines: 172 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-3.0 (sh.osrg.net [192.16.179.4]); Wed, 21 Apr 2010 15:01:26 +0900 (JST) X-Virus-Scanned: clamav-milter 0.95.3 at sh X-Virus-Status: Clean X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) Cc: aliguori@us.ibm.com, ohmura.kei@lab.ntt.co.jp, mtosatti@redhat.com, Yoshiaki Tamura , yoshikawa.takuya@oss.ntt.co.jp, avi@redhat.com Subject: [Qemu-devel] [RFC PATCH 05/20] Introduce put_vector() and get_vector to QEMUFile and qemu_fopen_ops(). X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org QEMUFile currently doesn't support writev(). For sending multiple data, such as pages, using writev() should be more efficient. Signed-off-by: Yoshiaki Tamura --- buffered_file.c | 2 +- hw/hw.h | 16 ++++++++++++++++ savevm.c | 43 +++++++++++++++++++++++++------------------ 3 files changed, 42 insertions(+), 19 deletions(-) diff --git a/buffered_file.c b/buffered_file.c index 54dc6c2..187d1d4 100644 --- a/buffered_file.c +++ b/buffered_file.c @@ -256,7 +256,7 @@ QEMUFile *qemu_fopen_ops_buffered(void *opaque, s->wait_for_unfreeze = wait_for_unfreeze; s->close = close; - s->file = qemu_fopen_ops(s, buffered_put_buffer, NULL, + s->file = qemu_fopen_ops(s, buffered_put_buffer, NULL, NULL, NULL, buffered_close, buffered_rate_limit, buffered_set_rate_limit, buffered_get_rate_limit); diff --git a/hw/hw.h b/hw/hw.h index fc9ed29..921cf90 100644 --- a/hw/hw.h +++ b/hw/hw.h @@ -23,6 +23,13 @@ typedef int (QEMUFilePutBufferFunc)(void *opaque, const uint8_t *buf, int64_t pos, int size); +/* This function writes a chunk of vector to a file at the given position. + * The pos argument can be ignored if the file is only being used for + * streaming. + */ +typedef int (QEMUFilePutVectorFunc)(void *opaque, struct iovec *iov, + int64_t pos, int iovcnt); + /* Read a chunk of data from a file at the given position. The pos argument * can be ignored if the file is only be used for streaming. The number of * bytes actually read should be returned. @@ -30,6 +37,13 @@ typedef int (QEMUFilePutBufferFunc)(void *opaque, const uint8_t *buf, typedef int (QEMUFileGetBufferFunc)(void *opaque, uint8_t *buf, int64_t pos, int size); +/* Read a chunk of vector from a file at the given position. The pos argument + * can be ignored if the file is only be used for streaming. The number of + * bytes actually read should be returned. + */ +typedef int (QEMUFileGetVectorFunc)(void *opaque, struct iovec *iov, + int64_t pos, int iovcnt); + /* Close a file and return an error code */ typedef int (QEMUFileCloseFunc)(void *opaque); @@ -46,7 +60,9 @@ typedef size_t (QEMUFileSetRateLimit)(void *opaque, size_t new_rate); typedef size_t (QEMUFileGetRateLimit)(void *opaque); QEMUFile *qemu_fopen_ops(void *opaque, QEMUFilePutBufferFunc *put_buffer, + QEMUFilePutVectorFunc *put_vector, QEMUFileGetBufferFunc *get_buffer, + QEMUFileGetVectorFunc *get_vector, QEMUFileCloseFunc *close, QEMUFileRateLimit *rate_limit, QEMUFileSetRateLimit *set_rate_limit, diff --git a/savevm.c b/savevm.c index 490ab70..944e788 100644 --- a/savevm.c +++ b/savevm.c @@ -162,7 +162,9 @@ void qemu_announce_self(void) struct QEMUFile { QEMUFilePutBufferFunc *put_buffer; + QEMUFilePutVectorFunc *put_vector; QEMUFileGetBufferFunc *get_buffer; + QEMUFileGetVectorFunc *get_vector; QEMUFileCloseFunc *close; QEMUFileRateLimit *rate_limit; QEMUFileSetRateLimit *set_rate_limit; @@ -263,11 +265,11 @@ QEMUFile *qemu_popen(FILE *stdio_file, const char *mode) s->stdio_file = stdio_file; if(mode[0] == 'r') { - s->file = qemu_fopen_ops(s, NULL, stdio_get_buffer, stdio_pclose, - NULL, NULL, NULL); + s->file = qemu_fopen_ops(s, NULL, NULL, stdio_get_buffer, + NULL, stdio_pclose, NULL, NULL, NULL); } else { - s->file = qemu_fopen_ops(s, stdio_put_buffer, NULL, stdio_pclose, - NULL, NULL, NULL); + s->file = qemu_fopen_ops(s, stdio_put_buffer, NULL, NULL, NULL, + stdio_pclose, NULL, NULL, NULL); } return s->file; } @@ -312,11 +314,11 @@ QEMUFile *qemu_fdopen(int fd, const char *mode) goto fail; if(mode[0] == 'r') { - s->file = qemu_fopen_ops(s, NULL, stdio_get_buffer, stdio_fclose, - NULL, NULL, NULL); + s->file = qemu_fopen_ops(s, NULL, NULL, stdio_get_buffer, NULL, + stdio_fclose, NULL, NULL, NULL); } else { - s->file = qemu_fopen_ops(s, stdio_put_buffer, NULL, stdio_fclose, - NULL, NULL, NULL); + s->file = qemu_fopen_ops(s, stdio_put_buffer, NULL, NULL, NULL, + stdio_fclose, NULL, NULL, NULL); } return s->file; @@ -330,8 +332,8 @@ QEMUFile *qemu_fopen_socket(int fd) QEMUFileSocket *s = qemu_mallocz(sizeof(QEMUFileSocket)); s->fd = fd; - s->file = qemu_fopen_ops(s, NULL, socket_get_buffer, socket_close, - NULL, NULL, NULL); + s->file = qemu_fopen_ops(s, NULL, NULL, socket_get_buffer, NULL, + socket_close, NULL, NULL, NULL); return s->file; } @@ -368,11 +370,11 @@ QEMUFile *qemu_fopen(const char *filename, const char *mode) goto fail; if(mode[0] == 'w') { - s->file = qemu_fopen_ops(s, file_put_buffer, NULL, stdio_fclose, - NULL, NULL, NULL); + s->file = qemu_fopen_ops(s, file_put_buffer, NULL, NULL, NULL, + stdio_fclose, NULL, NULL, NULL); } else { - s->file = qemu_fopen_ops(s, NULL, file_get_buffer, stdio_fclose, - NULL, NULL, NULL); + s->file = qemu_fopen_ops(s, NULL, NULL, file_get_buffer, NULL, + stdio_fclose, NULL, NULL, NULL); } return s->file; fail: @@ -400,13 +402,16 @@ static int bdrv_fclose(void *opaque) static QEMUFile *qemu_fopen_bdrv(BlockDriverState *bs, int is_writable) { if (is_writable) - return qemu_fopen_ops(bs, block_put_buffer, NULL, bdrv_fclose, - NULL, NULL, NULL); - return qemu_fopen_ops(bs, NULL, block_get_buffer, bdrv_fclose, NULL, NULL, NULL); + return qemu_fopen_ops(bs, block_put_buffer, NULL, NULL, NULL, + bdrv_fclose, NULL, NULL, NULL); + return qemu_fopen_ops(bs, NULL, NULL, block_get_buffer, NULL, bdrv_fclose, NULL, NULL, NULL); } -QEMUFile *qemu_fopen_ops(void *opaque, QEMUFilePutBufferFunc *put_buffer, +QEMUFile *qemu_fopen_ops(void *opaque, + QEMUFilePutBufferFunc *put_buffer, + QEMUFilePutVectorFunc *put_vector, QEMUFileGetBufferFunc *get_buffer, + QEMUFileGetVectorFunc *get_vector, QEMUFileCloseFunc *close, QEMUFileRateLimit *rate_limit, QEMUFileSetRateLimit *set_rate_limit, @@ -418,7 +423,9 @@ QEMUFile *qemu_fopen_ops(void *opaque, QEMUFilePutBufferFunc *put_buffer, f->opaque = opaque; f->put_buffer = put_buffer; + f->put_vector = put_vector; f->get_buffer = get_buffer; + f->get_vector = get_vector; f->close = close; f->rate_limit = rate_limit; f->set_rate_limit = set_rate_limit;