From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52054) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YWGpV-0003Tj-C3 for qemu-devel@nongnu.org; Fri, 13 Mar 2015 00:04:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YWGpT-0000gu-L4 for qemu-devel@nongnu.org; Fri, 13 Mar 2015 00:04:09 -0400 Received: from ozlabs.org ([2401:3900:2:1::2]:42085) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YWGpT-0000fh-2G for qemu-devel@nongnu.org; Fri, 13 Mar 2015 00:04:07 -0400 Date: Fri, 13 Mar 2015 12:26:52 +1100 From: David Gibson Message-ID: <20150313012652.GB11973@voom.redhat.com> References: <1424883128-9841-1-git-send-email-dgilbert@redhat.com> <1424883128-9841-24-git-send-email-dgilbert@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="irrheVdOic6+Kbak" Content-Disposition: inline In-Reply-To: <1424883128-9841-24-git-send-email-dgilbert@redhat.com> Subject: Re: [Qemu-devel] [PATCH v5 23/45] migrate_start_postcopy: Command to trigger transition to postcopy List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Dr. David Alan Gilbert (git)" Cc: aarcange@redhat.com, yamahata@private.email.ne.jp, quintela@redhat.com, qemu-devel@nongnu.org, amit.shah@redhat.com, pbonzini@redhat.com, yanghy@cn.fujitsu.com --irrheVdOic6+Kbak Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Feb 25, 2015 at 04:51:46PM +0000, Dr. David Alan Gilbert (git) wrot= e: > From: "Dr. David Alan Gilbert" >=20 > Once postcopy is enabled (with migrate_set_capability), the migration > will still start on precopy mode. To cause a transition into postcopy > the: >=20 > migrate_start_postcopy >=20 > command must be issued. Postcopy will start sometime after this > (when it's next checked in the migration loop). >=20 > Issuing the command before migration has started will error, > and issuing after it has finished is ignored. >=20 > Signed-off-by: Dr. David Alan Gilbert > Reviewed-by: Eric Blake > --- > 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(+) >=20 > diff --git a/hmp-commands.hx b/hmp-commands.hx > index e37bc8b..03b8b78 100644 > --- a/hmp-commands.hx > +++ b/hmp-commands.hx > @@ -985,6 +985,21 @@ Enable/Disable the usage of a capability @var{capabi= lity} for migration. > ETEXI > =20 > { > + .name =3D "migrate_start_postcopy", > + .args_type =3D "", > + .params =3D "", > + .help =3D "Switch migration to postcopy mode", > + .mhandler.cmd =3D 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 =3D "client_migrate_info", > .args_type =3D "protocol:s,hostname:s,port:i?,tls-port:i?,cert-= subject:s?", > .params =3D "protocol hostname port tls-port cert-subject", > diff --git a/hmp.c b/hmp.c > index b47f331..df9736c 100644 > --- a/hmp.c > +++ b/hmp.c > @@ -1140,6 +1140,13 @@ void hmp_migrate_set_capability(Monitor *mon, cons= t QDict *qdict) > } > } > =20 > +void hmp_migrate_start_postcopy(Monitor *mon, const QDict *qdict) > +{ > + Error *err =3D NULL; > + qmp_migrate_start_postcopy(&err); > + hmp_handle_error(mon, &err); > +} > + > void hmp_set_password(Monitor *mon, const QDict *qdict) > { > const char *protocol =3D qdict_get_str(qdict, "protocol"); > diff --git a/hmp.h b/hmp.h > index 4bb5dca..da1334f 100644 > --- a/hmp.h > +++ b/hmp.h > @@ -64,6 +64,7 @@ void hmp_migrate_set_downtime(Monitor *mon, const QDict= *qdict); > void hmp_migrate_set_speed(Monitor *mon, const QDict *qdict); > void hmp_migrate_set_capability(Monitor *mon, const QDict *qdict); > void hmp_migrate_set_cache_size(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 e6a814a..293c83e 100644 > --- a/include/migration/migration.h > +++ b/include/migration/migration.h > @@ -104,6 +104,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; > }; > =20 > void process_incoming_migration(QEMUFile *f); > diff --git a/migration/migration.c b/migration/migration.c > index a4fc7d7..43ca656 100644 > --- a/migration/migration.c > +++ b/migration/migration.c > @@ -372,6 +372,28 @@ void qmp_migrate_set_capabilities(MigrationCapabilit= yStatusList *params, > } > } > =20 > +void qmp_migrate_start_postcopy(Error **errp) > +{ > + MigrationState *s =3D 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 =3D=3D MIG_STATE_NONE) { > + error_setg(errp, "Postcopy must be started after migration has b= een" > + " 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); Why atomic_set? > +} > + > /* shared migration helpers */ > =20 > static void migrate_set_state(MigrationState *s, int old_state, int new_= state) > diff --git a/qapi-schema.json b/qapi-schema.json > index a8af1cb..7ff61e9 100644 > --- a/qapi-schema.json > +++ b/qapi-schema.json > @@ -542,6 +542,14 @@ > { 'command': 'query-migrate-capabilities', 'returns': ['MigrationCapab= ilityStatus']} > =20 > ## > +# @migrate-start-postcopy > +# > +# Switch migration to postcopy mode > +# > +# Since: 2.3 > +{ 'command': 'migrate-start-postcopy' } > + > +## > # @MouseInfo: > # > # Information about a mouse device. > diff --git a/qmp-commands.hx b/qmp-commands.hx > index a85d847..25d2208 100644 > --- a/qmp-commands.hx > +++ b/qmp-commands.hx > @@ -685,6 +685,25 @@ Example: > =20 > EQMP > { > + .name =3D "migrate-start-postcopy", > + .args_type =3D "", > + .mhandler.cmd_new =3D qmp_marshal_input_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 =3D "query-migrate-cache-size", > .args_type =3D "", > .mhandler.cmd_new =3D qmp_marshal_input_query_migrate_cache_size, --=20 David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson --irrheVdOic6+Kbak Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJVAjzcAAoJEGw4ysog2bOSslQP+gKKupS/LDTt50FDGDpl6YVT 1awFdi8MEvldWZ/F21faxyYdQCVwXs/ne+Q8HanUu0/R/SqJr+M86F7hkzJ1KIub RDyhVLway5nKnqKO+HXk2ANi39kWrDqJ54tDSmLpNqsTurdaevXfM6R6lrXqjulV rs5aN3L8HbY6VnkiFIKOIEHWPla0GYQNsC96433Ft61NxDIp+2wQThbpwuE2X99U ZbO5HBSl4sfS4lL3xOcXwD4Q76L12dwUowK0eDUhELo48G4QfsNDc8VOcyMxLNF2 bBSx1ivwObgmbpOy/grBK6R2mpdLx7iDYBH55dMBXezPHW4lM+7BNSjWj5BBMtYW VYZr0Hjx+YqIQQDuTmArIi+7+Z5nfvKJG8XToXolyuCk2a6YdaUjh6sH+/RNttqe TFLeCJhS26Ibfvob2LvrCNdbFiqcV15sqTAuHlvMuw1AWXgYQFi1GX893HnVzQA4 UCWZryzvdiz3/ps8pxV09hkQzUx70rwhIxx3vJDthg6oGpsZ26xA+gKTrFNOyjIp XgteEWBDn37zS9bwyEgiLTiGiVYBbdQgaIFy3/cHx1V9k6lUUdP2B/q+us2tonOo iMpOjXWmILZJLJRoTjCcN/DO78DgCgs83SYrs384GEdjEZqnwyMh7gZkkb88lOC4 ly/nv8TdLV9shvjR0Tlx =rwqy -----END PGP SIGNATURE----- --irrheVdOic6+Kbak--