{"id":815722,"url":"http://patchwork.ozlabs.org/api/patches/815722/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/patch/1505839684-10046-11-git-send-email-a.perevalov@samsung.com/","project":{"id":14,"url":"http://patchwork.ozlabs.org/api/projects/14/?format=json","name":"QEMU Development","link_name":"qemu-devel","list_id":"qemu-devel.nongnu.org","list_email":"qemu-devel@nongnu.org","web_url":"","scm_url":"","webscm_url":"","list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<1505839684-10046-11-git-send-email-a.perevalov@samsung.com>","list_archive_url":null,"date":"2017-09-19T16:48:04","name":"[v10,10/10] migration: add postcopy total blocktime into query-migrate","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"415a968099a68fbb8d22874cc3a22a9a7d1c1fc1","submitter":{"id":18164,"url":"http://patchwork.ozlabs.org/api/people/18164/?format=json","name":"Alexey Perevalov","email":"a.perevalov@samsung.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/qemu-devel/patch/1505839684-10046-11-git-send-email-a.perevalov@samsung.com/mbox/","series":[{"id":3930,"url":"http://patchwork.ozlabs.org/api/series/3930/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/list/?series=3930","date":"2017-09-19T16:48:03","name":"calculate blocktime for postcopy live migration","version":10,"mbox":"http://patchwork.ozlabs.org/series/3930/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/815722/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/815722/checks/","tags":{},"related":[],"headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":"ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)","Received":["from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xxVHb2m9Zz9sMN\n\tfor <incoming@patchwork.ozlabs.org>;\n\tWed, 20 Sep 2017 03:29:47 +1000 (AEST)","from localhost ([::1]:44282 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1duMLB-0003Tg-Cd\n\tfor incoming@patchwork.ozlabs.org; Tue, 19 Sep 2017 13:29:45 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:42532)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <a.perevalov@samsung.com>) id 1duLhI-0001E1-JN\n\tfor qemu-devel@nongnu.org; Tue, 19 Sep 2017 12:48:34 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <a.perevalov@samsung.com>) id 1duLhG-0006UM-TJ\n\tfor qemu-devel@nongnu.org; Tue, 19 Sep 2017 12:48:32 -0400","from mailout1.w1.samsung.com ([210.118.77.11]:33246)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <a.perevalov@samsung.com>)\n\tid 1duLhG-0006TL-Kb\n\tfor qemu-devel@nongnu.org; Tue, 19 Sep 2017 12:48:30 -0400","from eucas1p1.samsung.com (unknown [182.198.249.206])\n\tby mailout1.w1.samsung.com (KnoxPortal) with ESMTP id\n\t20170919164829euoutp015e73ca10499428113e88733a5d2fe597~l0Ty4bOVz2610726107euoutp01n;\n\tTue, 19 Sep 2017 16:48:29 +0000 (GMT)","from eusmges2.samsung.com (unknown [203.254.199.241]) by\n\teucas1p1.samsung.com (KnoxPortal) with ESMTP id\n\t20170919164828eucas1p1e8c50103e8a669aa5f5c9a5559f20ad4~l0Tx6AYtX3070230702eucas1p1C;\n\tTue, 19 Sep 2017 16:48:28 +0000 (GMT)","from eucas1p2.samsung.com ( [182.198.249.207]) by\n\teusmges2.samsung.com (EUCPMTA) with SMTP id 6B.6F.12907.B5A41C95;\n\tTue, 19 Sep 2017 17:48:27 +0100 (BST)","from eusmgms2.samsung.com (unknown [182.198.249.180]) by\n\teucas1p2.samsung.com (KnoxPortal) with ESMTP id\n\t20170919164827eucas1p231a5b9afd8e81427db114e57a0b6fbbe~l0TxJHFrl2073720737eucas1p2r;\n\tTue, 19 Sep 2017 16:48:27 +0000 (GMT)","from eusync1.samsung.com ( [203.254.199.211]) by\n\teusmgms2.samsung.com (EUCPMTA) with SMTP id 16.6C.20118.B5A41C95;\n\tTue, 19 Sep 2017 17:48:27 +0100 (BST)","from aperevalov-ubuntu.rnd.samsung.ru ([106.109.129.199]) by\n\teusync1.samsung.com (Oracle Communications Messaging Server\n\t7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id\n\t<0OWJ003OHDC8XU40@eusync1.samsung.com>; \n\tTue, 19 Sep 2017 17:48:27 +0100 (BST)"],"X-AuditID":"cbfec7f1-f793a6d00000326b-42-59c14a5b3332","From":"Alexey Perevalov <a.perevalov@samsung.com>","To":"qemu-devel@nongnu.org","Date":"Tue, 19 Sep 2017 19:48:04 +0300","Message-id":"<1505839684-10046-11-git-send-email-a.perevalov@samsung.com>","X-Mailer":"git-send-email 1.9.1","In-reply-to":"<1505839684-10046-1-git-send-email-a.perevalov@samsung.com>","X-Brightmail-Tracker":["H4sIAAAAAAAAA+NgFtrNIsWRmVeSWpSXmKPExsWy7djP87rRXgcjDVZNNraYe/c8i0Xvtnvs\n\tFhPfrme1mPb5NrvFlfaf7BZb9n9jtzjeu4PF4s6WPiYHDo8n1zYzebzfd5XNo2/LKsYA5igu\n\tm5TUnMyy1CJ9uwSujM2LrrEXfHWpWHbwIGMD4zSzLkZODgkBE4kHy2ayQNhiEhfurWfrY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xiFEktLc5Nzy020itOzC0uzUvXS87P3cQIDKZtx35u2cHY9S74EKMAB6MSD+8Km4OR\n\tQqyJZcWVuYcYJTiYlUR4XzsBhXhTEiurUovy44tKc1KLDzFKc7AoifP27lkdKSSQnliSmp2a\n\tWpBaBJNl4uCUamDMee5ZIqaYL9lhtTP35wxT74+NL76sebsx+Ef6ypd2rwr0irZ1HZXP8xF8\n\t4KRUVDp3m+eVd8l+S3a0eIo373ATvZlyVMEg21Tt2gcXPfdJ9oliudKOcz7Nu/ZI3apCLX7J\n\ta4bHV7VfNsf7n53VkndW/KHRlbnpHEErXt9nCPd4UrpTdOppI2klluKMREMt5qLiRAA83rJt\n\tIgIAAA=="],"X-CMS-MailID":"20170919164827eucas1p231a5b9afd8e81427db114e57a0b6fbbe","X-Msg-Generator":"CA","X-Sender-IP":"182.198.249.180","X-Local-Sender":"=?utf-8?q?Alexey_Perevalov=1BSRR-Virtualization_Lab=1B?=\n\t=?utf-8?b?7IK87ISx7KCE7J6QG1NlbmlvciBFbmdpbmVlcg==?=","X-Global-Sender":"=?utf-8?q?Alexey_Perevalov=1BSRR-Virtualization_Lab=1BSa?=\n\t=?utf-8?q?msung_Electronics=1BSenior_Engineer?=","X-Sender-Code":"=?utf-8?q?C10=1BCISHQ=1BC10GD01GD010154?=","CMS-TYPE":"201P","X-CMS-RootMailID":"20170919164827eucas1p231a5b9afd8e81427db114e57a0b6fbbe","X-RootMTR":"20170919164827eucas1p231a5b9afd8e81427db114e57a0b6fbbe","References":"<1505839684-10046-1-git-send-email-a.perevalov@samsung.com>\n\t<CGME20170919164827eucas1p231a5b9afd8e81427db114e57a0b6fbbe@eucas1p2.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 v10 10/10] migration: add postcopy total\n\tblocktime into query-migrate","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Id":"<qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<http://lists.nongnu.org/archive/html/qemu-devel/>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Cc":"heetae82.ahn@samsung.com, quintela@redhat.com,\n\tAlexey Perevalov <a.perevalov@samsung.com>, peterx@redhat.com,\n\tdgilbert@redhat.com, i.maximets@samsung.com","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"},"content":"Postcopy total blocktime is available on destination side only.\nBut query-migrate was possible only for source. This patch\nadds ability to call query-migrate on destination.\nTo be able to see postcopy blocktime, need to request postcopy-blocktime\ncapability.\n\nThe query-migrate command will show following sample result:\n{\"return\":\n    \"postcopy-vcpu-blocktime\": [115, 100],\n    \"status\": \"completed\",\n    \"postcopy-blocktime\": 100\n}}\n\npostcopy_vcpu_blocktime contains list, where the first item is the first\nvCPU in QEMU.\n\nThis patch has a drawback, it combines states of incoming and\noutgoing migration. Ongoing migration state will overwrite incoming\nstate. Looks like better to separate query-migrate for incoming and\noutgoing migration or add parameter to indicate type of migration.\n\nReviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>\nSigned-off-by: Alexey Perevalov <a.perevalov@samsung.com>\n---\n hmp.c                    | 15 +++++++++++++\n migration/migration.c    | 42 +++++++++++++++++++++++++++++++----\n migration/migration.h    |  4 ++++\n migration/postcopy-ram.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++\n migration/trace-events   |  1 +\n qapi/migration.json      | 11 +++++++++-\n 6 files changed, 125 insertions(+), 5 deletions(-)","diff":"diff --git a/hmp.c b/hmp.c\nindex 0fb2bc7..142f76e 100644\n--- a/hmp.c\n+++ b/hmp.c\n@@ -264,6 +264,21 @@ void hmp_info_migrate(Monitor *mon, const QDict *qdict)\n                        info->cpu_throttle_percentage);\n     }\n \n+    if (info->has_postcopy_blocktime) {\n+        monitor_printf(mon, \"postcopy blocktime: %\" PRId64 \"\\n\",\n+                       info->postcopy_blocktime);\n+    }\n+\n+    if (info->has_postcopy_vcpu_blocktime) {\n+        Visitor *v;\n+        char *str;\n+        v = string_output_visitor_new(false, &str);\n+        visit_type_int64List(v, NULL, &info->postcopy_vcpu_blocktime, NULL);\n+        visit_complete(v, &str);\n+        monitor_printf(mon, \"postcopy vcpu blocktime: %s\\n\", str);\n+        g_free(str);\n+        visit_free(v);\n+    }\n     qapi_free_MigrationInfo(info);\n     qapi_free_MigrationCapabilityStatusList(caps);\n }\ndiff --git a/migration/migration.c b/migration/migration.c\nindex 4f029e8..e1d3248 100644\n--- a/migration/migration.c\n+++ b/migration/migration.c\n@@ -528,14 +528,15 @@ static void populate_disk_info(MigrationInfo *info)\n     }\n }\n \n-MigrationInfo *qmp_query_migrate(Error **errp)\n+static void fill_source_migration_info(MigrationInfo *info)\n {\n-    MigrationInfo *info = g_malloc0(sizeof(*info));\n     MigrationState *s = migrate_get_current();\n \n     switch (s->state) {\n     case MIGRATION_STATUS_NONE:\n         /* no migration has happened ever */\n+        /* do not overwrite destination migration status */\n+        return;\n         break;\n     case MIGRATION_STATUS_SETUP:\n         info->has_status = true;\n@@ -584,8 +585,6 @@ MigrationInfo *qmp_query_migrate(Error **errp)\n         break;\n     }\n     info->status = s->state;\n-\n-    return info;\n }\n \n /**\n@@ -649,6 +648,41 @@ static bool migrate_caps_check(bool *cap_list,\n     return true;\n }\n \n+static void fill_destination_migration_info(MigrationInfo *info)\n+{\n+    MigrationIncomingState *mis = migration_incoming_get_current();\n+\n+    switch (mis->state) {\n+    case MIGRATION_STATUS_NONE:\n+        return;\n+        break;\n+    case MIGRATION_STATUS_SETUP:\n+    case MIGRATION_STATUS_CANCELLING:\n+    case MIGRATION_STATUS_CANCELLED:\n+    case MIGRATION_STATUS_ACTIVE:\n+    case MIGRATION_STATUS_POSTCOPY_ACTIVE:\n+    case MIGRATION_STATUS_FAILED:\n+    case MIGRATION_STATUS_COLO:\n+        info->has_status = true;\n+        break;\n+    case MIGRATION_STATUS_COMPLETED:\n+        info->has_status = true;\n+        fill_destination_postcopy_migration_info(info);\n+        break;\n+    }\n+    info->status = mis->state;\n+}\n+\n+MigrationInfo *qmp_query_migrate(Error **errp)\n+{\n+    MigrationInfo *info = g_malloc0(sizeof(*info));\n+\n+    fill_destination_migration_info(info);\n+    fill_source_migration_info(info);\n+\n+    return info;\n+}\n+\n void qmp_migrate_set_capabilities(MigrationCapabilityStatusList *params,\n                                   Error **errp)\n {\ndiff --git a/migration/migration.h b/migration/migration.h\nindex 770466b..882a59b 100644\n--- a/migration/migration.h\n+++ b/migration/migration.h\n@@ -70,6 +70,10 @@ struct MigrationIncomingState {\n \n MigrationIncomingState *migration_incoming_get_current(void);\n void migration_incoming_state_destroy(void);\n+/*\n+ * Functions to work with blocktime context\n+ */\n+void fill_destination_postcopy_migration_info(MigrationInfo *info);\n \n #define TYPE_MIGRATION \"migration\"\n \ndiff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c\nindex 9a5133f..5fdbf1e 100644\n--- a/migration/postcopy-ram.c\n+++ b/migration/postcopy-ram.c\n@@ -113,6 +113,55 @@ static struct PostcopyBlocktimeContext *blocktime_context_new(void)\n     return ctx;\n }\n \n+static int64List *get_vcpu_blocktime_list(PostcopyBlocktimeContext *ctx)\n+{\n+    int64List *list = NULL, *entry = NULL;\n+    int i;\n+\n+    for (i = smp_cpus - 1; i >= 0; i--) {\n+        entry = g_new0(int64List, 1);\n+        entry->value = ctx->vcpu_blocktime[i];\n+        entry->next = list;\n+        list = entry;\n+    }\n+\n+    return list;\n+}\n+\n+/*\n+ * This function just populates MigrationInfo from postcopy's\n+ * blocktime context. It will not populate MigrationInfo,\n+ * unless postcopy-blocktime capability was set.\n+ *\n+ * @info: pointer to MigrationInfo to populate\n+ */\n+void fill_destination_postcopy_migration_info(MigrationInfo *info)\n+{\n+    MigrationIncomingState *mis = migration_incoming_get_current();\n+    PostcopyBlocktimeContext *bc = mis->blocktime_ctx;\n+\n+    if (!bc) {\n+        return;\n+    }\n+\n+    info->has_postcopy_blocktime = true;\n+    info->postcopy_blocktime = bc->total_blocktime;\n+    info->has_postcopy_vcpu_blocktime = true;\n+    info->postcopy_vcpu_blocktime = get_vcpu_blocktime_list(bc);\n+}\n+\n+static uint64_t get_postcopy_total_blocktime(void)\n+{\n+    MigrationIncomingState *mis = migration_incoming_get_current();\n+    PostcopyBlocktimeContext *bc = mis->blocktime_ctx;\n+\n+    if (!bc) {\n+        return 0;\n+    }\n+\n+    return bc->total_blocktime;\n+}\n+\n /**\n  * receive_ufd_features: check userfault fd features, to request only supported\n  * features in the future.\n@@ -487,6 +536,9 @@ int postcopy_ram_incoming_cleanup(MigrationIncomingState *mis)\n         munmap(mis->postcopy_tmp_zero_page, mis->largest_page_size);\n         mis->postcopy_tmp_zero_page = NULL;\n     }\n+    trace_postcopy_ram_incoming_cleanup_blocktime(\n+            get_postcopy_total_blocktime());\n+\n     trace_postcopy_ram_incoming_cleanup_exit();\n     return 0;\n }\n@@ -958,6 +1010,11 @@ void *postcopy_get_tmp_page(MigrationIncomingState *mis)\n \n #else\n /* No target OS support, stubs just fail */\n+void fill_destination_postcopy_migration_info(MigrationInfo *info)\n+{\n+    error_report(\"%s: No OS support\", __func__);\n+}\n+\n bool postcopy_ram_supported_by_host(MigrationIncomingState *mis)\n {\n     error_report(\"%s: No OS support\", __func__);\ndiff --git a/migration/trace-events b/migration/trace-events\nindex 01f30fe..741f2ae 100644\n--- a/migration/trace-events\n+++ b/migration/trace-events\n@@ -197,6 +197,7 @@ postcopy_ram_incoming_cleanup_closeuf(void) \"\"\n postcopy_ram_incoming_cleanup_entry(void) \"\"\n postcopy_ram_incoming_cleanup_exit(void) \"\"\n postcopy_ram_incoming_cleanup_join(void) \"\"\n+postcopy_ram_incoming_cleanup_blocktime(uint64_t total) \"total blocktime %\" PRIu64\n save_xbzrle_page_skipping(void) \"\"\n save_xbzrle_page_overflow(void) \"\"\n ram_save_iterate_big_wait(uint64_t milliconds, int iterations) \"big wait: %\" PRIu64 \" milliseconds, %d iterations\"\ndiff --git a/qapi/migration.json b/qapi/migration.json\nindex 2e4a15d..55b055e 100644\n--- a/qapi/migration.json\n+++ b/qapi/migration.json\n@@ -150,6 +150,13 @@\n #              @status is 'failed'. Clients should not attempt to parse the\n #              error strings. (Since 2.7)\n #\n+# @postcopy-blocktime: total time when all vCPU were blocked during postcopy\n+#           live migration (Since 2.11)\n+#\n+# @postcopy-vcpu-blocktime: list of the postcopy blocktime per vCPU (Since 2.10)\n+#\n+\n+#\n # Since: 0.14.0\n ##\n { 'struct': 'MigrationInfo',\n@@ -161,7 +168,9 @@\n            '*downtime': 'int',\n            '*setup-time': 'int',\n            '*cpu-throttle-percentage': 'int',\n-           '*error-desc': 'str'} }\n+           '*error-desc': 'str',\n+           '*postcopy-blocktime' : 'int64',\n+           '*postcopy-vcpu-blocktime': ['int64']} }\n \n ##\n # @query-migrate:\n","prefixes":["v10","10/10"]}