From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:38022) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UPWxK-00075v-Mu for qemu-devel@nongnu.org; Tue, 09 Apr 2013 07:43:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UPWxI-0006ZX-WA for qemu-devel@nongnu.org; Tue, 09 Apr 2013 07:43:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:8881) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UPWxI-0006ZG-Kr for qemu-devel@nongnu.org; Tue, 09 Apr 2013 07:43:16 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r39BhGr8030790 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 9 Apr 2013 07:43:16 -0400 From: Juan Quintela In-Reply-To: <1365420597-5506-5-git-send-email-pbonzini@redhat.com> (Paolo Bonzini's message of "Mon, 8 Apr 2013 13:29:57 +0200") References: <1365420597-5506-1-git-send-email-pbonzini@redhat.com> <1365420597-5506-5-git-send-email-pbonzini@redhat.com> Date: Tue, 09 Apr 2013 13:43:22 +0200 Message-ID: <874nfgdj51.fsf@elfo.elfo> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH 4/4] migration: simplify writev vs. non-writev logic Reply-To: quintela@redhat.com List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: kwolf@redhat.com, owasserm@redhat.com, qemu-devel@nongnu.org Paolo Bonzini wrote: > 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); > } > } If you follow my advice of moving the call to add_to_iovec() you get this one simplified and only one place to do this. Thanks, Juan.