From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40983) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VCbpL-00041M-Av for qemu-devel@nongnu.org; Thu, 22 Aug 2013 16:50:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VCbpC-0001QW-C4 for qemu-devel@nongnu.org; Thu, 22 Aug 2013 16:49:55 -0400 Received: from e32.co.us.ibm.com ([32.97.110.150]:48958) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VCbpC-0001QH-5T for qemu-devel@nongnu.org; Thu, 22 Aug 2013 16:49:46 -0400 Received: from /spool/local by e32.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 22 Aug 2013 14:49:44 -0600 Received: from d03relay01.boulder.ibm.com (d03relay01.boulder.ibm.com [9.17.195.226]) by d03dlp03.boulder.ibm.com (Postfix) with ESMTP id C3B6F19D803E for ; Thu, 22 Aug 2013 14:49:28 -0600 (MDT) Received: from d03av06.boulder.ibm.com (d03av06.boulder.ibm.com [9.17.195.245]) by d03relay01.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r7MKnfNv167364 for ; Thu, 22 Aug 2013 14:49:41 -0600 Received: from d03av06.boulder.ibm.com (loopback [127.0.0.1]) by d03av06.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r7MKqV2a014135 for ; Thu, 22 Aug 2013 14:52:32 -0600 Message-ID: <52167964.8030901@linux.vnet.ibm.com> Date: Thu, 22 Aug 2013 16:49:40 -0400 From: "Michael R. Hines" MIME-Version: 1.0 References: <1377069536-12658-1-git-send-email-lilei@linux.vnet.ibm.com> <1377069536-12658-11-git-send-email-lilei@linux.vnet.ibm.com> In-Reply-To: <1377069536-12658-11-git-send-email-lilei@linux.vnet.ibm.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 10/18] migration-local: implementation of outgoing part List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Lei Li Cc: aarcange@redhat.com, aliguori@us.ibm.com, quintela@redhat.com, qemu-devel@nongnu.org, lagarcia@br.ibm.com, pbonzini@redhat.com, rcj@linux.vnet.ibm.com On 08/21/2013 03:18 AM, Lei Li wrote: > Implementation of outgoing part for localhost migration. > The integration of migration thread and corresponding > adjustment will be in coming patches. > > Signed-off-by: Lei Li > --- > include/migration/migration.h | 2 + > migration-local.c | 85 +++++++++++++++++++++++++++++++++++++++++ > 2 files changed, 87 insertions(+), 0 deletions(-) > > diff --git a/include/migration/migration.h b/include/migration/migration.h > index 5336117..d2c7eff 100644 > --- a/include/migration/migration.h > +++ b/include/migration/migration.h > @@ -92,6 +92,8 @@ void rdma_start_outgoing_migration(void *opaque, const char *host_port, Error ** > > void rdma_start_incoming_migration(const char *host_port, Error **errp); > > +void local_start_outgoing_migration(void *opaque, const char *uri, Error **errp); > + > void migrate_fd_error(MigrationState *s); > > void migrate_fd_connect(MigrationState *s); > diff --git a/migration-local.c b/migration-local.c > index 93190fd..cf4a091 100644 > --- a/migration-local.c > +++ b/migration-local.c > @@ -209,3 +209,88 @@ static void *qemu_fopen_local(int fd, const char *mode) > > return s->file; > } > + > +/************************************************************************ > + * Outgoing part > + **/ > + > +static QEMUFileLocal *local_migration_init(void) > +{ > + QEMUFileLocal *s = g_malloc0(sizeof(*s)); > + > + s->state = MIG_STATE_SETUP; > + trace_migrate_set_state(MIG_STATE_SETUP); > + s->fd = -1; > + s->last_block_sent = NULL; > + > + return s; > +} > + migration.c already does this. Is there some reason why you need to access the state machine? If you have a custom initial values, you should change migrate_get_current, not create your own init(). > +static void unix_local_wait_for_connect(int fd, void *opaque) > +{ > + MigrationState *s = opaque; > + > + if (fd < 0) { > + DPRINTF("migrate connect error\n"); > + s->file = NULL; > + migrate_fd_error(s); > + } else { > + DPRINTF("migrate connect success\n"); > + s->file = qemu_fopen_local(fd, "wb"); > + migrate_fd_connect(s); > + } > +} > + > +static void unix_local_outgoing_connect(MigrationState *s, const char *path, > + Error **errp) > +{ > + unix_nonblocking_connect(path, unix_local_wait_for_connect, s, errp); > +} > + > +void local_start_outgoing_migration(void *opaque, const char *uri, > + Error **errp) > +{ > + MigrationState *s = opaque; > + const char *path; > + QEMUFileLocal *local; > + Error *local_err = NULL; > + int is_vm_running; > + int ret; > + > + local = local_migration_init(); > + if (local == NULL) { > + error_setg(errp, "Failed to initialize\n"); > + } > + > + bdrv_flush_all(); > + > + is_vm_running = runstate_is_running(); > + > + /* Stop the VM first */ > + if (is_vm_running) { > + ret = vm_stop(RUN_STATE_SAVE_VM); > + if (ret < 0) { > + goto fail; > + } > + } > + What is this for? The migration_thread() already does this work for you..... Are you trying to avoid pre-copy? Pre-copy should not be bad for you. > + /* Start outgoing migration via unix socket. */ > + if (uri) { > + /* XXX. Creation of a new unix_start_outgoing_migration_* is > + * not necessary, just for the first step. This will be replaced > + * by vmsplice mechanism. > + **/ > + unix_local_outgoing_connect(s, path, &local_err); > + } else { > + error_set(errp, QERR_INVALID_PARAMETER_VALUE, > + "uri", "a valid migration protocol"); > + goto fail; > + } > + > + return; > + > +fail: > + error_propagate(errp, local_err); > + g_free(local); > + migrate_fd_error(s); > +}