From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50262) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VOq9k-0003Y7-0d for qemu-devel@nongnu.org; Wed, 25 Sep 2013 10:33:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VOq9b-0006M2-3z for qemu-devel@nongnu.org; Wed, 25 Sep 2013 10:33:31 -0400 Received: from e28smtp03.in.ibm.com ([122.248.162.3]:40414) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VOq9a-0006LJ-Fd for qemu-devel@nongnu.org; Wed, 25 Sep 2013 10:33:23 -0400 Received: from /spool/local by e28smtp03.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 25 Sep 2013 20:03:18 +0530 Received: from d28relay02.in.ibm.com (d28relay02.in.ibm.com [9.184.220.59]) by d28dlp03.in.ibm.com (Postfix) with ESMTP id C6BF61258051 for ; Wed, 25 Sep 2013 20:03:27 +0530 (IST) Received: from d28av02.in.ibm.com (d28av02.in.ibm.com [9.184.220.64]) by d28relay02.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r8PEZZrn38142176 for ; Wed, 25 Sep 2013 20:05:35 +0530 Received: from d28av02.in.ibm.com (localhost [127.0.0.1]) by d28av02.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id r8PEXEdj004404 for ; Wed, 25 Sep 2013 20:03:14 +0530 From: Lei Li Date: Wed, 25 Sep 2013 22:32:47 +0800 Message-Id: <1380119568-5530-8-git-send-email-lilei@linux.vnet.ibm.com> In-Reply-To: <1380119568-5530-1-git-send-email-lilei@linux.vnet.ibm.com> References: <1380119568-5530-1-git-send-email-lilei@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH 7/8] migration-unix: side channel support on unix outgoing 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, anthony@codemonkey.ws, lagarcia@br.ibm.com, pbonzini@redhat.com, rcj@linux.vnet.ibm.com This patch adds side channel support on the outgoing of unix migration. It will create a pipe and pass the read pipe fd to destination process by send_pipefd(). If the pipe fd was passed successfully, the qemu_fopen_pipe will be called with write mode to send RAM to the write pipe fd. Signed-off-by: Lei Li --- migration-unix.c | 34 +++++++++++++++++++++++++++++++--- 1 files changed, 31 insertions(+), 3 deletions(-) diff --git a/migration-unix.c b/migration-unix.c index 651fc5b..0bfc1c7 100644 --- a/migration-unix.c +++ b/migration-unix.c @@ -33,16 +33,44 @@ static void unix_wait_for_connect(int fd, void *opaque) { MigrationState *s = opaque; + int pipefd[2]; if (fd < 0) { DPRINTF("migrate connect error\n"); - s->file = NULL; - migrate_fd_error(s); + goto fail; } else { DPRINTF("migrate connect success\n"); - s->file = qemu_fopen_socket(fd, "wb"); + + if (s->enabled_capabilities[MIGRATION_CAPABILITY_UNIX_PAGE_FLIPPING]) { + if (pipe(pipefd) < 0) { + DPRINTF("qemu_fopen_pipe: %s", strerror(errno)); + goto fail; + } + + /* Send pipefd[0] to destination QEMU process */ + if (send_pipefd(fd, pipefd[0]) < 0) { + DPRINTF("failed to pass pipe\n"); + goto fail; + } + + s->file = qemu_fopen_pipe(pipefd[1], "w"); + } else { + s->file = qemu_fopen_socket(fd, "wb"); + } + + if (s->file == NULL) { + DPRINTF("failed to open migration target"); + migrate_fd_error(s); + return; + } + migrate_fd_connect(s); + return; } + +fail: + s->file = NULL; + migrate_fd_error(s); } void unix_start_outgoing_migration(MigrationState *s, const char *path, Error **errp) -- 1.7.7.6