From patchwork Wed Jun 7 09:46:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Perevalov X-Patchwork-Id: 9771159 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 869906034B for ; Wed, 7 Jun 2017 09:54:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 61D0D28459 for ; Wed, 7 Jun 2017 09:54:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 54BFA2849E; Wed, 7 Jun 2017 09:54:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 002A228459 for ; Wed, 7 Jun 2017 09:54:21 +0000 (UTC) Received: from localhost ([::1]:42337 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dIXfR-0007QO-4l for patchwork-qemu-devel@patchwork.kernel.org; Wed, 07 Jun 2017 05:54:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58104) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dIXYx-0001Bv-0O for qemu-devel@nongnu.org; Wed, 07 Jun 2017 05:47:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dIXYs-0000Gd-Ia for qemu-devel@nongnu.org; Wed, 07 Jun 2017 05:47:39 -0400 Received: from mailout2.w1.samsung.com ([210.118.77.12]:15628) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dIXYs-0000GQ-9x for qemu-devel@nongnu.org; Wed, 07 Jun 2017 05:47:34 -0400 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0OR6007J58J8AG30@mailout2.w1.samsung.com> for qemu-devel@nongnu.org; Wed, 07 Jun 2017 10:47:32 +0100 (BST) Received: from eusmges1.samsung.com (unknown [203.254.199.239]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20170607094732eucas1p266cd95b6af5a3671e594b59d9edb9693~FzekXalML0466904669eucas1p2V; Wed, 7 Jun 2017 09:47:32 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1.samsung.com (EUCPMTA) with SMTP id 7F.CE.14140.6BBC7395; Wed, 7 Jun 2017 10:47:34 +0100 (BST) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20170607094731eucas1p2cbbf439e841b1d72edb374d35d53bea3~FzejwE-5y0466904669eucas1p2U; Wed, 7 Jun 2017 09:47:31 +0000 (GMT) X-AuditID: cbfec7ef-f796a6d00000373c-35-5937cbb64ce6 Received: from eusync1.samsung.com ( [203.254.199.211]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id E0.CB.17452.3BBC7395; Wed, 7 Jun 2017 10:47:31 +0100 (BST) Received: from aperevalov-ubuntu.rnd.samsung.ru ([106.109.129.199]) by eusync1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OR600I3B8ILMHB0@eusync1.samsung.com>; Wed, 07 Jun 2017 10:47:31 +0100 (BST) From: Alexey Perevalov To: qemu-devel@nongnu.org Date: Wed, 07 Jun 2017 12:46:37 +0300 Message-id: <1496828798-27548-11-git-send-email-a.perevalov@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1496828798-27548-1-git-send-email-a.perevalov@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrGIsWRmVeSWpSXmKPExsWy7djPc7rbTptHGnS+VbSYe/c8i0Xvtnvs Flfaf7JbbNn/jd3ieO8OFgdWjyfXNjN5vN93lc2jb8sqxgDmKC6blNSczLLUIn27BK6MNy1T GAs2uVS8/3edpYHxmmkXIyeHhICJxIo/z9ggbDGJC/fWA9lcHEICyxgl/nybywLhfGaUWLj0 IjNMx6kNXUxwVZuWXmaEcLqZJCZfWgmU4eBgEzCQ2HfPFqRBREBS4nfXabBmZoECiY+tK1lA bGGBMIknfzaC2SwCqhL3lvwBq+EV8JDoff6aBWKZnMTJY5NZQWxOoPiPqbeZQXZJCFxnk3hz dTPYLgkBWYlNB6COc5HYM+UxlC0s8er4FnYIW0ais+MgE0RvO6NE985OVghnAqPEmel/oars JU7dvMoEcSmfxKRt05khFvBKdLQJQZR4SBxeNIERwnaUeL33INgyIYHZjBK3l3tNYJRZwMiw ilEktbQ4Nz212FCvODG3uDQvXS85P3cTIzA2T/87/n4H49PmkEOMAhyMSjy8GXvMIoVYE8uK K3MPMUpwMCuJ8E48ah4pxJuSWFmVWpQfX1Sak1p8iFGag0VJnJf31LUIIYH0xJLU7NTUgtQi mCwTB6dUA6N+5t/Qb1vcWblemppHXmx4F2FcJyngdoLVZv1tOZV5Koxdl7Sffv6YapX9TPy8 4kWBzIyNoYERofrcrJzegQsFbXbsl5EM/8z8LCfsyvE7d7c9Wf/X1/bRmrf1ywV8GuxCdl8T 3jtdpKl1ZW/9qv4zu1WKnM7P6+G6YpuzRLvyhev+K2/PHVRiKc5INNRiLipOBAAsxu1jyQIA AA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrCLMWRmVeSWpSXmKPExsVy+t/xy7qbT5tHGlxtlrOYe/c8i0Xvtnvs Flfaf7JbbNn/jd3ieO8OFgdWjyfXNjN5vN93lc2jb8sqxgDmKDebjNTElNQihdS85PyUzLx0 W6XQEDddCyWFvMTcVFulCF3fkCAlhbLEnFIgz8gADTg4B7gHK+nbJbhlvGmZwliwyaXi/b/r LA2M10y7GDk5JARMJE5t6GKCsMUkLtxbz9bFyMUhJLCEUeLvzanMIAkhgV4miWdzE7sYOTjY BAwk9t2zBQmLCEhK/O46DVbCLFAgcW7yFBYQW1ggTOLJn41gNouAqsS9JX/AangFPCR6n79m gdglJ3Hy2GRWEJsTKP5j6m2oVe4St++cYZrAyLuAkWEVo0hqaXFuem6xoV5xYm5xaV66XnJ+ 7iZGYIhuO/Zz8w7GSxuDDzEKcDAq8fAK7DKLFGJNLCuuzD3EKMHBrCTCO/GoeaQQb0piZVVq UX58UWlOavEhRlOgoyYyS4km5wPjJ68k3tDE0NzS0MjYwsLcyEhJnLfkw5VwIYH0xJLU7NTU gtQimD4mDk6pBsb2iQ5S35aLPPGJrZTZuur4rQU3bjgZ8t02yj/DMG3++3Dh5cJGNr5pT8XF 4wtvZXZu2csZ1MJ9fer3WfNfnJ0UobaumP31yYgVVbN2FXN2JM/aefvkpKzDy47o+ktZ+G9W n/D8W3nx18P6kVL2xg+2+f6JZ29VOVNnd3vzle+JuY7JWlvVjpUpsRRnJBpqMRcVJwIAWGDZ jWcCAAA= X-MTR: 20000000000000000@CPGS X-CMS-MailID: 20170607094731eucas1p2cbbf439e841b1d72edb374d35d53bea3 X-Msg-Generator: CA X-Sender-IP: 182.198.249.179 X-Local-Sender: =?UTF-8?B?QWxleGV5IFBlcmV2YWxvdhtTUlItVmlydHVhbGl6YXRpb24g?= =?UTF-8?B?TGFiG+yCvOyEseyghOyekBtTZW5pb3IgRW5naW5lZXI=?= X-Global-Sender: =?UTF-8?B?QWxleGV5IFBlcmV2YWxvdhtTUlItVmlydHVhbGl6YXRpb24g?= =?UTF-8?B?TGFiG1NhbXN1bmcgRWxlY3Ryb25pY3MbU2VuaW9yIEVuZ2luZWVy?= X-Sender-Code: =?UTF-8?B?QzEwG0NJU0hRG0MxMEdEMDFHRDAxMDE1NA==?= CMS-TYPE: 201P X-HopCount: 7 X-CMS-RootMailID: 20170607094731eucas1p2cbbf439e841b1d72edb374d35d53bea3 X-RootMTR: 20170607094731eucas1p2cbbf439e841b1d72edb374d35d53bea3 References: <1496828798-27548-1-git-send-email-a.perevalov@samsung.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 210.118.77.12 Subject: [Qemu-devel] [PATCH v8 10/11] 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: i.maximets@samsung.com, Alexey Perevalov , peterx@redhat.com, dgilbert@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 --- hmp.c | 15 ++++++++++++ include/migration/migration.h | 4 +++ migration/migration.c | 40 +++++++++++++++++++++++++++--- migration/postcopy-ram.c | 57 +++++++++++++++++++++++++++++++++++++++++++ migration/trace-events | 1 + qapi-schema.json | 9 ++++++- 6 files changed, 122 insertions(+), 4 deletions(-) diff --git a/hmp.c b/hmp.c index 8c72c58..e0c4fdf 100644 --- a/hmp.c +++ b/hmp.c @@ -262,6 +262,21 @@ void hmp_info_migrate(Monitor *mon, const QDict *qdict) info->cpu_throttle_percentage); } + if (info->has_postcopy_blocktime) { + monitor_printf(mon, "postcopy blocktime: %" PRId64 "\n", + info->postcopy_blocktime); + } + + if (info->has_postcopy_vcpu_blocktime) { + Visitor *v; + char *str; + v = string_output_visitor_new(false, &str); + visit_type_int64List(v, NULL, &info->postcopy_vcpu_blocktime, NULL); + 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/include/migration/migration.h b/include/migration/migration.h index 766e802..7d20470 100644 --- a/include/migration/migration.h +++ b/include/migration/migration.h @@ -98,6 +98,10 @@ struct MigrationIncomingState { 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); struct MigrationState { diff --git a/migration/migration.c b/migration/migration.c index d1cc34f..b80d5b5 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -625,14 +625,15 @@ static void populate_ram_info(MigrationInfo *info, MigrationState *s) } } -MigrationInfo *qmp_query_migrate(Error **errp) +static void fill_source_migration_info(MigrationInfo *info) { - MigrationInfo *info = g_malloc0(sizeof(*info)); MigrationState *s = migrate_get_current(); 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 = true; @@ -718,10 +719,43 @@ MigrationInfo *qmp_query_migrate(Error **errp) break; } info->status = s->state; +} - return info; +static void fill_destination_migration_info(MigrationInfo *info) +{ + MigrationIncomingState *mis = 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 = true; + break; + case MIGRATION_STATUS_COMPLETED: + info->has_status = true; + fill_destination_postcopy_migration_info(info); + break; + } + info->status = mis->state; } +MigrationInfo *qmp_query_migrate(Error **errp) +{ + MigrationInfo *info = 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/postcopy-ram.c b/migration/postcopy-ram.c index 0ad9f9f..7f5b402 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -117,6 +117,55 @@ static struct PostcopyBlocktimeContext *blocktime_context_new(void) return ctx; } +static int64List *get_vcpu_blocktime_list(PostcopyBlocktimeContext *ctx) +{ + int64List *list = NULL, *entry = NULL; + int i; + + for (i = smp_cpus - 1; i >= 0; i--) { + entry = g_new0(int64List, 1); + entry->value = ctx->vcpu_blocktime[i]; + entry->next = list; + list = 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 = migration_incoming_get_current(); + PostcopyBlocktimeContext *bc = mis->blocktime_ctx; + + if (!bc) { + return; + } + + info->has_postcopy_blocktime = true; + info->postcopy_blocktime = bc->total_blocktime; + info->has_postcopy_vcpu_blocktime = true; + info->postcopy_vcpu_blocktime = get_vcpu_blocktime_list(bc); +} + +static uint64_t get_postcopy_total_blocktime(void) +{ + MigrationIncomingState *mis = migration_incoming_get_current(); + PostcopyBlocktimeContext *bc = mis->blocktime_ctx; + + if (!bc) { + return 0; + } + + return bc->total_blocktime; +} + /** * receive_ufd_features: check userfault fd features, to request only supported * features in the future. @@ -491,6 +540,9 @@ int postcopy_ram_incoming_cleanup(MigrationIncomingState *mis) munmap(mis->postcopy_tmp_zero_page, mis->largest_page_size); mis->postcopy_tmp_zero_page = NULL; } + trace_postcopy_ram_incoming_cleanup_blocktime( + get_postcopy_total_blocktime()); + trace_postcopy_ram_incoming_cleanup_exit(); return 0; } @@ -950,6 +1002,11 @@ void *postcopy_get_tmp_page(MigrationIncomingState *mis) #else /* No target OS support, stubs just fail */ +void fill_destination_postcopy_migration_info(MigrationInfo *info) +{ + error_report("%s: No OS support", __func__); +} + 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 7bdadbb..55a3b6e 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -195,6 +195,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-schema.json b/qapi-schema.json index e906953..9229bbc 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -712,6 +712,11 @@ # @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 postcopy +# live migration (Since 2.10) +# +# @postcopy-vcpu-blocktime: list of the postcopy blocktime per vCPU (Since 2.10) +# # Since: 0.14.0 ## { 'struct': 'MigrationInfo', @@ -723,7 +728,9 @@ '*downtime': 'int', '*setup-time': 'int', '*cpu-throttle-percentage': 'int', - '*error-desc': 'str'} } + '*error-desc': 'str', + '*postcopy-blocktime' : 'int64', + '*postcopy-vcpu-blocktime': ['int64']} } ## # @query-migrate: