From patchwork Thu Aug 19 13:18:40 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 62155 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 7E26CB70D8 for ; Thu, 19 Aug 2010 23:22:17 +1000 (EST) Received: from localhost ([127.0.0.1]:36513 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Om54Q-0008SF-LM for incoming@patchwork.ozlabs.org; Thu, 19 Aug 2010 09:22:14 -0400 Received: from [140.186.70.92] (port=40017 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Om51L-0007sn-4y for qemu-devel@nongnu.org; Thu, 19 Aug 2010 09:19:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Om51J-0000xL-Ui for qemu-devel@nongnu.org; Thu, 19 Aug 2010 09:19:03 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47954) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Om51J-0000xB-OU for qemu-devel@nongnu.org; Thu, 19 Aug 2010 09:19:01 -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.13.8/8.13.8) with ESMTP id o7JDJ07c018714 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 19 Aug 2010 09:19:01 -0400 Received: from localhost (ovpn-113-87.phx2.redhat.com [10.3.113.87]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o7JDIxdX030518; Thu, 19 Aug 2010 09:19:00 -0400 From: Luiz Capitulino To: aliguori@us.ibm.com Date: Thu, 19 Aug 2010 10:18:40 -0300 Message-Id: <1282223922-5971-3-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1282223922-5971-1-git-send-email-lcapitulino@redhat.com> References: <1282223922-5971-1-git-send-email-lcapitulino@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: qemu-devel@nongnu.org, Avi Kivity Subject: [Qemu-devel] [PATCH 2/4] QEMUFileBuffered: indicate that we're ready when the underlying file is ready 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 From: Avi Kivity QEMUFileBuffered stops writing when the underlying QEMUFile is not ready, and tells its producer so. However, when the underlying QEMUFile becomes ready, it neglects to pass that information along, resulting in stoppage of all data until the next tick (a tenths of a second). Usually this doesn't matter, because most QEMUFiles used with QEMUFileBuffered are almost always ready, but in the case of exec: migration this is not true, due to the small pipe buffers used to connect to the target process. The result is very slow migration. Fix by detecting the readiness notification and propagating it. The detection is a little ugly since QEMUFile overloads put_buffer() to send it, but that's the suject for a different patch. Signed-off-by: Avi Kivity Signed-off-by: Luiz Capitulino --- buffered_file.c | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-) diff --git a/buffered_file.c b/buffered_file.c index be147d6..1836e7e 100644 --- a/buffered_file.c +++ b/buffered_file.c @@ -156,6 +156,14 @@ static int buffered_put_buffer(void *opaque, const uint8_t *buf, int64_t pos, in offset = size; } + if (pos == 0 && size == 0) { + DPRINTF("file is ready\n"); + if (s->bytes_xfer <= s->xfer_limit) { + DPRINTF("notifying client\n"); + s->put_ready(s->opaque); + } + } + return offset; }