From patchwork Wed Dec 19 12:33:40 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [17/34] buffered_file: Unfold the trick to restart generating migration data From: Juan Quintela X-Patchwork-Id: 207332 Message-Id: <1355920437-29882-18-git-send-email-quintela@redhat.com> To: qemu-devel@nongnu.org Date: Wed, 19 Dec 2012 13:33:40 +0100 This was needed before due to the way that the callbacks worked. Signed-off-by: Juan Quintela Reviewed-by: Paolo Bonzini --- buffered_file.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/buffered_file.c b/buffered_file.c index 5cd477a..f4f5110 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 */ g_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;