From patchwork Tue Aug 25 11:59:08 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Liang Z" X-Patchwork-Id: 510471 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 83C4E140281 for ; Tue, 25 Aug 2015 22:00:56 +1000 (AEST) Received: from localhost ([::1]:59565 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZUCuM-0007Wl-NG for incoming@patchwork.ozlabs.org; Tue, 25 Aug 2015 08:00:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56255) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZUCtk-0006uS-V3 for qemu-devel@nongnu.org; Tue, 25 Aug 2015 08:00:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZUCth-0006Ct-JO for qemu-devel@nongnu.org; Tue, 25 Aug 2015 08:00:16 -0400 Received: from mga09.intel.com ([134.134.136.24]:39137) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZUCth-0006Br-Eg for qemu-devel@nongnu.org; Tue, 25 Aug 2015 08:00:13 -0400 Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga102.jf.intel.com with ESMTP; 25 Aug 2015 05:00:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.15,745,1432623600"; d="scan'208";a="548153247" Received: from ll.sh.intel.com (HELO localhost) ([10.239.13.27]) by FMSMGA003.fm.intel.com with ESMTP; 25 Aug 2015 05:00:10 -0700 From: Liang Li To: qemu-devel@nongnu.org Date: Tue, 25 Aug 2015 19:59:08 +0800 Message-Id: <1440503950-14174-2-git-send-email-liang.z.li@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1440503950-14174-1-git-send-email-liang.z.li@intel.com> References: <1440503950-14174-1-git-send-email-liang.z.li@intel.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 134.134.136.24 Cc: amit.shah@redhat.com, yang.z.zhang@intel.com, Liang Li , dgilbert@redhat.com, quintela@redhat.com Subject: [Qemu-devel] [PATCH 1/3] qemu-file: improve qemu_put_compression_data X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org There are some flaws in qemu_put_compression_data so that it can't not operate on an normal QEMUFile, improve it so as to use it later. Signed-off-by: Liang Li --- migration/qemu-file.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/migration/qemu-file.c b/migration/qemu-file.c index 6bb3dc1..59967b6 100644 --- a/migration/qemu-file.c +++ b/migration/qemu-file.c @@ -567,7 +567,9 @@ ssize_t qemu_put_compression_data(QEMUFile *f, const uint8_t *p, size_t size, ssize_t blen = IO_BUF_SIZE - f->buf_index - sizeof(int32_t); if (blen < compressBound(size)) { - return 0; + if (f->ops->writev_buffer || f->ops->put_buffer) { + qemu_fflush(f); + } } if (compress2(f->buf + f->buf_index + sizeof(int32_t), (uLongf *)&blen, (Bytef *)p, size, level) != Z_OK) { @@ -575,7 +577,13 @@ ssize_t qemu_put_compression_data(QEMUFile *f, const uint8_t *p, size_t size, return 0; } qemu_put_be32(f, blen); + if (f->ops->writev_buffer) { + add_to_iovec(f, f->buf + f->buf_index, blen); + } f->buf_index += blen; + if (f->buf_index == IO_BUF_SIZE) { + qemu_fflush(f); + } return blen + sizeof(int32_t); }