From patchwork Mon Apr 8 11:29:57 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 234745 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 75E272C00D0 for ; Mon, 8 Apr 2013 21:33:02 +1000 (EST) Received: from localhost ([::1]:57187 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UPAJo-0002Pf-1I for incoming@patchwork.ozlabs.org; Mon, 08 Apr 2013 07:33:00 -0400 Received: from eggs.gnu.org ([208.118.235.92]:46722) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UPAHA-0007Tm-2Z for qemu-devel@nongnu.org; Mon, 08 Apr 2013 07:30:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UPAH4-0006cT-6B for qemu-devel@nongnu.org; Mon, 08 Apr 2013 07:30:16 -0400 Received: from mail-wi0-x235.google.com ([2a00:1450:400c:c05::235]:58930) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UPAH4-0006cL-0A for qemu-devel@nongnu.org; Mon, 08 Apr 2013 07:30:10 -0400 Received: by mail-wi0-f181.google.com with SMTP id hj8so2426905wib.2 for ; Mon, 08 Apr 2013 04:30:09 -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=i+DGRqJ0itpJlsV7q02aWADa/qPMEniTHvTprXwfYzI=; b=07nbPQgjPw+tju/r9CdhyCOOUn6ycmmodRBUUg9yKIyPDyLrxI9ueWb1VZebxmxjX4 ls4D1r3bCC8cyJMZf9ygYgjZtaJfgN90Ky1C5kHnjo0pPyjQIDPhCvD7GrIauCiIxpx1 E+nzTxFARjrQIr3ZxUXjfu8dlh5alrm659yLm3lf500UVoBZwmZR/uOePtWHonOWOxUF hn3O2+LQwfKQBAseoC5jYxW9mm0e2QYKcE++zqHqdQnxkFVamtQ8AOgOWkCxlpMV8gEt b7yg6WO9ciBWkOKpXNOqBVJez2MW4oyxwHAe78Z7FMBi/fTMsSpi03Y/va425l/NVg02 bmQQ== X-Received: by 10.180.87.170 with SMTP id az10mr12449276wib.3.1365420609285; Mon, 08 Apr 2013 04:30:09 -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.07 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 08 Apr 2013 04:30:08 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 8 Apr 2013 13:29:57 +0200 Message-Id: <1365420597-5506-5-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:c05::235 Cc: kwolf@redhat.com, owasserm@redhat.com, quintela@redhat.com Subject: [Qemu-devel] [PATCH 4/4] migration: simplify writev vs. non-writev logic 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 Check f->iovcnt in add_to_iovec, f->buf_index in qemu_put_buffer/byte. Signed-off-by: Paolo Bonzini --- savevm.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/savevm.c b/savevm.c index a2f6bc0..63f4c82 100644 --- a/savevm.c +++ b/savevm.c @@ -626,7 +626,7 @@ static void add_to_iovec(QEMUFile *f, const uint8_t *buf, int size) f->iov[f->iovcnt++].iov_len = size; } - if (f->buf_index >= IO_BUF_SIZE || f->iovcnt >= MAX_IOV_SIZE) { + if (f->iovcnt >= MAX_IOV_SIZE) { qemu_fflush(f); } } @@ -662,12 +662,10 @@ void qemu_put_buffer(QEMUFile *f, const uint8_t *buf, int size) f->bytes_xfer += size; if (f->ops->writev_buffer) { add_to_iovec(f, f->buf + f->buf_index, l); - f->buf_index += l; - } else { - f->buf_index += l; - if (f->buf_index == IO_BUF_SIZE) { - qemu_fflush(f); - } + } + f->buf_index += l; + if (f->buf_index == IO_BUF_SIZE) { + qemu_fflush(f); } if (qemu_file_get_error(f)) { break; @@ -687,12 +685,10 @@ void qemu_put_byte(QEMUFile *f, int v) f->bytes_xfer++; if (f->ops->writev_buffer) { add_to_iovec(f, f->buf + f->buf_index, 1); - f->buf_index++; - } else { - f->buf_index++; - if (f->buf_index == IO_BUF_SIZE) { - qemu_fflush(f); - } + } + f->buf_index++; + if (f->buf_index == IO_BUF_SIZE) { + qemu_fflush(f); } }