From patchwork Mon Apr 8 11:29:54 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 234741 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 4AC412C00E3 for ; Mon, 8 Apr 2013 21:30:41 +1000 (EST) Received: from localhost ([::1]:51177 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UPAHV-0007Tq-W4 for incoming@patchwork.ozlabs.org; Mon, 08 Apr 2013 07:30:38 -0400 Received: from eggs.gnu.org ([208.118.235.92]:46687) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UPAH4-0007T8-Ts for qemu-devel@nongnu.org; Mon, 08 Apr 2013 07:30:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UPAGy-0006Y2-U8 for qemu-devel@nongnu.org; Mon, 08 Apr 2013 07:30:10 -0400 Received: from mail-we0-x22c.google.com ([2a00:1450:400c:c03::22c]:34611) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UPAGy-0006Vv-OK for qemu-devel@nongnu.org; Mon, 08 Apr 2013 07:30:04 -0400 Received: by mail-we0-f172.google.com with SMTP id r3so4477417wey.3 for ; Mon, 08 Apr 2013 04:30:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:sender:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references; bh=9jUIaZLWchNTdspNdMLHsNwFmm5MXOmtf45wMclwPsY=; b=YnIDaE4mAtL5QATOYK7vk8pDf2+m0Wiiiz5z6BQAR25l2Azsm0dzHTD9yBz5DNtAqY UnJfF2COm9ddMS8twDnVDSU0Cgd69pTFl9IHgoMiHFjbrkBYkFwYNVmbqUAN46p3JpTr zOPhPDY/9GrX6hCrRNMfcr9UU4lc5Dwm7K6/IAoR3J8Xln7s2PNV3II0/lCc2HyaHB1G bBliBclUABIQvCjcetQg3EndZ/jx1X5VkpvI3b9LO9H+WGmQpqZ1b5ZyNfWBBnftq3vI klH8v0qZ/+kRUlfzG0uCdWYT4mJHPPoK2+xr6f7Ryh+Jfo4g9uOj5ObBq9DXpiKScf6R mhUQ== X-Received: by 10.180.36.48 with SMTP id n16mr12201971wij.30.1365420604030; Mon, 08 Apr 2013 04:30:04 -0700 (PDT) Received: from playground.lan (93-34-176-20.ip50.fastwebnet.it. [93.34.176.20]) by mx.google.com with ESMTPS id h10sm21504167wic.8.2013.04.08.04.30.01 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 08 Apr 2013 04:30:03 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 8 Apr 2013 13:29:54 +0200 Message-Id: <1365420597-5506-2-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1365420597-5506-1-git-send-email-pbonzini@redhat.com> References: <1365420597-5506-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c03::22c Cc: kwolf@redhat.com, owasserm@redhat.com, quintela@redhat.com Subject: [Qemu-devel] [PATCH 1/4] migration: set f->is_write and flush in add_to_iovec 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 Signed-off-by: Paolo Bonzini --- savevm.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/savevm.c b/savevm.c index b1d8988..c952c41 100644 --- a/savevm.c +++ b/savevm.c @@ -631,6 +631,11 @@ static void add_to_iovec(QEMUFile *f, const uint8_t *buf, int size) f->iov[f->iovcnt].iov_base = (uint8_t *)buf; f->iov[f->iovcnt++].iov_len = size; } + + f->is_write = 1; + if (f->buf_index >= IO_BUF_SIZE || f->iovcnt >= MAX_IOV_SIZE) { + qemu_fflush(f); + } } void qemu_put_buffer_async(QEMUFile *f, const uint8_t *buf, int size) @@ -645,14 +650,8 @@ void qemu_put_buffer_async(QEMUFile *f, const uint8_t *buf, int size) abort(); } - add_to_iovec(f, buf, size); - - f->is_write = 1; f->bytes_xfer += size; - - if (f->buf_index >= IO_BUF_SIZE || f->iovcnt >= MAX_IOV_SIZE) { - qemu_fflush(f); - } + add_to_iovec(f, buf, size); } void qemu_put_buffer(QEMUFile *f, const uint8_t *buf, int size) @@ -674,7 +673,6 @@ void qemu_put_buffer(QEMUFile *f, const uint8_t *buf, int size) if (l > size) l = size; memcpy(f->buf + f->buf_index, buf, l); - f->is_write = 1; f->buf_index += l; qemu_put_buffer_async(f, f->buf + (f->buf_index - l), l); if (qemu_file_get_error(f)) { @@ -697,15 +695,10 @@ void qemu_put_byte(QEMUFile *f, int v) abort(); } - f->buf[f->buf_index++] = v; - f->is_write = 1; + f->buf[f->buf_index] = v; f->bytes_xfer++; - - add_to_iovec(f, f->buf + (f->buf_index - 1), 1); - - if (f->buf_index >= IO_BUF_SIZE || f->iovcnt >= MAX_IOV_SIZE) { - qemu_fflush(f); - } + add_to_iovec(f, f->buf + f->buf_index, 1); + f->buf_index++; } static void qemu_file_skip(QEMUFile *f, int size)