[{"id":1771246,"web_url":"http://patchwork.ozlabs.org/comment/1771246/","msgid":"<455fc8e2-ca88-d32f-1aac-3d2f400dcaa4@redhat.com>","list_archive_url":null,"date":"2017-09-19T17:41:51","subject":"Re: [Qemu-devel] [PATCH v10 10/10] migration: add postcopy total\n\tblocktime into query-migrate","submitter":{"id":6591,"url":"http://patchwork.ozlabs.org/api/people/6591/","name":"Eric Blake","email":"eblake@redhat.com"},"content":"On 09/19/2017 11:48 AM, Alexey Perevalov wrote:\n> Postcopy total blocktime is available on destination side only.\n> But query-migrate was possible only for source. This patch\n> adds ability to call query-migrate on destination.\n> To be able to see postcopy blocktime, need to request postcopy-blocktime\n> capability.\n> \n\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\nYou got this one right,\n\n> +# @postcopy-vcpu-blocktime: list of the postcopy blocktime per vCPU (Since 2.10)\n\nbut left this one at 2.10.  Should be 2.11.","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>)","ext-mx07.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com","ext-mx07.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=eblake@redhat.com"],"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 3xxVls372Kz9sBZ\n\tfor <incoming@patchwork.ozlabs.org>;\n\tWed, 20 Sep 2017 03:50:49 +1000 (AEST)","from localhost ([::1]:44500 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 1duMfX-0005Dg-8M\n\tfor incoming@patchwork.ozlabs.org; Tue, 19 Sep 2017 13:50:47 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:52338)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <eblake@redhat.com>) id 1duMX4-0006a1-OQ\n\tfor qemu-devel@nongnu.org; Tue, 19 Sep 2017 13:42:03 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <eblake@redhat.com>) id 1duMX0-0006CV-6t\n\tfor qemu-devel@nongnu.org; Tue, 19 Sep 2017 13:42:02 -0400","from mx1.redhat.com ([209.132.183.28]:52524)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <eblake@redhat.com>) id 1duMWz-0006Bf-Tj\n\tfor qemu-devel@nongnu.org; Tue, 19 Sep 2017 13:41:58 -0400","from smtp.corp.redhat.com\n\t(int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby mx1.redhat.com (Postfix) with ESMTPS id 000D7C04B924;\n\tTue, 19 Sep 2017 17:41:56 +0000 (UTC)","from [10.10.124.97] (ovpn-124-97.rdu2.redhat.com [10.10.124.97])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id AC65060BE6;\n\tTue, 19 Sep 2017 17:41:52 +0000 (UTC)"],"DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com 000D7C04B924","To":"Alexey Perevalov <a.perevalov@samsung.com>, qemu-devel@nongnu.org","References":"<1505839684-10046-1-git-send-email-a.perevalov@samsung.com>\n\t<CGME20170919164827eucas1p231a5b9afd8e81427db114e57a0b6fbbe@eucas1p2.samsung.com>\n\t<1505839684-10046-11-git-send-email-a.perevalov@samsung.com>","From":"Eric Blake <eblake@redhat.com>","Openpgp":"url=http://people.redhat.com/eblake/eblake.gpg","Organization":"Red Hat, Inc.","Message-ID":"<455fc8e2-ca88-d32f-1aac-3d2f400dcaa4@redhat.com>","Date":"Tue, 19 Sep 2017 12:41:51 -0500","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101\n\tThunderbird/52.3.0","MIME-Version":"1.0","In-Reply-To":"<1505839684-10046-11-git-send-email-a.perevalov@samsung.com>","Content-Type":"multipart/signed; micalg=pgp-sha256;\n\tprotocol=\"application/pgp-signature\";\n\tboundary=\"1tspBr5UBAmLHCiFiUa13cScJbabXeqKc\"","X-Scanned-By":"MIMEDefang 2.79 on 10.5.11.12","X-Greylist":"Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.31]);\n\tTue, 19 Sep 2017 17:41:57 +0000 (UTC)","X-detected-operating-system":"by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]\n\t[fuzzy]","X-Received-From":"209.132.183.28","X-Content-Filtered-By":"Mailman/MimeDel 2.1.21","Subject":"Re: [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":"i.maximets@samsung.com, heetae82.ahn@samsung.com, dgilbert@redhat.com,\n\tpeterx@redhat.com, quintela@redhat.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>"}},{"id":1772783,"web_url":"http://patchwork.ozlabs.org/comment/1772783/","msgid":"<20170921124228.GG2717@work-vm>","list_archive_url":null,"date":"2017-09-21T12:42:28","subject":"Re: [Qemu-devel] [PATCH v10 10/10] migration: add postcopy total\n\tblocktime into query-migrate","submitter":{"id":48102,"url":"http://patchwork.ozlabs.org/api/people/48102/","name":"Dr. David Alan Gilbert","email":"dgilbert@redhat.com"},"content":"* Alexey Perevalov (a.perevalov@samsung.com) wrote:\n> Postcopy total blocktime is available on destination side only.\n> But query-migrate was possible only for source. This patch\n> adds ability to call query-migrate on destination.\n> To be able to see postcopy blocktime, need to request postcopy-blocktime\n> capability.\n> \n> The 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> \n> postcopy_vcpu_blocktime contains list, where the first item is the first\n> vCPU in QEMU.\n> \n> This patch has a drawback, it combines states of incoming and\n> outgoing migration. Ongoing migration state will overwrite incoming\n> state. Looks like better to separate query-migrate for incoming and\n> outgoing migration or add parameter to indicate type of migration.\n> \n> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>\n> Signed-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(-)\n> \n> diff --git a/hmp.c b/hmp.c\n> index 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>  }\n> diff --git a/migration/migration.c b/migration/migration.c\n> index 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>  {\n> diff --git a/migration/migration.h b/migration/migration.h\n> index 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>  \n> diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c\n> index 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\nDo we want that error_report? info migrate shouldn't give an error on a\nnon-postcopy host.\n\nAlso, don't you fancy just checking for the presence of this new info in\nthe test?\n\nDave\n\n>  bool postcopy_ram_supported_by_host(MigrationIncomingState *mis)\n>  {\n>      error_report(\"%s: No OS support\", __func__);\n> diff --git a/migration/trace-events b/migration/trace-events\n> index 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\"\n> diff --git a/qapi/migration.json b/qapi/migration.json\n> index 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> -- \n> 1.9.1\n> \n--\nDr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK","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>)","ext-mx02.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com","ext-mx02.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=dgilbert@redhat.com"],"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 3xybqp4glvz9sP1\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 21 Sep 2017 22:43:02 +1000 (AEST)","from localhost ([::1]:53493 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 1dv0om-0001WN-Pk\n\tfor incoming@patchwork.ozlabs.org; Thu, 21 Sep 2017 08:43:00 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:47096)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <dgilbert@redhat.com>) id 1dv0oS-0001W7-Ki\n\tfor qemu-devel@nongnu.org; Thu, 21 Sep 2017 08:42:42 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <dgilbert@redhat.com>) id 1dv0oO-0000Um-0v\n\tfor qemu-devel@nongnu.org; Thu, 21 Sep 2017 08:42:40 -0400","from mx1.redhat.com ([209.132.183.28]:34638)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <dgilbert@redhat.com>) id 1dv0oN-0000UH-NX\n\tfor qemu-devel@nongnu.org; Thu, 21 Sep 2017 08:42:35 -0400","from smtp.corp.redhat.com\n\t(int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby mx1.redhat.com (Postfix) with ESMTPS id B94D9806CB;\n\tThu, 21 Sep 2017 12:42:34 +0000 (UTC)","from work-vm (ovpn-117-186.ams2.redhat.com [10.36.117.186])\n\tby smtp.corp.redhat.com (Postfix) with ESMTPS id 2614360E3B;\n\tThu, 21 Sep 2017 12:42:30 +0000 (UTC)"],"DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com B94D9806CB","Date":"Thu, 21 Sep 2017 13:42:28 +0100","From":"\"Dr. David Alan Gilbert\" <dgilbert@redhat.com>","To":"Alexey Perevalov <a.perevalov@samsung.com>","Message-ID":"<20170921124228.GG2717@work-vm>","References":"<1505839684-10046-1-git-send-email-a.perevalov@samsung.com>\n\t<CGME20170919164827eucas1p231a5b9afd8e81427db114e57a0b6fbbe@eucas1p2.samsung.com>\n\t<1505839684-10046-11-git-send-email-a.perevalov@samsung.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<1505839684-10046-11-git-send-email-a.perevalov@samsung.com>","User-Agent":"Mutt/1.8.3 (2017-05-23)","X-Scanned-By":"MIMEDefang 2.79 on 10.5.11.12","X-Greylist":"Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.26]);\n\tThu, 21 Sep 2017 12:42:34 +0000 (UTC)","X-detected-operating-system":"by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]\n\t[fuzzy]","X-Received-From":"209.132.183.28","Subject":"Re: [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, qemu-devel@nongnu.org,\n\tpeterx@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>"}},{"id":1772922,"web_url":"http://patchwork.ozlabs.org/comment/1772922/","msgid":"<288ce5a4-ece0-1754-c7df-0a6be5af1f2a@samsung.com>","list_archive_url":null,"date":"2017-09-21T15:24:54","subject":"Re: [Qemu-devel] [PATCH v10 10/10] migration: add postcopy total\n\tblocktime into query-migrate","submitter":{"id":18164,"url":"http://patchwork.ozlabs.org/api/people/18164/","name":"Alexey Perevalov","email":"a.perevalov@samsung.com"},"content":"On 09/21/2017 03:42 PM, Dr. David Alan Gilbert wrote:\n> * Alexey Perevalov (a.perevalov@samsung.com) wrote:\n>> Postcopy total blocktime is available on destination side only.\n>> But query-migrate was possible only for source. This patch\n>> adds ability to call query-migrate on destination.\n>> To be able to see postcopy blocktime, need to request postcopy-blocktime\n>> capability.\n>>\n>> The 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>>\n>> postcopy_vcpu_blocktime contains list, where the first item is the first\n>> vCPU in QEMU.\n>>\n>> This patch has a drawback, it combines states of incoming and\n>> outgoing migration. Ongoing migration state will overwrite incoming\n>> state. Looks like better to separate query-migrate for incoming and\n>> outgoing migration or add parameter to indicate type of migration.\n>>\n>> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>\n>> Signed-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(-)\n>>\n>> diff --git a/hmp.c b/hmp.c\n>> index 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>>   }\n>> diff --git a/migration/migration.c b/migration/migration.c\n>> index 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>>   {\n>> diff --git a/migration/migration.h b/migration/migration.h\n>> index 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>>   \n>> diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c\n>> index 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> Do we want that error_report? info migrate shouldn't give an error on a\n> non-postcopy host.\n>\n> Also, don't you fancy just checking for the presence of this new info in\n> the test?\nI'll add assert, like that\ng_assert(qdict_haskey(rsp_return, \"postcopy-blocktime\"));\nwhen host supports UFFD_FEATURE_THREAD_ID","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 3xygRX2rpnz9t43\n\tfor <incoming@patchwork.ozlabs.org>;\n\tFri, 22 Sep 2017 01:25:44 +1000 (AEST)","from localhost ([::1]:54190 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 1dv3ME-0003YE-Gi\n\tfor incoming@patchwork.ozlabs.org; Thu, 21 Sep 2017 11:25:42 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:34856)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <a.perevalov@samsung.com>) id 1dv3Lg-0003Sr-Qx\n\tfor qemu-devel@nongnu.org; Thu, 21 Sep 2017 11:25:10 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <a.perevalov@samsung.com>) id 1dv3La-00029m-I5\n\tfor qemu-devel@nongnu.org; Thu, 21 Sep 2017 11:25:08 -0400","from mailout1.w1.samsung.com ([210.118.77.11]:39177)\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 1dv3La-00027h-91\n\tfor qemu-devel@nongnu.org; Thu, 21 Sep 2017 11:25:02 -0400","from eucas1p2.samsung.com (unknown [182.198.249.207])\n\tby mailout1.w1.samsung.com (KnoxPortal) with ESMTP id\n\t20170921152458euoutp014a929be7790aa8a7cf341186e94381fb~madc6pfLb0242602426euoutp01n;\n\tThu, 21 Sep 2017 15:24:58 +0000 (GMT)","from eusmges2.samsung.com (unknown [203.254.199.241]) by\n\teucas1p2.samsung.com (KnoxPortal) with ESMTP id\n\t20170921152457eucas1p256cb4a6864c95e4c0107872c358f1cd7~madcJDlll1231712317eucas1p2a;\n\tThu, 21 Sep 2017 15:24:57 +0000 (GMT)","from eucas1p2.samsung.com ( [182.198.249.207]) by\n\teusmges2.samsung.com (EUCPMTA) with SMTP id 15.07.12907.9C9D3C95;\n\tThu, 21 Sep 2017 16:24:57 +0100 (BST)","from eusmgms2.samsung.com (unknown [182.198.249.180]) by\n\teucas1p1.samsung.com (KnoxPortal) with ESMTP id\n\t20170921152457eucas1p183c8d3afda870b14eca3f616f3423c34~madbfxoI41226512265eucas1p1j;\n\tThu, 21 Sep 2017 15:24:56 +0000 (GMT)","from eusync1.samsung.com ( [203.254.199.211]) by\n\teusmgms2.samsung.com (EUCPMTA) with SMTP id D1.BE.20118.8C9D3C95;\n\tThu, 21 Sep 2017 16:24:56 +0100 (BST)","from [106.109.129.199] by eusync1.samsung.com (Oracle\n\tCommunications Messaging Server 7.0.5.31.0 64bit (built May 5 2014))\n\twith ESMTPA id <0OWM00D8NYTK6CC0@eusync1.samsung.com>;\n\tThu, 21 Sep 2017 16:24:56 +0100 (BST)"],"X-AuditID":"cbfec7f1-f793a6d00000326b-73-59c3d9c9e745","To":"\"Dr. David Alan Gilbert\" <dgilbert@redhat.com>","From":"Alexey Perevalov <a.perevalov@samsung.com>","Message-id":"<288ce5a4-ece0-1754-c7df-0a6be5af1f2a@samsung.com>","Date":"Thu, 21 Sep 2017 18:24:54 +0300","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101\n\tThunderbird/52.2.1","MIME-version":"1.0","In-reply-to":"<20170921124228.GG2717@work-vm>","Content-type":"text/plain; charset=\"utf-8\"; format=\"flowed\"","Content-transfer-encoding":"7bit","Content-language":"en-GB","X-Brightmail-Tracker":["H4sIAAAAAAAAA+NgFprMKsWRmVeSWpSXmKPExsWy7djP87onbx6ONJixVcqid9s9douJb9ez\n\tWkz7fJvd4kr7T3aLLfu/sVsc793BYnFnSx+TA7vHk2ubmTze77vK5tG3ZRVjAHMUl01Kak5m\n\tWWqRvl0CV8b/A2+YClYEVHxYfZ6lgfG3bRcjJ4eEgInEp4U72CFsMYkL99azdTFycQgJLGWU\n\t2PxoJjuE85lR4vns26wwHSuvHWaBSCxjlNiz/C5U1QtGif3bngA5HBzCAtESj7ZmgJgiAkYS\n\tx34qgJQwC3QATZ3VzwoSZxMwkNh3zxbE5BWwk5jWyw1isgioSqx+XgWySVQgQmLb9xlsIDav\n\tgKDEj8n3WEBsTgEdiT9flzOB2MwCVhLP/rWyQtjyEpvXvGWGsMUljt2/yQiyVULgBJvErlPr\n\t2SDOd5G4+ncrlC0s8er4FqjnZSQuT+5mgWhoZ5To3tnJCuFMYJQ4M/0vVJW9xKmbV6FW80lM\n\t2jadGeRqCQFeiY42IYgSD4mvk7YyQdiOEs9mr4OG6B9GiR2H7rJOYJSfheSjWUi+mIXki1lI\n\tvljAyLKKUSS1tDg3PbXYSK84Mbe4NC9dLzk/dxMjMKmc/nf84w7G9yesDjEKcDAq8fDe2Hc4\n\tUog1say4MvcQowQHs5IIb+V1oBBvSmJlVWpRfnxRaU5q8SFGaQ4WJXFe26i2SCGB9MSS1OzU\n\t1ILUIpgsEwenVAPj7lnfT183tzow31W455tE/Hfxbc+9tvzoueiUl2VqXunOn3TP6MwXc3eP\n\tgO3LPY9abz1b1WjLViZ54qzC+gWr+iRlj9j8SUhLNfOfv6rIpnvTORc+z5i/D4/NfsGXm6BW\n\tLSb4VWgu32eNuObH4jdiQnen3DW4+fy4jHnPF/dvhvln94v83/lZiaU4I9FQi7moOBEAwPPN\n\tyyYDAAA=","H4sIAAAAAAAAA+NgFnrOLMWRmVeSWpSXmKPExsVy+t/xy7onbh6ONFhz0Nqid9s9douJb9ez\n\tWkz7fJvd4kr7T3aLLfu/sVsc793BYnFnSx+TA7vHk2ubmTze77vK5tG3ZRVjAHMUl01Kak5m\n\tWWqRvl0CV8b/A2+YClYEVHxYfZ6lgfG3bRcjJ4eEgInEymuHWSBsMYkL99azdTFycQgJLGGU\n\t6DtwlhHCecEosXF1G3MXIweHsEC0xKOtGSCmiICRxLGfCiAlzAIdjBLfL+1hh6j/wyjxbj9I\n\tMwcHm4CBxL57tiAmr4CdxLRebhCTRUBVYvXzKpC1ogIREn1vL7OD2LwCghI/Jt8DO4dTQEfi\n\tz9flTCA2s4CZxJeXh1khbHmJzWveMkPY4hLH7t9knMAoOAtJ+ywkLbOQtMxC0rKAkWUVo0hq\n\taXFuem6xkV5xYm5xaV66XnJ+7iZGYPBvO/Zzyw7GrnfBhxgFOBiVeHhv7DscKcSaWFZcmXuI\n\tUYKDWUmEt/I6UIg3JbGyKrUoP76oNCe1+BCjNAeLkjhv757VkUIC6YklqdmpqQWpRTBZJg5O\n\tqQbGwN9rbyz5q3n+gobj9G+Z001io7MbFV4YHlFg7zhgVux+w0Z1f8zT6yZHjsTpPmM/FbBO\n\tpaCwIe7XRBm/iFMfEwJfOC12jv4TUmPo1JDnYravxmjT8UXRzIeu7fA1LXk1a0rU3H3f1F3f\n\t3PKRvPjk97WSyoV2BZ82GH92frZn6bf5/52ORGuHK7EUZyQaajEXFScCANrOnVB6AgAA"],"X-CMS-MailID":"20170921152457eucas1p183c8d3afda870b14eca3f616f3423c34","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>\n\t<1505839684-10046-11-git-send-email-a.perevalov@samsung.com>\n\t<20170921124228.GG2717@work-vm>","X-detected-operating-system":"by eggs.gnu.org: GNU/Linux 3.x [fuzzy]","X-Received-From":"210.118.77.11","Subject":"Re: [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, qemu-devel@nongnu.org,\n\tpeterx@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>"}},{"id":1772996,"web_url":"http://patchwork.ozlabs.org/comment/1772996/","msgid":"<20170921164431.GK2717@work-vm>","list_archive_url":null,"date":"2017-09-21T16:44:32","subject":"Re: [Qemu-devel] [PATCH v10 10/10] migration: add postcopy total\n\tblocktime into query-migrate","submitter":{"id":48102,"url":"http://patchwork.ozlabs.org/api/people/48102/","name":"Dr. David Alan Gilbert","email":"dgilbert@redhat.com"},"content":"* Alexey Perevalov (a.perevalov@samsung.com) wrote:\n> On 09/21/2017 03:42 PM, Dr. David Alan Gilbert wrote:\n> > * Alexey Perevalov (a.perevalov@samsung.com) wrote:\n> > > Postcopy total blocktime is available on destination side only.\n> > > But query-migrate was possible only for source. This patch\n> > > adds ability to call query-migrate on destination.\n> > > To be able to see postcopy blocktime, need to request postcopy-blocktime\n> > > capability.\n> > > \n> > > The 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> > > \n> > > postcopy_vcpu_blocktime contains list, where the first item is the first\n> > > vCPU in QEMU.\n> > > \n> > > This patch has a drawback, it combines states of incoming and\n> > > outgoing migration. Ongoing migration state will overwrite incoming\n> > > state. Looks like better to separate query-migrate for incoming and\n> > > outgoing migration or add parameter to indicate type of migration.\n> > > \n> > > Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>\n> > > Signed-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(-)\n> > > \n> > > diff --git a/hmp.c b/hmp.c\n> > > index 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> > > +    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> > >   }\n> > > diff --git a/migration/migration.c b/migration/migration.c\n> > > index 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> > > -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> > >       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> > > @@ -649,6 +648,41 @@ static bool migrate_caps_check(bool *cap_list,\n> > >       return true;\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> > >   {\n> > > diff --git a/migration/migration.h b/migration/migration.h\n> > > index 770466b..882a59b 100644\n> > > --- a/migration/migration.h\n> > > +++ b/migration/migration.h\n> > > @@ -70,6 +70,10 @@ struct MigrationIncomingState {\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> > >   #define TYPE_MIGRATION \"migration\"\n> > > diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c\n> > > index 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> > > +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> > >   #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> > Do we want that error_report? info migrate shouldn't give an error on a\n> > non-postcopy host.\n> > \n> > Also, don't you fancy just checking for the presence of this new info in\n> > the test?\n> I'll add assert, like that\n> g_assert(qdict_haskey(rsp_return, \"postcopy-blocktime\"));\n\nYes, that seems reasonable.\n\n> when host supports UFFD_FEATURE_THREAD_ID\n\nGreat;  note that needs to be runtime, not the ifdef.\n\nDave\n\n> -- \n> Best regards,\n> Alexey Perevalov\n> > \n> > Dave\n> > \n> > >   bool postcopy_ram_supported_by_host(MigrationIncomingState *mis)\n> > >   {\n> > >       error_report(\"%s: No OS support\", __func__);\n> > > diff --git a/migration/trace-events b/migration/trace-events\n> > > index 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\"\n> > > diff --git a/qapi/migration.json b/qapi/migration.json\n> > > index 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> > >   # @query-migrate:\n> > > -- \n> > > 1.9.1\n> > > \n> > --\n> > Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK\n> > \n> > \n> > \n> \n> \n--\nDr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK","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>)","ext-mx09.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com","ext-mx09.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=dgilbert@redhat.com"],"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 3xyjbV36Rhz9sRq\n\tfor <incoming@patchwork.ozlabs.org>;\n\tFri, 22 Sep 2017 03:02:46 +1000 (AEST)","from localhost ([::1]:54730 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 1dv4s8-0004Lx-H3\n\tfor incoming@patchwork.ozlabs.org; Thu, 21 Sep 2017 13:02:44 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:33533)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <dgilbert@redhat.com>) id 1dv4aj-00066q-HW\n\tfor qemu-devel@nongnu.org; Thu, 21 Sep 2017 12:44:47 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <dgilbert@redhat.com>) id 1dv4ag-0006og-4S\n\tfor qemu-devel@nongnu.org; Thu, 21 Sep 2017 12:44:45 -0400","from mx1.redhat.com ([209.132.183.28]:57860)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <dgilbert@redhat.com>) id 1dv4af-0006lp-Rg\n\tfor qemu-devel@nongnu.org; Thu, 21 Sep 2017 12:44:42 -0400","from smtp.corp.redhat.com\n\t(int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby mx1.redhat.com (Postfix) with ESMTPS id E274365CE9;\n\tThu, 21 Sep 2017 16:44:39 +0000 (UTC)","from work-vm (ovpn-117-186.ams2.redhat.com [10.36.117.186])\n\tby smtp.corp.redhat.com (Postfix) with ESMTPS id 1ECB2600C2;\n\tThu, 21 Sep 2017 16:44:34 +0000 (UTC)"],"DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com E274365CE9","Date":"Thu, 21 Sep 2017 17:44:32 +0100","From":"\"Dr. David Alan Gilbert\" <dgilbert@redhat.com>","To":"Alexey Perevalov <a.perevalov@samsung.com>","Message-ID":"<20170921164431.GK2717@work-vm>","References":"<1505839684-10046-1-git-send-email-a.perevalov@samsung.com>\n\t<CGME20170919164827eucas1p231a5b9afd8e81427db114e57a0b6fbbe@eucas1p2.samsung.com>\n\t<1505839684-10046-11-git-send-email-a.perevalov@samsung.com>\n\t<20170921124228.GG2717@work-vm>\n\t<288ce5a4-ece0-1754-c7df-0a6be5af1f2a@samsung.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<288ce5a4-ece0-1754-c7df-0a6be5af1f2a@samsung.com>","User-Agent":"Mutt/1.8.3 (2017-05-23)","X-Scanned-By":"MIMEDefang 2.79 on 10.5.11.11","X-Greylist":"Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.38]);\n\tThu, 21 Sep 2017 16:44:40 +0000 (UTC)","X-detected-operating-system":"by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]\n\t[fuzzy]","X-Received-From":"209.132.183.28","Subject":"Re: [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, qemu-devel@nongnu.org,\n\tpeterx@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>"}}]