From nobody Mon Feb 9 18:45:20 2026 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; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=samsung.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1521743000042100.27180060656224; Thu, 22 Mar 2018 11:23:20 -0700 (PDT) Received: from localhost ([::1]:34172 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ez4rv-0003Ib-57 for importer@patchew.org; Thu, 22 Mar 2018 14:23:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54026) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ez4mc-00079V-PY for qemu-devel@nongnu.org; Thu, 22 Mar 2018 14:17:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ez4ma-0000cF-NQ for qemu-devel@nongnu.org; Thu, 22 Mar 2018 14:17:50 -0400 Received: from mailout2.w1.samsung.com ([210.118.77.12]:44935) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ez4ma-0000bz-De for qemu-devel@nongnu.org; Thu, 22 Mar 2018 14:17:48 -0400 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20180322181746euoutp0214d24e093f9447cf5b8508d5382440ba~eUOShq7Kr2649426494euoutp02A; Thu, 22 Mar 2018 18:17:46 +0000 (GMT) Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20180322181745eucas1p297523b10b14bb76f0883c61dbd5de53b~eUORQOH012015620156eucas1p2E; Thu, 22 Mar 2018 18:17:45 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 37.0E.10409.943F3BA5; Thu, 22 Mar 2018 18:17:45 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20180322181744eucas1p1a738955967cd8a6cc0330980753b2bad~eUOP8OkVf2937029370eucas1p1s; Thu, 22 Mar 2018 18:17:44 +0000 (GMT) Received: from eusync4.samsung.com ( [203.254.199.214]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 27.AC.04183.843F3BA5; Thu, 22 Mar 2018 18:17:44 +0000 (GMT) Received: from aperevalov-ubuntu.rnd.samsung.ru ([106.109.129.199]) by eusync4.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0P60001OD857D350@eusync4.samsung.com>; Thu, 22 Mar 2018 18:17:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20180322181746euoutp0214d24e093f9447cf5b8508d5382440ba~eUOShq7Kr2649426494euoutp02A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1521742667; bh=ctE757L9LEWNeD+3ZLZvMU2J/yxAXH/VUqnaN6mrPEA=; h=From:To:Cc:Subject:Date:In-reply-to:References:From; b=cxLpQJ51GxM2p40RZ8PkUmp8SHVZiEUXQlXxe8C4ClZ14o2l/HiFjfJaQaMT+j1xf v7yQdDR//aclrtf/8ktC2lgIqZHE8uZvDXZl5xmOui+QCPxOGODOxCkpp5eHHJEWb3 i9yWDyA2YHcdSIhk20FrqxMfS7h9s36iQ5rzie4A= X-AuditID: cbfec7f5-b45ff700000028a9-57-5ab3f349f22c From: Alexey Perevalov To: qemu-devel@nongnu.org, dgilbert@redhat.com Date: Thu, 22 Mar 2018 21:17:27 +0300 Message-id: <1521742647-25550-7-git-send-email-a.perevalov@samsung.com> X-Mailer: git-send-email 2.7.4 In-reply-to: <1521742647-25550-1-git-send-email-a.perevalov@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrJIsWRmVeSWpSXmKPExsWy7djPc7qenzdHGWxoFbKYe/c8i8XKyUuY LHq33WO3OLHpILPFpwYpiy37v7FbHO/dwWJxZ0sfk8Xpm5vZHTg9DrxYyO7x5NpmJo/3+66y efRtWcUYwBLFZZOSmpNZllqkb5fAlXFi+U2Wgs1uFUfnrWVrYDxk3sXIySEhYCLRc76TvYuR i0NIYAWjxL2321ghnM+MEj/nnGaDqTre38kEkVjGKPHkyGQWCKebSeLdmj6gKg4ONgEDiX33 bEFMEQE9iQlXI0FKmAU2MkrsvPOeBSQuLBAisX2bBshMFgFViY0Pp7OD2LwC7hIHZvWxQOyS k7h5rpMZxOYU8JDYe2sTI8gcCYEJbBLPbv6FKnKR2D/9LjuELSzx6vgWKFtG4vLkbhaIhnZG ibsbr7JCdTNKrJt8jBmiyl7i1M2rTCA2swCfxKRt05lBrpMQ4JXoaBOCMD0kDh1NhKh2lJjb 2A/172xGib5T8xgnMEotYGRYxSieWlqcm55abJyXWq5XnJhbXJqXrpecn7uJERihp/8d/7qD cd+fpEOMAhyMSjy8H45sjhJiTSwrrsw9xCjBwawkwpu/FijEm5JYWZValB9fVJqTWnyIUZqD RUmcN06jLkpIID2xJDU7NbUgtQgmy8TBKdXAKBi+O7Y0SK5v26Wq89Exkg/alnOnmFzWWP/5 mLNI+u7IjSlv+KyvTndKWh8VktXs/lH23fS7Z+qnf8+KMVxX0Gm5V+DrdB6bluk5rw5PPnau z2RCNceEKwL1lo9e8W62aZ90/0ygjsKvR8IvHR7G6QQeqdnlZ1Hx5dA3MWOpmgVWKze+SNuc psRSnJFoqMVcVJwIAILL2hvMAgAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupkluLIzCtJLcpLzFFi42I5/e/4NV2Pz5ujDFaeZ7OYe/c8i8XKyUuY LHq33WO3OLHpILPFpwYpiy37v7FbHO/dwWJxZ0sfk8Xpm5vZHTg9DrxYyO7x5NpmJo/3+66y efRtWcUYwBLFZZOSmpNZllqkb5fAlXFi+U2Wgs1uFUfnrWVrYDxk3sXIySEhYCJxvL+TqYuR i0NIYAmjxNbOf6wgCSGBXiaJnpvBXYwcHGwCBhL77tmCmCICehITrkaClDMLbGSU+DXjLitI XFggRGL7Ng2QThYBVYmND6ezg9i8Au4SB2b1sUCskpO4ea6TGcTmFPCQ2HtrEyPEJneJXReu MU9g5FnAyLCKUSS1tDg3PbfYSK84Mbe4NC9dLzk/dxMjMIC2Hfu5ZQdj17vgQ4wCHIxKPLwz Dm2OEmJNLCuuzD3EKMHBrCTCm78WKMSbklhZlVqUH19UmpNafIhRmoNFSZz3vEFllJBAemJJ anZqakFqEUyWiYNTqoFRhUf0av7pvDoR5lrOJ2eTj2XVOS+cIyj86N7CJMeHGlv1NlbqTntR nLWzLP6mUtMuFpVvopzO8tklLN8kuBVUpDdv/fBKRvlVVloT02T9szfShHT7rq8022DAH2dS fV25+vV/Xdfn1Q+E5R1zl5aINm46dOj+5/y7CklLCjsr2aPvvpjiF6HEUpyRaKjFXFScCABO ysVMHAIAAA== X-CMS-MailID: 20180322181744eucas1p1a738955967cd8a6cc0330980753b2bad X-Msg-Generator: CA CMS-TYPE: 201P X-CMS-RootMailID: 20180322181744eucas1p1a738955967cd8a6cc0330980753b2bad X-RootMTR: 20180322181744eucas1p1a738955967cd8a6cc0330980753b2bad References: <1521742647-25550-1-git-send-email-a.perevalov@samsung.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 210.118.77.12 Subject: [Qemu-devel] [PATCH v2 6/6] migration: add postcopy total blocktime into query-migrate 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: lvivier@redhat.com, v.kuramshin@samsung.com, quintela@redhat.com, ash.billore@samsung.com, Alexey Perevalov , peterx@redhat.com, f4bug@amsat.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Postcopy total blocktime is available on destination side only. But query-migrate was possible only for source. This patch adds ability to call query-migrate on destination. To be able to see postcopy blocktime, need to request postcopy-blocktime capability. The query-migrate command will show following sample result: {"return": "postcopy-vcpu-blocktime": [115, 100], "status": "completed", "postcopy-blocktime": 100 }} postcopy_vcpu_blocktime contains list, where the first item is the first vCPU in QEMU. This patch has a drawback, it combines states of incoming and outgoing migration. Ongoing migration state will overwrite incoming state. Looks like better to separate query-migrate for incoming and outgoing migration or add parameter to indicate type of migration. Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Alexey Perevalov Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela --- hmp.c | 15 +++++++++++++ migration/migration.c | 42 ++++++++++++++++++++++++++++++++---- migration/migration.h | 4 ++++ migration/postcopy-ram.c | 56 ++++++++++++++++++++++++++++++++++++++++++++= ++++ migration/trace-events | 1 + qapi/migration.json | 11 +++++++++- 6 files changed, 124 insertions(+), 5 deletions(-) diff --git a/hmp.c b/hmp.c index 679467d..6c51df5 100644 --- a/hmp.c +++ b/hmp.c @@ -274,6 +274,21 @@ void hmp_info_migrate(Monitor *mon, const QDict *qdict) info->cpu_throttle_percentage); } =20 + if (info->has_postcopy_blocktime) { + monitor_printf(mon, "postcopy blocktime: %u\n", + info->postcopy_blocktime); + } + + if (info->has_postcopy_vcpu_blocktime) { + Visitor *v; + char *str; + v =3D string_output_visitor_new(false, &str); + visit_type_uint32List(v, NULL, &info->postcopy_vcpu_blocktime, NUL= L); + visit_complete(v, &str); + monitor_printf(mon, "postcopy vcpu blocktime: %s\n", str); + g_free(str); + visit_free(v); + } qapi_free_MigrationInfo(info); qapi_free_MigrationCapabilityStatusList(caps); } diff --git a/migration/migration.c b/migration/migration.c index f95a7f3..71b0f19 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -630,14 +630,15 @@ static void populate_disk_info(MigrationInfo *info) } } =20 -MigrationInfo *qmp_query_migrate(Error **errp) +static void fill_source_migration_info(MigrationInfo *info) { - MigrationInfo *info =3D g_malloc0(sizeof(*info)); MigrationState *s =3D migrate_get_current(); =20 switch (s->state) { case MIGRATION_STATUS_NONE: /* no migration has happened ever */ + /* do not overwrite destination migration status */ + return; break; case MIGRATION_STATUS_SETUP: info->has_status =3D true; @@ -688,8 +689,6 @@ MigrationInfo *qmp_query_migrate(Error **errp) break; } info->status =3D s->state; - - return info; } =20 /** @@ -753,6 +752,41 @@ static bool migrate_caps_check(bool *cap_list, return true; } =20 +static void fill_destination_migration_info(MigrationInfo *info) +{ + MigrationIncomingState *mis =3D migration_incoming_get_current(); + + switch (mis->state) { + case MIGRATION_STATUS_NONE: + return; + break; + case MIGRATION_STATUS_SETUP: + case MIGRATION_STATUS_CANCELLING: + case MIGRATION_STATUS_CANCELLED: + case MIGRATION_STATUS_ACTIVE: + case MIGRATION_STATUS_POSTCOPY_ACTIVE: + case MIGRATION_STATUS_FAILED: + case MIGRATION_STATUS_COLO: + info->has_status =3D true; + break; + case MIGRATION_STATUS_COMPLETED: + info->has_status =3D true; + fill_destination_postcopy_migration_info(info); + break; + } + info->status =3D mis->state; +} + +MigrationInfo *qmp_query_migrate(Error **errp) +{ + MigrationInfo *info =3D g_malloc0(sizeof(*info)); + + fill_destination_migration_info(info); + fill_source_migration_info(info); + + return info; +} + void qmp_migrate_set_capabilities(MigrationCapabilityStatusList *params, Error **errp) { diff --git a/migration/migration.h b/migration/migration.h index 6d9aaeb..7c69598 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -77,6 +77,10 @@ struct MigrationIncomingState { =20 MigrationIncomingState *migration_incoming_get_current(void); void migration_incoming_state_destroy(void); +/* + * Functions to work with blocktime context + */ +void fill_destination_postcopy_migration_info(MigrationInfo *info); =20 #define TYPE_MIGRATION "migration" =20 diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c index 6b01884..bbc1a95 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -139,6 +139,55 @@ static struct PostcopyBlocktimeContext *blocktime_cont= ext_new(void) return ctx; } =20 +static uint32List *get_vcpu_blocktime_list(PostcopyBlocktimeContext *ctx) +{ + uint32List *list =3D NULL, *entry =3D NULL; + int i; + + for (i =3D smp_cpus - 1; i >=3D 0; i--) { + entry =3D g_new0(uint32List, 1); + entry->value =3D ctx->vcpu_blocktime[i]; + entry->next =3D list; + list =3D entry; + } + + return list; +} + +/* + * This function just populates MigrationInfo from postcopy's + * blocktime context. It will not populate MigrationInfo, + * unless postcopy-blocktime capability was set. + * + * @info: pointer to MigrationInfo to populate + */ +void fill_destination_postcopy_migration_info(MigrationInfo *info) +{ + MigrationIncomingState *mis =3D migration_incoming_get_current(); + PostcopyBlocktimeContext *bc =3D mis->blocktime_ctx; + + if (!bc) { + return; + } + + info->has_postcopy_blocktime =3D true; + info->postcopy_blocktime =3D bc->total_blocktime; + info->has_postcopy_vcpu_blocktime =3D true; + info->postcopy_vcpu_blocktime =3D get_vcpu_blocktime_list(bc); +} + +static uint32_t get_postcopy_total_blocktime(void) +{ + MigrationIncomingState *mis =3D migration_incoming_get_current(); + PostcopyBlocktimeContext *bc =3D mis->blocktime_ctx; + + if (!bc) { + return 0; + } + + return bc->total_blocktime; +} + /** * receive_ufd_features: check userfault fd features, to request only supp= orted * features in the future. @@ -512,6 +561,9 @@ int postcopy_ram_incoming_cleanup(MigrationIncomingStat= e *mis) munmap(mis->postcopy_tmp_zero_page, mis->largest_page_size); mis->postcopy_tmp_zero_page =3D NULL; } + trace_postcopy_ram_incoming_cleanup_blocktime( + get_postcopy_total_blocktime()); + trace_postcopy_ram_incoming_cleanup_exit(); return 0; } @@ -1156,6 +1208,10 @@ void *postcopy_get_tmp_page(MigrationIncomingState *= mis) =20 #else /* No target OS support, stubs just fail */ +void fill_destination_postcopy_migration_info(MigrationInfo *info) +{ +} + bool postcopy_ram_supported_by_host(MigrationIncomingState *mis) { error_report("%s: No OS support", __func__); diff --git a/migration/trace-events b/migration/trace-events index 368bc4b..d6be74b 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -200,6 +200,7 @@ postcopy_ram_incoming_cleanup_closeuf(void) "" postcopy_ram_incoming_cleanup_entry(void) "" postcopy_ram_incoming_cleanup_exit(void) "" postcopy_ram_incoming_cleanup_join(void) "" +postcopy_ram_incoming_cleanup_blocktime(uint64_t total) "total blocktime %= " PRIu64 postcopy_request_shared_page(const char *sharer, const char *rb, uint64_t = rb_offset) "for %s in %s offset 0x%"PRIx64 postcopy_request_shared_page_present(const char *sharer, const char *rb, u= int64_t rb_offset) "%s already %s offset 0x%"PRIx64 postcopy_wake_shared(uint64_t client_addr, const char *rb) "at 0x%"PRIx64"= in %s" diff --git a/qapi/migration.json b/qapi/migration.json index 24bfc19..f3974c6 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -156,6 +156,13 @@ # @status is 'failed'. Clients should not attempt to parse the # error strings. (Since 2.7) # +# @postcopy-blocktime: total time when all vCPU were blocked during postco= py +# live migration (Since 2.13) +# +# @postcopy-vcpu-blocktime: list of the postcopy blocktime per vCPU (Since= 2.13) +# + +# # Since: 0.14.0 ## { 'struct': 'MigrationInfo', @@ -167,7 +174,9 @@ '*downtime': 'int', '*setup-time': 'int', '*cpu-throttle-percentage': 'int', - '*error-desc': 'str'} } + '*error-desc': 'str', + '*postcopy-blocktime' : 'uint32', + '*postcopy-vcpu-blocktime': ['uint32']} } =20 ## # @query-migrate: --=20 2.7.4