From nobody Tue Feb 10 04:55:27 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 1520953492164527.3544236483932; Tue, 13 Mar 2018 08:04:52 -0700 (PDT) Received: from localhost ([::1]:40389 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1evlTv-0004jG-1j for importer@patchew.org; Tue, 13 Mar 2018 11:04:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59160) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1evlJW-0003OR-Oz for qemu-devel@nongnu.org; Tue, 13 Mar 2018 10:54:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1evlJV-0001Nq-BS for qemu-devel@nongnu.org; Tue, 13 Mar 2018 10:54:06 -0400 Received: from mailout2.w1.samsung.com ([210.118.77.12]:57463) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1evlJV-0001N5-1m for qemu-devel@nongnu.org; Tue, 13 Mar 2018 10:54:05 -0400 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20180313145403euoutp02bc5204be3e13519e9e7fc96028a3c97d~bgo2BrXFZ0472804728euoutp020; Tue, 13 Mar 2018 14:54:03 +0000 (GMT) Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20180313145402eucas1p211bf9bdd56d018390f7bcfd9d772b968~bgo1UqM582039920399eucas1p2M; Tue, 13 Mar 2018 14:54:02 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 21.2E.17380.A06E7AA5; Tue, 13 Mar 2018 14:54:02 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20180313145401eucas1p2b7cbb73e2515551b9a0287df1335eeb9~bgo0h3Qyq1458414584eucas1p2G; Tue, 13 Mar 2018 14:54:01 +0000 (GMT) Received: from eusync3.samsung.com ( [203.254.199.213]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id F3.18.04178.906E7AA5; Tue, 13 Mar 2018 14:54:01 +0000 (GMT) Received: from aperevalov-ubuntu.rnd.samsung.ru ([106.109.129.199]) by eusync3.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0P5J00AR2APOJ400@eusync3.samsung.com>; Tue, 13 Mar 2018 14:54:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20180313145403euoutp02bc5204be3e13519e9e7fc96028a3c97d~bgo2BrXFZ0472804728euoutp020 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1520952843; bh=APeQ/n7bu2hailg9v4ujaqHxryytGYv0HHuG1HPG5E8=; h=From:To:Cc:Subject:Date:In-reply-to:References:From; b=afemt92v+PCWpYp+JeMJiT4Z+gBYl3JMXiPGEajeGNvl4qs2CKMm8BhwVLQSW28b4 SKW1j/nAU1n1RMwqk5/dz6oCqY6VG8HNAv6wR/Jd4auapipshap0CjqIapkOy0b6k+ SluhnCNQ67KKHiSVDi6gvLKyTfpYB1k80xFqjRww= X-AuditID: cbfec7f4-6f9ff700000043e4-32-5aa7e60af0d4 From: Alexey Perevalov To: qemu-devel@nongnu.org, dgilbert@redhat.com Date: Tue, 13 Mar 2018 17:53:44 +0300 Message-id: <1520952824-3172-7-git-send-email-a.perevalov@samsung.com> X-Mailer: git-send-email 2.7.4 In-reply-to: <1520952824-3172-1-git-send-email-a.perevalov@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrBIsWRmVeSWpSXmKPExsWy7djPc7pcz5ZHGfxZI2kx9+55FouVk5cw WfRuu8ducWLTQWaLTw1SFlv2f2O3ON67g8XizpY+JovTNzezO3B6HHixkN3jybXNTB7v911l 8+jbsooxgCWKyyYlNSezLLVI3y6BK+PwojssBctcK44/usPUwHjSrIuRk0NCwETibe961i5G Lg4hgRWMEncOdzFDOJ8ZJa6dmcXYxcgBVrXonzBEfBmjxLOmbSwQTjeTxKNZDcwgRWwCBhL7 7tmCmCICehITrkaClDALbGSU2HnnPQvINmGBEIkZZ3awgtgsAqoSK389BYvzCrhJ9F15xQ5x kZzEzXOdYCM5BdwlVnSVgMyREOhhkzi/ZSMbRI2LxO9br1khbGGJV8e3QPXKSHR2HGSCaGhn lLi78SorhDOBUWLd5GPMEFX2EqduXmUCsZkF+CQmbZvODPElr0RHmxCE6SExuT0VotpRYtWM iVD/zmKUWPhxH+sERqkFjAyrGMVTS4tz01OLjfJSy/WKE3OLS/PS9ZLzczcxAuPz9L/jX3Yw 7vqTdIhRgINRiYd3xdnlUUKsiWXFlbmHGCU4mJVEeHMeAIV4UxIrq1KL8uOLSnNSiw8xSnOw KInzxmnURQkJpCeWpGanphakFsFkmTg4pRoYlff3akefvSaaLWc8yUxvre3kzFOvmUTOnb9/ 7SJXc8ov86cTGZ/1TFP1Zvq+66TVs6sM+vPfHJFt37/JyWWiXESlBK9xtEr/YdFPOgfeTSpT MnnmUxOdaprn7Pz8XBX3pTd2H+alOOz9lm7JFJz1fVaXKnN7k4/shup2jy21jx3//Laoj4tU YinOSDTUYi4qTgQAikEH58sCAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupgluLIzCtJLcpLzFFi42I5/e/4VV3OZ8ujDK53G1rMvXuexWLl5CVM Fr3b7rFbnNh0kNniU4OUxZb939gtjvfuYLG4s6WPyeL0zc3sDpweB14sZPd4cm0zk8f7fVfZ PPq2rGIMYInisklJzcksSy3St0vgyji86A5LwTLXiuOP7jA1MJ4062Lk4JAQMJFY9E+4i5GL Q0hgCaPE3ZmnWboYOYGcXiaJXZPsQWrYBAwk9t2zBTFFBPQkJlyNBClnFtjIKPFrxl1WkHJh gRCJGWd2gNksAqoSK389BRvDK+Am0XflFTuILSEgJ3HzXCczyBxOAXeJFV0lEJvcJHbO+ss+ gZFnASPDKkaR1NLi3PTcYkO94sTc4tK8dL3k/NxNjMDw2Xbs5+YdjJc2Bh9iFOBgVOLhXXF2 eZQQa2JZcWXuIUYJDmYlEd6cB0Ah3pTEyqrUovz4otKc1OJDjNIcLErivOcNKqOEBNITS1Kz U1MLUotgskwcnFINjCo2TAEHb/x9/cu6RTOhi8HzscbNmpPVoal5TyxXaEzdXnkiaT/vi9JU jplN3EzLddau3/LR/tusF8vSbsY0y72dsPihc+Tryy3Zb6WOFB6rKmu/zC+/5fv12pX2uqZr nsg8zDbk36XYn5lwW53r0dct7CdUbkvsF9mQvj5lW7msiJOiyYFV6kosxRmJhlrMRcWJAKnv y4IbAgAA X-CMS-MailID: 20180313145401eucas1p2b7cbb73e2515551b9a0287df1335eeb9 X-Msg-Generator: CA CMS-TYPE: 201P X-CMS-RootMailID: 20180313145401eucas1p2b7cbb73e2515551b9a0287df1335eeb9 X-RootMTR: 20180313145401eucas1p2b7cbb73e2515551b9a0287df1335eeb9 References: <1520952824-3172-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 v1 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 016cb5c..4539f77 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 0ee9c1f..ae8890e 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -619,14 +619,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; @@ -677,8 +678,6 @@ MigrationInfo *qmp_query_migrate(Error **errp) break; } info->status =3D s->state; - - return info; } =20 /** @@ -742,6 +741,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 3ead619..a09277e 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -73,6 +73,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 9e51e84..c46225c 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -110,6 +110,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. @@ -475,6 +524,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; } @@ -968,6 +1020,10 @@ void *postcopy_get_tmp_page(MigrationIncomingState *m= is) =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 22ced40..def03c4 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -198,6 +198,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 save_xbzrle_page_skipping(void) "" save_xbzrle_page_overflow(void) "" ram_save_iterate_big_wait(uint64_t milliconds, int iterations) "big wait: = %" PRIu64 " milliseconds, %d iterations" diff --git a/qapi/migration.json b/qapi/migration.json index 676ef06..c4737f8 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.12) +# +# @postcopy-vcpu-blocktime: list of the postcopy blocktime per vCPU (Since= 2.12) +# + +# # 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