From patchwork Tue Dec 11 12:46:46 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 205230 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 92A8F2C008C for ; Wed, 12 Dec 2012 01:04:14 +1100 (EST) Received: from localhost ([::1]:57432 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TiPG5-0007T5-5P for incoming@patchwork.ozlabs.org; Tue, 11 Dec 2012 07:48:25 -0500 Received: from eggs.gnu.org ([208.118.235.92]:50990) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TiPFG-0005zN-RW for qemu-devel@nongnu.org; Tue, 11 Dec 2012 07:47:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TiPF8-0004NZ-KQ for qemu-devel@nongnu.org; Tue, 11 Dec 2012 07:47:34 -0500 Received: from mx1.redhat.com ([209.132.183.28]:24130) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TiPF8-0004NS-Cs for qemu-devel@nongnu.org; Tue, 11 Dec 2012 07:47:26 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id qBBClPi5027312 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 11 Dec 2012 07:47:25 -0500 Received: from trasno.mitica (ovpn-113-46.phx2.redhat.com [10.3.113.46]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id qBBClCVa027513; Tue, 11 Dec 2012 07:47:25 -0500 From: Juan Quintela To: qemu-devel@nongnu.org Date: Tue, 11 Dec 2012 13:46:46 +0100 Message-Id: <1355230031-28233-11-git-send-email-quintela@redhat.com> In-Reply-To: <1355230031-28233-1-git-send-email-quintela@redhat.com> References: <1355230031-28233-1-git-send-email-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 10/35] buffered_file: Unfold the trick to restart generating migration 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 This was needed before due to the way that the callbacks worked. Signed-off-by: Juan Quintela --- buffered_file.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/buffered_file.c b/buffered_file.c index d68eb66..9ef30b3 100644 --- a/buffered_file.c +++ b/buffered_file.c @@ -113,14 +113,6 @@ static int buffered_put_buffer(void *opaque, const uint8_t *buf, int64_t pos, in return error; } - if (pos == 0 && size == 0) { - DPRINTF("file is ready\n"); - if (s->bytes_xfer < s->xfer_limit) { - DPRINTF("notifying client\n"); - migrate_fd_put_ready(s->migration_state); - } - } - return size; } @@ -223,8 +215,17 @@ static void *buffered_file_thread(void *opaque) /* usleep expects microseconds */ usleep((expire_time - current_time)*1000); } - buffered_put_buffer(s, NULL, 0, 0); + if (buffered_flush(s) < 0) { + break; + } + + DPRINTF("file is ready\n"); + if (s->bytes_xfer < s->xfer_limit) { + DPRINTF("notifying client\n"); + migrate_fd_put_ready(s->migration_state); + } } + g_free(s->buffer); g_free(s); return NULL;