From nobody Wed Nov 5 09:52:34 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1499704794122992.3011860076701; Mon, 10 Jul 2017 09:39:54 -0700 (PDT) Received: from localhost ([::1]:41962 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dUbiw-0007ov-22 for importer@patchew.org; Mon, 10 Jul 2017 12:39:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47131) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dUba6-0000fa-5G for qemu-devel@nongnu.org; Mon, 10 Jul 2017 12:30:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dUba2-0001OB-UP for qemu-devel@nongnu.org; Mon, 10 Jul 2017 12:30:41 -0400 Received: from mailhub.sw.ru ([195.214.232.25]:42484 helo=relay.sw.ru) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dUba2-0001M4-CJ; Mon, 10 Jul 2017 12:30:38 -0400 Received: from kvm.sw.ru (msk-vpn.virtuozzo.com [195.214.232.6]) by relay.sw.ru (8.13.4/8.13.4) with ESMTP id v6AGUTIg031112; Mon, 10 Jul 2017 19:30:32 +0300 (MSK) From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org, qemu-devel@nongnu.org Date: Mon, 10 Jul 2017 19:30:17 +0300 Message-Id: <20170710163029.129912-5-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.11.1 In-Reply-To: <20170710163029.129912-1-vsementsov@virtuozzo.com> References: <20170710163029.129912-1-vsementsov@virtuozzo.com> X-detected-operating-system: by eggs.gnu.org: OpenBSD 3.x [fuzzy] X-Received-From: 195.214.232.25 Subject: [Qemu-devel] [PATCH v7 04/16] migration: introduce postcopy-only pending X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, vsementsov@virtuozzo.com, famz@redhat.com, lirans@il.ibm.com, quintela@redhat.com, jsnow@redhat.com, armbru@redhat.com, mreitz@redhat.com, stefanha@redhat.com, den@openvz.org, amit.shah@redhat.com, pbonzini@redhat.com, dgilbert@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" There would be savevm states (dirty-bitmap) which can migrate only in postcopy stage. The corresponding pending is introduced here. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Juan Quintela --- include/migration/register.h | 17 +++++++++++++++-- migration/block.c | 7 ++++--- migration/migration.c | 15 ++++++++------- migration/ram.c | 9 +++++---- migration/savevm.c | 13 ++++++++----- migration/savevm.h | 5 +++-- migration/trace-events | 2 +- 7 files changed, 44 insertions(+), 24 deletions(-) diff --git a/include/migration/register.h b/include/migration/register.h index b999917c9d..ebf68992dd 100644 --- a/include/migration/register.h +++ b/include/migration/register.h @@ -37,8 +37,21 @@ typedef struct SaveVMHandlers { int (*save_live_setup)(QEMUFile *f, void *opaque); void (*save_live_pending)(QEMUFile *f, void *opaque, uint64_t threshold_size, - uint64_t *non_postcopiable_pending, - uint64_t *postcopiable_pending); + uint64_t *res_precopy_only, + uint64_t *res_compatible, + uint64_t *res_postcopy_only); + /* Note for save_live_pending: + * - res_precopy_only is for data which must be migrated in precopy ph= ase + * or in stopped state, in other words - before target vm start + * - res_compatible is for data which may be migrated in any phase + * - res_postcopy_only is for data which must be migrated in postcopy = phase + * or in stopped state, in other words - after source vm stop + * + * Sum of res_postcopy_only, res_compatible and res_postcopy_only is t= he + * whole amount of pending data. + */ + + LoadStateHandler *load_state; } SaveVMHandlers; =20 diff --git a/migration/block.c b/migration/block.c index 2844149d34..0897c90fd2 100644 --- a/migration/block.c +++ b/migration/block.c @@ -857,8 +857,9 @@ static int block_save_complete(QEMUFile *f, void *opaqu= e) } =20 static void block_save_pending(QEMUFile *f, void *opaque, uint64_t max_siz= e, - uint64_t *non_postcopiable_pending, - uint64_t *postcopiable_pending) + uint64_t *res_precopy_only, + uint64_t *res_compatible, + uint64_t *res_postcopy_only) { /* Estimate pending number of bytes to send */ uint64_t pending; @@ -879,7 +880,7 @@ static void block_save_pending(QEMUFile *f, void *opaqu= e, uint64_t max_size, =20 DPRINTF("Enter save live pending %" PRIu64 "\n", pending); /* We don't do postcopy */ - *non_postcopiable_pending +=3D pending; + *res_precopy_only +=3D pending; } =20 static int block_load(QEMUFile *f, void *opaque, int version_id) diff --git a/migration/migration.c b/migration/migration.c index d3a2fd405a..b13a9f496a 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1867,20 +1867,21 @@ static void *migration_thread(void *opaque) uint64_t pending_size; =20 if (!qemu_file_rate_limit(s->to_dst_file)) { - uint64_t pend_post, pend_nonpost; + uint64_t pend_pre, pend_compat, pend_post; =20 - qemu_savevm_state_pending(s->to_dst_file, threshold_size, - &pend_nonpost, &pend_post); - pending_size =3D pend_nonpost + pend_post; + qemu_savevm_state_pending(s->to_dst_file, threshold_size, &pen= d_pre, + &pend_compat, &pend_post); + pending_size =3D pend_pre + pend_compat + pend_post; trace_migrate_pending(pending_size, threshold_size, - pend_post, pend_nonpost); + pend_pre, pend_compat, pend_post); if (pending_size && pending_size >=3D threshold_size) { /* Still a significant amount to transfer */ =20 if (migrate_postcopy() && s->state !=3D MIGRATION_STATUS_POSTCOPY_ACTIVE && - pend_nonpost <=3D threshold_size && - atomic_read(&s->start_postcopy)) { + pend_pre <=3D threshold_size && + (atomic_read(&s->start_postcopy) || + (pend_pre + pend_compat <=3D threshold_size))) { =20 if (!postcopy_start(s, &old_vm_running)) { current_active_state =3D MIGRATION_STATUS_POSTCOPY= _ACTIVE; diff --git a/migration/ram.c b/migration/ram.c index b43589e3d2..0f564d1ff3 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -2049,8 +2049,9 @@ static int ram_save_complete(QEMUFile *f, void *opaqu= e) } =20 static void ram_save_pending(QEMUFile *f, void *opaque, uint64_t max_size, - uint64_t *non_postcopiable_pending, - uint64_t *postcopiable_pending) + uint64_t *res_precopy_only, + uint64_t *res_compatible, + uint64_t *res_postcopy_only) { RAMState **temp =3D opaque; RAMState *rs =3D *temp; @@ -2070,9 +2071,9 @@ static void ram_save_pending(QEMUFile *f, void *opaqu= e, uint64_t max_size, =20 if (migrate_postcopy_ram()) { /* We can do postcopy, and all the data is postcopiable */ - *postcopiable_pending +=3D remaining_size; + *res_compatible +=3D remaining_size; } else { - *non_postcopiable_pending +=3D remaining_size; + *res_precopy_only +=3D remaining_size; } } =20 diff --git a/migration/savevm.c b/migration/savevm.c index cf79e1d3ac..0ab036489a 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1210,13 +1210,15 @@ int qemu_savevm_state_complete_precopy(QEMUFile *f,= bool iterable_only, * for units that can't do postcopy. */ void qemu_savevm_state_pending(QEMUFile *f, uint64_t threshold_size, - uint64_t *res_non_postcopiable, - uint64_t *res_postcopiable) + uint64_t *res_precopy_only, + uint64_t *res_compatible, + uint64_t *res_postcopy_only) { SaveStateEntry *se; =20 - *res_non_postcopiable =3D 0; - *res_postcopiable =3D 0; + *res_precopy_only =3D 0; + *res_compatible =3D 0; + *res_postcopy_only =3D 0; =20 =20 QTAILQ_FOREACH(se, &savevm_state.handlers, entry) { @@ -1229,7 +1231,8 @@ void qemu_savevm_state_pending(QEMUFile *f, uint64_t = threshold_size, } } se->ops->save_live_pending(f, se->opaque, threshold_size, - res_non_postcopiable, res_postcopiable); + res_precopy_only, res_compatible, + res_postcopy_only); } } =20 diff --git a/migration/savevm.h b/migration/savevm.h index 5a2ed1161d..775f7eec0f 100644 --- a/migration/savevm.h +++ b/migration/savevm.h @@ -38,8 +38,9 @@ void qemu_savevm_state_complete_postcopy(QEMUFile *f); int qemu_savevm_state_complete_precopy(QEMUFile *f, bool iterable_only, bool inactivate_disks); void qemu_savevm_state_pending(QEMUFile *f, uint64_t max_size, - uint64_t *res_non_postcopiable, - uint64_t *res_postcopiable); + uint64_t *res_precopy_only, + uint64_t *res_compatible, + uint64_t *res_postcopy_only); void qemu_savevm_send_ping(QEMUFile *f, uint32_t value); void qemu_savevm_send_open_return_path(QEMUFile *f); int qemu_savevm_send_packaged(QEMUFile *f, const uint8_t *buf, size_t len); diff --git a/migration/trace-events b/migration/trace-events index 38345be9c3..34cc2adafc 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -83,7 +83,7 @@ migrate_fd_cleanup(void) "" migrate_fd_error(const char *error_desc) "error=3D%s" migrate_fd_cancel(void) "" migrate_handle_rp_req_pages(const char *rbname, size_t start, size_t len) = "in %s at %zx len %zx" -migrate_pending(uint64_t size, uint64_t max, uint64_t post, uint64_t nonpo= st) "pending size %" PRIu64 " max %" PRIu64 " (post=3D%" PRIu64 " nonpost= =3D%" PRIu64 ")" +migrate_pending(uint64_t size, uint64_t max, uint64_t pre, uint64_t compat= , uint64_t post) "pending size %" PRIu64 " max %" PRIu64 " (pre =3D %" PRIu= 64 " compat=3D%" PRIu64 " post=3D%" PRIu64 ")" migrate_send_rp_message(int msg_type, uint16_t len) "%d: len %d" migration_completion_file_err(void) "" migration_completion_postcopy_end(void) "" --=20 2.11.1