From patchwork Thu Nov 5 18:10:56 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Dr. David Alan Gilbert" X-Patchwork-Id: 540582 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)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 986DF1402D6 for ; Fri, 6 Nov 2015 05:29:31 +1100 (AEDT) Received: from localhost ([::1]:34222 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZuPHt-00048g-Bk for incoming@patchwork.ozlabs.org; Thu, 05 Nov 2015 13:29:29 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44260) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZuP1g-0008RD-0c for qemu-devel@nongnu.org; Thu, 05 Nov 2015 13:12:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZuP1d-0003wK-V6 for qemu-devel@nongnu.org; Thu, 05 Nov 2015 13:12:43 -0500 Received: from mx1.redhat.com ([209.132.183.28]:44076) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZuP1d-0003vo-Ny for qemu-devel@nongnu.org; Thu, 05 Nov 2015 13:12:41 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 4EAA98EFE6; Thu, 5 Nov 2015 18:12:41 +0000 (UTC) Received: from dgilbert-t530.redhat.com (ovpn-116-77.ams2.redhat.com [10.36.116.77]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id tA5IBN2F025766; Thu, 5 Nov 2015 13:12:39 -0500 From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org Date: Thu, 5 Nov 2015 18:10:56 +0000 Message-Id: <1446747083-18205-30-git-send-email-dgilbert@redhat.com> In-Reply-To: <1446747083-18205-1-git-send-email-dgilbert@redhat.com> References: <1446747083-18205-1-git-send-email-dgilbert@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: aarcange@redhat.com, yamahata@private.email.ne.jp, quintela@redhat.com, liang.z.li@intel.com, luis@cs.umu.se, bharata@linux.vnet.ibm.com, amit.shah@redhat.com, pbonzini@redhat.com, david@gibson.dropbear.id.au Subject: [Qemu-devel] [PATCH v9 29/56] migrate_start_postcopy: Command to trigger transition to postcopy 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 From: "Dr. David Alan Gilbert" Once postcopy is enabled (with migrate_set_capability), the migration will still start on precopy mode. To cause a transition into postcopy the: migrate_start_postcopy command must be issued. Postcopy will start sometime after this (when it's next checked in the migration loop). Issuing the command before migration has started will error, and issuing after it has finished is ignored. Signed-off-by: Dr. David Alan Gilbert Reviewed-by: Eric Blake Reviewed-by: Juan Quintela Reviewed-by: Amit Shah --- hmp-commands.hx | 15 +++++++++++++++ hmp.c | 7 +++++++ hmp.h | 1 + include/migration/migration.h | 3 +++ migration/migration.c | 22 ++++++++++++++++++++++ qapi-schema.json | 8 ++++++++ qmp-commands.hx | 19 +++++++++++++++++++ 7 files changed, 75 insertions(+) diff --git a/hmp-commands.hx b/hmp-commands.hx index 3a4ae39..8939b98 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -1008,6 +1008,21 @@ Set the parameter @var{parameter} for migration. ETEXI { + .name = "migrate_start_postcopy", + .args_type = "", + .params = "", + .help = "Switch migration to postcopy mode", + .mhandler.cmd = hmp_migrate_start_postcopy, + }, + +STEXI +@item migrate_start_postcopy +@findex migrate_start_postcopy +Switch in-progress migration to postcopy mode. Ignored after the end of +migration (or once already in postcopy). +ETEXI + + { .name = "client_migrate_info", .args_type = "protocol:s,hostname:s,port:i?,tls-port:i?,cert-subject:s?", .params = "protocol hostname port tls-port cert-subject", diff --git a/hmp.c b/hmp.c index a15d00c..e1f854a 100644 --- a/hmp.c +++ b/hmp.c @@ -1293,6 +1293,13 @@ void hmp_client_migrate_info(Monitor *mon, const QDict *qdict) hmp_handle_error(mon, &err); } +void hmp_migrate_start_postcopy(Monitor *mon, const QDict *qdict) +{ + Error *err = NULL; + qmp_migrate_start_postcopy(&err); + hmp_handle_error(mon, &err); +} + void hmp_set_password(Monitor *mon, const QDict *qdict) { const char *protocol = qdict_get_str(qdict, "protocol"); diff --git a/hmp.h b/hmp.h index 81656c3..a8c5b5a 100644 --- a/hmp.h +++ b/hmp.h @@ -69,6 +69,7 @@ void hmp_migrate_set_capability(Monitor *mon, const QDict *qdict); void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict); void hmp_migrate_set_cache_size(Monitor *mon, const QDict *qdict); void hmp_client_migrate_info(Monitor *mon, const QDict *qdict); +void hmp_migrate_start_postcopy(Monitor *mon, const QDict *qdict); void hmp_set_password(Monitor *mon, const QDict *qdict); void hmp_expire_password(Monitor *mon, const QDict *qdict); void hmp_eject(Monitor *mon, const QDict *qdict); diff --git a/include/migration/migration.h b/include/migration/migration.h index 2e9fa3c..2176666 100644 --- a/include/migration/migration.h +++ b/include/migration/migration.h @@ -127,6 +127,9 @@ struct MigrationState int64_t xbzrle_cache_size; int64_t setup_time; int64_t dirty_sync_count; + + /* Flag set once the migration has been asked to enter postcopy */ + bool start_postcopy; }; void process_incoming_migration(QEMUFile *f); diff --git a/migration/migration.c b/migration/migration.c index 28eaf4b..f5cb9c5 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -668,6 +668,28 @@ void qmp_migrate_set_parameters(bool has_compress_level, } } +void qmp_migrate_start_postcopy(Error **errp) +{ + MigrationState *s = migrate_get_current(); + + if (!migrate_postcopy_ram()) { + error_setg(errp, "Enable postcopy with migration_set_capability before" + " the start of migration"); + return; + } + + if (s->state == MIGRATION_STATUS_NONE) { + error_setg(errp, "Postcopy must be started after migration has been" + " started"); + return; + } + /* + * we don't error if migration has finished since that would be racy + * with issuing this command. + */ + atomic_set(&s->start_postcopy, true); +} + /* shared migration helpers */ static void migrate_set_state(MigrationState *s, int old_state, int new_state) diff --git a/qapi-schema.json b/qapi-schema.json index b6a3c10..66e1f2f 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -702,6 +702,14 @@ '*tls-port': 'int', '*cert-subject': 'str' } } ## +# @migrate-start-postcopy +# +# Switch migration to postcopy mode +# +# Since: 2.5 +{ 'command': 'migrate-start-postcopy' } + +## # @MouseInfo: # # Information about a mouse device. diff --git a/qmp-commands.hx b/qmp-commands.hx index d7cf0ff..7f85d40 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -718,6 +718,25 @@ Example: EQMP { + .name = "migrate-start-postcopy", + .args_type = "", + .mhandler.cmd_new = qmp_marshal_migrate_start_postcopy, + }, + +SQMP +migrate-start-postcopy +---------------------- + +Switch an in-progress migration to postcopy mode. Ignored after the end of +migration (or once already in postcopy). + +Example: +-> { "execute": "migrate-start-postcopy" } +<- { "return": {} } + +EQMP + + { .name = "query-migrate-cache-size", .args_type = "", .mhandler.cmd_new = qmp_marshal_query_migrate_cache_size,