From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34763) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YWDxe-0004oc-06 for qemu-devel@nongnu.org; Thu, 12 Mar 2015 21:00:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YWDxa-0006iM-PF for qemu-devel@nongnu.org; Thu, 12 Mar 2015 21:00:21 -0400 Received: from ozlabs.org ([103.22.144.67]:42060) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YWDxa-0006gX-6j for qemu-devel@nongnu.org; Thu, 12 Mar 2015 21:00:18 -0400 Date: Fri, 13 Mar 2015 12:00:58 +1100 From: David Gibson Message-ID: <20150313010058.GZ11973@voom.redhat.com> References: <1424883128-9841-1-git-send-email-dgilbert@redhat.com> <1424883128-9841-21-git-send-email-dgilbert@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="RQRqO9v0HfCoqppm" Content-Disposition: inline In-Reply-To: <1424883128-9841-21-git-send-email-dgilbert@redhat.com> Subject: Re: [Qemu-devel] [PATCH v5 20/45] Modify savevm handlers for 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 --RQRqO9v0HfCoqppm Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Feb 25, 2015 at 04:51:43PM +0000, Dr. David Alan Gilbert (git) wrot= e: > From: "Dr. David Alan Gilbert" >=20 > Modify save_live_pending to return separate postcopiable and > non-postcopiable counts. >=20 > Add 'can_postcopy' to allow a device to state if it can postcopy What's the purpose of the can_postcopy callback? There are no callers in this patch - is it still necessary with the change to save_live_pending? >=20 > Signed-off-by: Dr. David Alan Gilbert > --- > arch_init.c | 15 +++++++++++++-- > include/migration/vmstate.h | 10 ++++++++-- > include/sysemu/sysemu.h | 4 +++- > migration/block.c | 7 +++++-- > migration/migration.c | 9 +++++++-- > savevm.c | 21 +++++++++++++++++---- > trace-events | 2 +- > 7 files changed, 54 insertions(+), 14 deletions(-) >=20 > diff --git a/arch_init.c b/arch_init.c > index fe0df0d..7bc5fa6 100644 > --- a/arch_init.c > +++ b/arch_init.c > @@ -997,7 +997,9 @@ static int ram_save_complete(QEMUFile *f, void *opaqu= e) > return 0; > } > =20 > -static uint64_t ram_save_pending(QEMUFile *f, void *opaque, uint64_t max= _size) > +static void ram_save_pending(QEMUFile *f, void *opaque, uint64_t max_siz= e, > + uint64_t *non_postcopiable_pending, > + uint64_t *postcopiable_pending) > { > uint64_t remaining_size; > =20 > @@ -1009,7 +1011,9 @@ static uint64_t ram_save_pending(QEMUFile *f, void = *opaque, uint64_t max_size) > qemu_mutex_unlock_iothread(); > remaining_size =3D ram_save_remaining() * TARGET_PAGE_SIZE; > } > - return remaining_size; > + > + *non_postcopiable_pending =3D 0; > + *postcopiable_pending =3D remaining_size; > } > =20 > static int load_xbzrle(QEMUFile *f, ram_addr_t addr, void *host) > @@ -1204,6 +1208,12 @@ static int ram_load(QEMUFile *f, void *opaque, int= version_id) > return ret; > } > =20 > +/* RAM's always up for postcopying */ > +static bool ram_can_postcopy(void *opaque) > +{ > + return true; > +} > + > static SaveVMHandlers savevm_ram_handlers =3D { > .save_live_setup =3D ram_save_setup, > .save_live_iterate =3D ram_save_iterate, > @@ -1211,6 +1221,7 @@ static SaveVMHandlers savevm_ram_handlers =3D { > .save_live_pending =3D ram_save_pending, > .load_state =3D ram_load, > .cancel =3D ram_migration_cancel, > + .can_postcopy =3D ram_can_postcopy, > }; > =20 > void ram_mig_init(void) > diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h > index 18da207..c9ec74a 100644 > --- a/include/migration/vmstate.h > +++ b/include/migration/vmstate.h > @@ -54,8 +54,14 @@ typedef struct SaveVMHandlers { > =20 > /* This runs outside the iothread lock! */ > int (*save_live_setup)(QEMUFile *f, void *opaque); > - uint64_t (*save_live_pending)(QEMUFile *f, void *opaque, uint64_t ma= x_size); > - > + /* > + * postcopiable_pending must return 0 unless the can_postcopy > + * handler returns true. > + */ > + void (*save_live_pending)(QEMUFile *f, void *opaque, uint64_t max_si= ze, > + uint64_t *non_postcopiable_pending, > + uint64_t *postcopiable_pending); > + bool (*can_postcopy)(void *opaque); > LoadStateHandler *load_state; > } SaveVMHandlers; > =20 > diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h > index e83bf80..5f518b3 100644 > --- a/include/sysemu/sysemu.h > +++ b/include/sysemu/sysemu.h > @@ -111,7 +111,9 @@ void qemu_savevm_state_header(QEMUFile *f); > int qemu_savevm_state_iterate(QEMUFile *f); > void qemu_savevm_state_complete(QEMUFile *f); > void qemu_savevm_state_cancel(void); > -uint64_t qemu_savevm_state_pending(QEMUFile *f, uint64_t max_size); > +void qemu_savevm_state_pending(QEMUFile *f, uint64_t max_size, > + uint64_t *res_non_postcopiable, > + uint64_t *res_postcopiable); > void qemu_savevm_command_send(QEMUFile *f, enum qemu_vm_cmd command, > uint16_t len, uint8_t *data); > void qemu_savevm_send_ping(QEMUFile *f, uint32_t value); > diff --git a/migration/block.c b/migration/block.c > index 0c76106..0f6f209 100644 > --- a/migration/block.c > +++ b/migration/block.c > @@ -754,7 +754,9 @@ static int block_save_complete(QEMUFile *f, void *opa= que) > return 0; > } > =20 > -static uint64_t block_save_pending(QEMUFile *f, void *opaque, uint64_t m= ax_size) > +static void block_save_pending(QEMUFile *f, void *opaque, uint64_t max_s= ize, > + uint64_t *non_postcopiable_pending, > + uint64_t *postcopiable_pending) > { > /* Estimate pending number of bytes to send */ > uint64_t pending; > @@ -773,7 +775,8 @@ static uint64_t block_save_pending(QEMUFile *f, void = *opaque, uint64_t max_size) > qemu_mutex_unlock_iothread(); > =20 > DPRINTF("Enter save live pending %" PRIu64 "\n", pending); > - return pending; > + *non_postcopiable_pending =3D pending; > + *postcopiable_pending =3D 0; > } > =20 > static int block_load(QEMUFile *f, void *opaque, int version_id) > diff --git a/migration/migration.c b/migration/migration.c > index 2e6adca..a4fc7d7 100644 > --- a/migration/migration.c > +++ b/migration/migration.c > @@ -868,8 +868,13 @@ static void *migration_thread(void *opaque) > uint64_t pending_size; > =20 > if (!qemu_file_rate_limit(s->file)) { > - pending_size =3D qemu_savevm_state_pending(s->file, max_size= ); > - trace_migrate_pending(pending_size, max_size); > + uint64_t pend_post, pend_nonpost; > + > + qemu_savevm_state_pending(s->file, max_size, &pend_nonpost, > + &pend_post); > + pending_size =3D pend_nonpost + pend_post; > + trace_migrate_pending(pending_size, max_size, > + pend_post, pend_nonpost); > if (pending_size && pending_size >=3D max_size) { > qemu_savevm_state_iterate(s->file); > } else { > diff --git a/savevm.c b/savevm.c > index df48ba8..e301a0a 100644 > --- a/savevm.c > +++ b/savevm.c > @@ -944,10 +944,20 @@ void qemu_savevm_state_complete(QEMUFile *f) > qemu_fflush(f); > } > =20 > -uint64_t qemu_savevm_state_pending(QEMUFile *f, uint64_t max_size) > +/* Give an estimate of the amount left to be transferred, > + * the result is split into the amount for units that can and > + * for units that can't do postcopy. > + */ > +void qemu_savevm_state_pending(QEMUFile *f, uint64_t max_size, > + uint64_t *res_non_postcopiable, > + uint64_t *res_postcopiable) > { > SaveStateEntry *se; > - uint64_t ret =3D 0; > + uint64_t tmp_non_postcopiable, tmp_postcopiable; > + > + *res_non_postcopiable =3D 0; > + *res_postcopiable =3D 0; > + > =20 > QTAILQ_FOREACH(se, &savevm_handlers, entry) { > if (!se->ops || !se->ops->save_live_pending) { > @@ -958,9 +968,12 @@ uint64_t qemu_savevm_state_pending(QEMUFile *f, uint= 64_t max_size) > continue; > } > } > - ret +=3D se->ops->save_live_pending(f, se->opaque, max_size); > + se->ops->save_live_pending(f, se->opaque, max_size, > + &tmp_non_postcopiable, &tmp_postcopia= ble); > + > + *res_postcopiable +=3D tmp_postcopiable; > + *res_non_postcopiable +=3D tmp_non_postcopiable; > } > - return ret; > } > =20 > void qemu_savevm_state_cancel(void) > diff --git a/trace-events b/trace-events > index cbf995c..83312b6 100644 > --- a/trace-events > +++ b/trace-events > @@ -1400,7 +1400,7 @@ migrate_fd_cleanup(void) "" > migrate_fd_cleanup_src_rp(void) "" > migrate_fd_error(void) "" > migrate_fd_cancel(void) "" > -migrate_pending(uint64_t size, uint64_t max) "pending size %" PRIu64 " m= ax %" PRIu64 > +migrate_pending(uint64_t size, uint64_t max, uint64_t post, uint64_t non= post) "pending size %" PRIu64 " max %" PRIu64 " (post=3D%" PRIu64 " nonpost= =3D%" PRIu64 ")" > migrate_send_rp_message(int cmd, uint16_t len) "cmd=3D%d, len=3D%d" > open_outgoing_return_path(void) "" > open_outgoing_return_path_continue(void) "" --=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 --RQRqO9v0HfCoqppm Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJVAjbKAAoJEGw4ysog2bOSjQUP/13OkxxDwBnvFEjsRirGk/Pm TPTcwqOk1koZKHrykpEmz5Wp9MXdLshqOS0Qr0pdCCNhA1dDDKRTyt9K1bmdtMSj PPcvk9K3IADPAJpH0hOstwcn+BP3OshCaTCFrZg1hOTDjtz5HvSJYbzUll2yUDVf dClrO5UBJkVNOTS0RbbsJRyPJDVww7Mn3CjP+B2yzMVDbZNS80kQm5sOWfnZX2Ax k2q/kGfECsOsG9sVr2Hu+pPuCIafHKMwT2g5xs3cYHBWfwXTFuSrvrsXxvRiwGJN WJcrw67nrjfLWsSDjF2U1txMkLZQFevWTFfyI8Op6ikfiuWcmh3TskkZRS3pMbRG HKcso7XyaBSq0I5PNSGUoVFC18cd9iVgxIkvrg41T1TreRt+BgJVRRjhdtbg426R 0Ea9/R3LE3OENbf/GkZcFHDFCM3Z4atROTLvt3psO033EjjEG150tsz9FIs0xXQl cQmj6mz8nZ2PvjPxXYrv3kmmzWaw74afgJmC8z2r8W+gTko/t1MQIZhKatAZH9L9 qXVTJpWsw94IlFJMw4G55QAOZ/7Yt984xuiDqTWozGGc0JI9fDjuSNJZGMzgbNlJ eq2SJM3ySa4EMHAGTY8YI+T9o76b+HnYWSSB/YnHgXMEZ2SsO/XyHsLreEi3F991 HvZWHEScyQDycX8g/im3 =ii1n -----END PGP SIGNATURE----- --RQRqO9v0HfCoqppm--