From patchwork Tue Oct 22 03:25:33 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lei Li X-Patchwork-Id: 285333 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 7CFB22C016A for ; Tue, 22 Oct 2013 14:29:43 +1100 (EST) Received: from localhost ([::1]:42771 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VYSf7-0002Y3-Iz for incoming@patchwork.ozlabs.org; Mon, 21 Oct 2013 23:29:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47263) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VYSbv-0005So-27 for qemu-devel@nongnu.org; Mon, 21 Oct 2013 23:26:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VYSbl-0004Xq-Ro for qemu-devel@nongnu.org; Mon, 21 Oct 2013 23:26:23 -0400 Received: from e28smtp04.in.ibm.com ([122.248.162.4]:60209) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VYSbl-0004Xk-6S for qemu-devel@nongnu.org; Mon, 21 Oct 2013 23:26:13 -0400 Received: from /spool/local by e28smtp04.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 22 Oct 2013 08:56:11 +0530 Received: from d28dlp02.in.ibm.com (9.184.220.127) by e28smtp04.in.ibm.com (192.168.1.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 22 Oct 2013 08:56:09 +0530 Received: from d28relay02.in.ibm.com (d28relay02.in.ibm.com [9.184.220.59]) by d28dlp02.in.ibm.com (Postfix) with ESMTP id E59DF394003F for ; Tue, 22 Oct 2013 08:55:48 +0530 (IST) Received: from d28av04.in.ibm.com (d28av04.in.ibm.com [9.184.220.66]) by d28relay02.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r9M3T48R23396476 for ; Tue, 22 Oct 2013 08:59:04 +0530 Received: from d28av04.in.ibm.com (localhost [127.0.0.1]) by d28av04.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id r9M3Q8JR023307 for ; Tue, 22 Oct 2013 08:56:08 +0530 Received: from localhost.cn.ibm.com ([9.115.122.43]) by d28av04.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id r9M3PhTZ022250; Tue, 22 Oct 2013 08:56:07 +0530 From: Lei Li To: qemu-devel@nongnu.org Date: Tue, 22 Oct 2013 11:25:33 +0800 Message-Id: <1382412341-1173-10-git-send-email-lilei@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.7.6 In-Reply-To: <1382412341-1173-1-git-send-email-lilei@linux.vnet.ibm.com> References: <1382412341-1173-1-git-send-email-lilei@linux.vnet.ibm.com> X-TM-AS-MML: No X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13102203-5564-0000-0000-00000A46E456 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 122.248.162.4 Cc: aarcange@redhat.com, aliguori@us.ibm.com, Lei Li , quintela@redhat.com, mdroth@linux.vnet.ibm.com, mrhines@linux.vnet.ibm.com, lagarcia@br.ibm.com, pbonzini@redhat.com, rcj@linux.vnet.ibm.com Subject: [Qemu-devel] [PATCH 09/17] migration-local: override before_ram_iterate to send pipefd 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 Override befor_ram_iterate to send pipefd. It will write the RAM_SAVE_FLAG_HOOK flags which will trigger the load hook to receive it. Signed-off-by: Lei Li --- migration-local.c | 26 ++++++++++++++++++++++++++ 1 files changed, 26 insertions(+), 0 deletions(-) diff --git a/migration-local.c b/migration-local.c index ed0ae6c..92c661c 100644 --- a/migration-local.c +++ b/migration-local.c @@ -114,6 +114,31 @@ static int qemu_local_close(void *opaque) return 0; } +static int send_pipefd(int sockfd, int pipefd); + +static int qemu_local_send_pipefd(QEMUFile *f, void *opaque, + uint64_t flags) +{ + QEMUFileLocal *s = opaque; + int ret; + + if (s->unix_page_flipping) { + /* Avoid sending pipe fd again in ram_save_complete() stage */ + if (flags != RAM_CONTROL_FINISH) { + qemu_put_be64(f, RAM_SAVE_FLAG_HOOK); + qemu_fflush(f); + ret = send_pipefd(s->sockfd, s->pipefd[0]); + if (ret < 0) { + fprintf(stderr, "failed to pass pipe\n"); + return ret; + } + DPRINTF("pipe fd was sent\n"); + } + } + + return 0; +} + static const QEMUFileOps pipe_read_ops = { .get_fd = qemu_local_get_sockfd, .get_buffer = qemu_local_get_buffer, @@ -124,6 +149,7 @@ static const QEMUFileOps pipe_write_ops = { .get_fd = qemu_local_get_sockfd, .writev_buffer = qemu_local_writev_buffer, .close = qemu_local_close, + .before_ram_iterate = qemu_local_send_pipefd, }; QEMUFile *qemu_fopen_socket_local(int sockfd, const char *mode)