From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55458) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xnifh-0006Ts-6X for qemu-devel@nongnu.org; Mon, 10 Nov 2014 01:41:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xnifc-0004P5-98 for qemu-devel@nongnu.org; Mon, 10 Nov 2014 01:41:53 -0500 Received: from ozlabs.org ([2401:3900:2:1::2]:59567) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xnifb-0004Ny-N9 for qemu-devel@nongnu.org; Mon, 10 Nov 2014 01:41:48 -0500 Date: Mon, 10 Nov 2014 17:19:24 +1100 From: David Gibson Message-ID: <20141110061924.GC31324@voom.redhat.com> References: <1412358473-31398-1-git-send-email-dgilbert@redhat.com> <1412358473-31398-36-git-send-email-dgilbert@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="NKoe5XOeduwbEQHU" Content-Disposition: inline In-Reply-To: <1412358473-31398-36-git-send-email-dgilbert@redhat.com> Subject: Re: [Qemu-devel] [PATCH v4 35/47] Page request: Add MIG_RPCOMM_REQPAGES reverse command 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, lilei@linux.vnet.ibm.com, quintela@redhat.com, cristian.klein@cs.umu.se, qemu-devel@nongnu.org, amit.shah@redhat.com, yanghy@cn.fujitsu.com --NKoe5XOeduwbEQHU Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Oct 03, 2014 at 06:47:41PM +0100, Dr. David Alan Gilbert (git) wrot= e: > From: "Dr. David Alan Gilbert" >=20 > Add MIG_RPCOMM_REQPAGES command on Return path for the postcopy > destination to request a page from the source. >=20 > Signed-off-by: Dr. David Alan Gilbert > --- > include/migration/migration.h | 3 ++ > migration.c | 74 +++++++++++++++++++++++++++++++++++++= ++++++ > 2 files changed, 77 insertions(+) >=20 > diff --git a/include/migration/migration.h b/include/migration/migration.h > index cdd0e56..5e0d30d 100644 > --- a/include/migration/migration.h > +++ b/include/migration/migration.h > @@ -45,6 +45,7 @@ enum mig_rpcomm_cmd { > MIG_RPCOMM_INVALID =3D 0, /* Must be 0 */ > MIG_RPCOMM_SHUT, /* sibling will not send any more RP messag= es */ > MIG_RPCOMM_ACK, /* data (seq: be32 ) */ > + MIG_RPCOMM_REQPAGES, /* data (start: be64, len: be64) */ > MIG_RPCOMM_AFTERLASTVALID > }; > =20 > @@ -250,6 +251,8 @@ void migrate_send_rp_shut(MigrationIncomingState *mis, > uint32_t value); > void migrate_send_rp_ack(MigrationIncomingState *mis, > uint32_t value); > +void migrate_send_rp_reqpages(MigrationIncomingState *mis, const char* r= bname, > + ram_addr_t start, ram_addr_t len); > =20 > =20 > void ram_control_before_iterate(QEMUFile *f, uint64_t flags); > diff --git a/migration.c b/migration.c > index 1731017..cfdaa52 100644 > --- a/migration.c > +++ b/migration.c > @@ -144,6 +144,38 @@ void migrate_send_rp_ack(MigrationIncomingState *mis, > migrate_send_rp_message(mis, MIG_RPCOMM_ACK, 4, (uint8_t *)&buf); > } > =20 > +/* Request a range of pages from the source VM at the given > + * start address. > + * rbname: Name of the RAMBlock to request the page in, if NULL it's t= he same > + * as the last request (a name must have been given previously) > + * Start: Address offset within the RB > + * Len: Length in bytes required - must be a multiple of pagesize > + */ > +void migrate_send_rp_reqpages(MigrationIncomingState *mis, const char *r= bname, > + ram_addr_t start, ram_addr_t len) > +{ > + uint8_t bufc[16+1+255]; /* start (8 byte), len (8 byte), rbname upto= 256 */ > + uint64_t *buf64 =3D (uint64_t *)bufc; > + size_t msglen =3D 16; /* start + len */ > + > + assert(!(len & 1)); > + if (rbname) { > + int rbname_len =3D strlen(rbname); > + assert(rbname_len < 256); > + > + len |=3D 1; /* Flag to say we've got a name */ > + bufc[msglen++] =3D rbname_len; > + memcpy(bufc + msglen, rbname, rbname_len); > + msglen +=3D rbname_len; > + } > + > + buf64[0] =3D (uint64_t)start; > + buf64[0] =3D cpu_to_be64(buf64[0]); I think this would be clearer as well as less verbose, as just: buf64[0] =3D cpu_to_be64(start); > + buf64[1] =3D (uint64_t)len; > + buf64[1] =3D cpu_to_be64(buf64[1]); > + migrate_send_rp_message(mis, MIG_RPCOMM_REQPAGES, msglen, bufc); > +} > + > void qemu_start_incoming_migration(const char *uri, Error **errp) > { > const char *p; > @@ -784,6 +816,17 @@ static void source_return_path_bad(MigrationState *s) > } > =20 > /* > + * Process a request for pages received on the return path, > + * We're allowed to send more than requested (e.g. to round to our page = size) > + * and we don't need to send pages that have already been sent. > + */ > +static void migrate_handle_rp_reqpages(MigrationState *ms, const char* r= bname, > + ram_addr_t start, ram_addr_t len) > +{ > + DPRINTF("migrate_handle_rp_reqpages: at %zx for len %zx", start, len= ); > +} > + > +/* > * Handles messages sent on the return path towards the source VM > * > */ > @@ -795,6 +838,8 @@ static void *source_return_path_thread(void *opaque) > const int max_len =3D 512; > uint8_t buf[max_len]; > uint32_t tmp32; > + uint64_t tmp64a, tmp64b; Hrm.. calling everything "tmp*" doesn't help readability. > + char *tmpstr; > int res; > =20 > DPRINTF("RP: %s entry", __func__); > @@ -810,6 +855,11 @@ static void *source_return_path_thread(void *opaque) > expected_len =3D 4; > break; > =20 > + case MIG_RPCOMM_REQPAGES: > + /* 16 byte start/len _possibly_ plus an id str */ > + expected_len =3D 16 + 256; > + break; > + > default: > error_report("RP: Received invalid cmd 0x%04x length 0x%04x", > header_com, header_len); > @@ -857,6 +907,30 @@ static void *source_return_path_thread(void *opaque) > atomic_xchg(&ms->rp_state.latest_ack, tmp32); > break; > =20 > + case MIG_RPCOMM_REQPAGES: > + tmp64a =3D be64_to_cpup((uint64_t *)buf); /* Start */ > + tmp64b =3D be64_to_cpup(((uint64_t *)buf)+1); /* Len */ > + tmpstr =3D NULL; > + if (tmp64b & 1) { > + tmp64b -=3D 1; /* Remove the flag */ > + /* Now we expect an idstr */ > + tmp32 =3D buf[16]; /* Length of the following idstr */ > + tmpstr =3D (char *)&buf[17]; > + buf[17+tmp32] =3D '\0'; > + expected_len =3D 16+1+tmp32; > + } else { > + expected_len =3D 16; > + } > + if (header_len !=3D expected_len) { > + error_report("RP: Received ReqPage with length %d expect= ing %d", > + header_len, expected_len); > + source_return_path_bad(ms); > + } > + migrate_handle_rp_reqpages(ms, tmpstr, > + (ram_addr_t)tmp64a, > + (ram_addr_t)tmp64b); > + break; > + > default: > /* This shouldn't happen because we should catch this above = */ > DPRINTF("RP: Bad header_com in dispatch"); --=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 --NKoe5XOeduwbEQHU Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJUYFjsAAoJEGw4ysog2bOS27kQAMdTU+nZ+3gnjvCivyadACWM 4N0e9zb4IFrsKTK2KIQBEF1VJ8pR3IXm1WGJHBiAQmVMmY4lEKPJct7734229GsV mMQH8UN4VZ/eju2QeVJRZ3qzgxeZXGe1BIe8puE+qBBKY4KviZPUQ0V5i7q5D3mJ 8t4xoWmMqThUJ6Rs35Gdh1l6ZJAaP1RWaojq4Uo1/o/u3iyduROtH/4vxmjaB/8j pR1gAQK/kI2AuVjMWDKYm2zNCbzFrzCthe4v4t1VID56dp7DA27+N9NEjTqMH3eq kEZIx6Xgxrz33PO2kaLGzO04dRofycqFBv7HoWPYnrkbblawcom2TtbPsBw9ymSn Px9Ic/WJKHpAHs6Ij6zX6IaN1g+J5IuVi3DQas9kL4qQLnpR85vrqv5hSV1RUJPt 3QmhLf+59xqLYI1yR/GXvjksqWom21yHpR+osaKsPIVJvR26Ut0E/VAQ5+Fq5R0+ XDRyu9LFP+32s3F5DmK+B07l3UfDwP3jfoPYtN1D44rGG5jUbS6N3X+0vDZPGDyR VMIn2XFzikqU25zdmrASbn1DnCCyv6tRjB4uprnKU0OSvvP202/rGoXdmk9y21Ke +jKkkERchwkLuT0SXPrSpjWN28vWXe3FqqEcV7u6zwHrldlkCJq5j2rgF8RAfvcr jVNLlVqWrryDvIpiZIfU =XtzR -----END PGP SIGNATURE----- --NKoe5XOeduwbEQHU--