From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40346) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VjQJF-0006wn-MP for qemu-devel@nongnu.org; Thu, 21 Nov 2013 04:12:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VjQJ6-0003S4-Oq for qemu-devel@nongnu.org; Thu, 21 Nov 2013 04:12:25 -0500 Received: from e28smtp06.in.ibm.com ([122.248.162.6]:58195) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VjQJ6-0003R6-0o for qemu-devel@nongnu.org; Thu, 21 Nov 2013 04:12:16 -0500 Received: from /spool/local by e28smtp06.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 21 Nov 2013 14:42:11 +0530 Received: from d28relay03.in.ibm.com (d28relay03.in.ibm.com [9.184.220.60]) by d28dlp03.in.ibm.com (Postfix) with ESMTP id 687681258056 for ; Thu, 21 Nov 2013 14:43:03 +0530 (IST) Received: from d28av03.in.ibm.com (d28av03.in.ibm.com [9.184.220.65]) by d28relay03.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id rAL9C2Nd2556194 for ; Thu, 21 Nov 2013 14:42:02 +0530 Received: from d28av03.in.ibm.com (localhost [127.0.0.1]) by d28av03.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id rAL9C73V030355 for ; Thu, 21 Nov 2013 14:42:08 +0530 From: Lei Li Date: Thu, 21 Nov 2013 17:11:30 +0800 Message-Id: <1385025100-3191-8-git-send-email-lilei@linux.vnet.ibm.com> In-Reply-To: <1385025100-3191-1-git-send-email-lilei@linux.vnet.ibm.com> References: <1385025100-3191-1-git-send-email-lilei@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH 07/17] migration-local: override before_ram_iterate to send pipefd List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: aarcange@redhat.com, Lei Li , quintela@redhat.com, mdroth@linux.vnet.ibm.com, mrhines@linux.vnet.ibm.com, aliguori@amazon.com, lagarcia@br.ibm.com, pbonzini@redhat.com, rcj@linux.vnet.ibm.com Override before_ram_iterate to send pipefd. It will qemu_fflush the stream QEMUFile and send it in RAM_CONTROL_SETUP stage. Signed-off-by: Lei Li --- migration-local.c | 25 +++++++++++++++++++++++++ 1 files changed, 25 insertions(+), 0 deletions(-) diff --git a/migration-local.c b/migration-local.c index f4265a1..e028beb 100644 --- a/migration-local.c +++ b/migration-local.c @@ -114,6 +114,30 @@ 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_SETUP) { + 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 +148,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) -- 1.7.7.6