From patchwork Mon Oct 30 13:16:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Perevalov X-Patchwork-Id: 10032641 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 B04D3603B4 for ; Mon, 30 Oct 2017 13:22:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9898B26E1A for ; Mon, 30 Oct 2017 13:22:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8D28E281C3; Mon, 30 Oct 2017 13:22: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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 CAB5D28662 for ; Mon, 30 Oct 2017 13:22:22 +0000 (UTC) Received: from localhost ([::1]:40699 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e9A1F-0005Ue-RV for patchwork-qemu-devel@patchwork.kernel.org; Mon, 30 Oct 2017 09:22:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52352) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e99w2-0002GN-Gd for qemu-devel@nongnu.org; Mon, 30 Oct 2017 09:17:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e99vy-00045l-4J for qemu-devel@nongnu.org; Mon, 30 Oct 2017 09:16:58 -0400 Received: from mailout1.w1.samsung.com ([210.118.77.11]:51569) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e99vx-00044u-QW for qemu-devel@nongnu.org; Mon, 30 Oct 2017 09:16:54 -0400 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20171030131652euoutp01bb3edbbbde850a3cf0f87f04443d7bdd~yW3vHR5U50384103841euoutp013; Mon, 30 Oct 2017 13:16:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20171030131652euoutp01bb3edbbbde850a3cf0f87f04443d7bdd~yW3vHR5U50384103841euoutp013 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1509369412; bh=hfNVJr27DLq+kBCL5RLliBliIL6sEL1dqvkZsXI1e9k=; h=From:To:Cc:Subject:Date:In-reply-to:References:From; b=mRYy3cMtJXWX14TNXAHrIMWwY/0+uqPaECkWCWBo/kMcXjvlt5ppVuT+TSEZT7mgm fmXkuuZJ4LywEaD1oib/POh6UVDycIG7VDtDK1K7UAFikzibhpRTVwqien9mKI4nzJ DqqzxBnhbDqHows37qRh/hKuEXF5QUdUUMHkm0U4= Received: from eusmges4.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20171030131651eucas1p262b2b1c033977f59a376e61e2ce56b14~yW3uXbSuz3245832458eucas1p2W; Mon, 30 Oct 2017 13:16:51 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges4.samsung.com (EUCPMTA) with SMTP id DB.6B.12944.34627F95; Mon, 30 Oct 2017 13:16:51 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20171030131650eucas1p183c745b845ded5e02e842582bb44fd7b~yW3tucdOw0074600746eucas1p1I; Mon, 30 Oct 2017 13:16:50 +0000 (GMT) X-AuditID: cbfec7f4-f79ab6d000003290-19-59f72643b330 Received: from eusync3.samsung.com ( [203.254.199.213]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 62.33.20118.24627F95; Mon, 30 Oct 2017 13:16:50 +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 <0OYN00A7O0VNBHD0@eusync3.samsung.com>; Mon, 30 Oct 2017 13:16:50 +0000 (GMT) From: Alexey Perevalov To: qemu-devel@nongnu.org Date: Mon, 30 Oct 2017 16:16:30 +0300 Message-id: <1509369390-8285-7-git-send-email-a.perevalov@samsung.com> X-Mailer: git-send-email 2.7.4 In-reply-to: <1509369390-8285-1-git-send-email-a.perevalov@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrKIsWRmVeSWpSXmKPExsWy7djPc7rOat8jDb485rOYe/c8i0Xvtnvs FtM+32a3uNL+k91iy/5v7BbHe3ewWNzZ0sfkwO7x5NpmJo/3+66yefRtWcUYwBzFZZOSmpNZ llqkb5fAlfHpwVWmgsMuFZv/vWVrYHxn2sXIySEhYCIx884JZghbTOLCvfVsXYxcHEICSxkl Tty+zwThfGaUeLrxNitMx/VJF1ggEssYJU4eXwTV0s0k0Tf/EFAVBwebgIHEvnu2IA0iApIS v7tOM4PUMAssZJSYsv85G0iNsECoxP2zbCA1LAKqEu39j1lAbF4BN4kbG1qhlslJ3DzXCXYe p4C7xK0DH8AukhDoYJM4fegxE0SRi8T/ifPZIWxhiVfHt0DZMhKXJ3ezQDS0M0p07+xkhXAm MEqcmf4Xqspe4tTNq2CTmAX4JCZtm84Mcp2EAK9ER5sQRImHxP5jE6EucpR4d2AX2EVCArMY JbbtV5rAKL2AkWEVo0hqaXFuemqxiV5xYm5xaV66XnJ+7iZGYGSe/nf8yw7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c745b845ded5e02e842582bb44fd7b X-Msg-Generator: CA CMS-TYPE: 201P X-CMS-RootMailID: 20171030131650eucas1p183c745b845ded5e02e842582bb44fd7b X-RootMTR: 20171030131650eucas1p183c745b845ded5e02e842582bb44fd7b References: <1509369390-8285-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.11 Subject: [Qemu-devel] [PATCH v12 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: heetae82.ahn@samsung.com, quintela@redhat.com, dgilbert@redhat.com, peterx@redhat.com, Alexey Perevalov , i.maximets@samsung.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 +++++++++++++ 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 41fcce6..4f42eb8 100644 --- a/hmp.c +++ b/hmp.c @@ -264,6 +264,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/migration/migration.c b/migration/migration.c index c5244ae..cd09ba4 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -589,14 +589,15 @@ static void populate_disk_info(MigrationInfo *info) } } -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; @@ -647,8 +648,6 @@ MigrationInfo *qmp_query_migrate(Error **errp) break; } info->status = s->state; - - return info; } /** @@ -712,6 +711,41 @@ static bool migrate_caps_check(bool *cap_list, return true; } +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/migration.h b/migration/migration.h index fb8d2ef..99f294f 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -71,6 +71,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); #define TYPE_MIGRATION "migration" diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c index 6bf24e9..2823133 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -108,6 +108,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. @@ -482,6 +531,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; } @@ -959,6 +1011,10 @@ void *postcopy_get_tmp_page(MigrationIncomingState *mis) #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 462d157..141e773 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 c20caf4..be4a869 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 postcopy +# live migration (Since 2.11) +# +# @postcopy-vcpu-blocktime: list of the postcopy blocktime per vCPU (Since 2.11) +# + +# # 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' : 'int64', + '*postcopy-vcpu-blocktime': ['int64']} } ## # @query-migrate: