From patchwork Wed Jun 12 10:53:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 10989471 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3A41713AF for ; Wed, 12 Jun 2019 11:14:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2170728A09 for ; Wed, 12 Jun 2019 11:14:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 152A128A21; Wed, 12 Jun 2019 11:14:06 +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=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 33CBA28A5D for ; Wed, 12 Jun 2019 11:14:05 +0000 (UTC) Received: from localhost ([::1]:58870 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hb1Ce-0004zg-9T for patchwork-qemu-devel@patchwork.kernel.org; Wed, 12 Jun 2019 07:14:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60193) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hb0t9-0008M5-Qr for qemu-devel@nongnu.org; Wed, 12 Jun 2019 06:53:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hb0t6-0004o2-95 for qemu-devel@nongnu.org; Wed, 12 Jun 2019 06:53:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51388) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hb0t5-0004kZ-68 for qemu-devel@nongnu.org; Wed, 12 Jun 2019 06:53:51 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7DC0B882EA for ; Wed, 12 Jun 2019 10:53:42 +0000 (UTC) Received: from localhost.localdomain (ovpn-116-241.ams2.redhat.com [10.36.116.241]) by smtp.corp.redhat.com (Postfix) with ESMTP id 98CFB17C46; Wed, 12 Jun 2019 10:53:40 +0000 (UTC) From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 12 Jun 2019 12:53:21 +0200 Message-Id: <20190612105323.7051-5-quintela@redhat.com> In-Reply-To: <20190612105323.7051-1-quintela@redhat.com> References: <20190612105323.7051-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Wed, 12 Jun 2019 10:53:42 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v4 4/6] migration: Add multifd-compress parameter X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Thomas Huth , Juan Quintela , Markus Armbruster , "Dr. David Alan Gilbert" , Paolo Bonzini Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Juan Quintela --- Rename it to NONE Fix typos (dave) We don't need to chek values returned by visit_type_MultifdCompress (markus) Fix yet more typos (wei) --- hmp.c | 13 +++++++++++++ hw/core/qdev-properties.c | 13 +++++++++++++ include/hw/qdev-properties.h | 3 +++ migration/migration.c | 13 +++++++++++++ qapi/migration.json | 30 +++++++++++++++++++++++++++--- tests/migration-test.c | 13 ++++++++++--- 6 files changed, 79 insertions(+), 6 deletions(-) diff --git a/hmp.c b/hmp.c index be5e345c6f..b011f139ca 100644 --- a/hmp.c +++ b/hmp.c @@ -38,6 +38,7 @@ #include "qapi/qapi-commands-run-state.h" #include "qapi/qapi-commands-tpm.h" #include "qapi/qapi-commands-ui.h" +#include "qapi/qapi-visit-migration.h" #include "qapi/qmp/qdict.h" #include "qapi/qmp/qerror.h" #include "qapi/string-input-visitor.h" @@ -435,6 +436,9 @@ void hmp_info_migrate_parameters(Monitor *mon, const QDict *qdict) monitor_printf(mon, "%s: %u\n", MigrationParameter_str(MIGRATION_PARAMETER_MULTIFD_CHANNELS), params->multifd_channels); + monitor_printf(mon, "%s: %s\n", + MigrationParameter_str(MIGRATION_PARAMETER_MULTIFD_COMPRESS), + MultifdCompress_str(params->multifd_compress)); monitor_printf(mon, "%s: %" PRIu64 "\n", MigrationParameter_str(MIGRATION_PARAMETER_XBZRLE_CACHE_SIZE), params->xbzrle_cache_size); @@ -1736,6 +1740,7 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict) MigrateSetParameters *p = g_new0(MigrateSetParameters, 1); uint64_t valuebw = 0; uint64_t cache_size; + MultifdCompress compress_type; Error *err = NULL; int val, ret; @@ -1821,6 +1826,14 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict) p->has_multifd_channels = true; visit_type_int(v, param, &p->multifd_channels, &err); break; + case MIGRATION_PARAMETER_MULTIFD_COMPRESS: + p->has_multifd_compress = true; + visit_type_MultifdCompress(v, param, &compress_type, &err); + if (err) { + break; + } + p->multifd_compress = compress_type; + break; case MIGRATION_PARAMETER_XBZRLE_CACHE_SIZE: p->has_xbzrle_cache_size = true; visit_type_size(v, param, &cache_size, &err); diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c index 5da1439a8b..ebeeb5c88d 100644 --- a/hw/core/qdev-properties.c +++ b/hw/core/qdev-properties.c @@ -5,6 +5,7 @@ #include "hw/pci/pci.h" #include "qapi/qmp/qerror.h" #include "qemu/error-report.h" +#include "qapi/qapi-types-migration.h" #include "hw/block/block.h" #include "net/hub.h" #include "qapi/visitor.h" @@ -645,6 +646,18 @@ const PropertyInfo qdev_prop_fdc_drive_type = { .set_default_value = set_default_value_enum, }; +/* --- MultifdCompress --- */ + +const PropertyInfo qdev_prop_multifd_compress = { + .name = "MultifdCompress", + .description = "multifd_compress values, " + "none", + .enum_table = &MultifdCompress_lookup, + .get = get_enum, + .set = set_enum, + .set_default_value = set_default_value_enum, +}; + /* --- pci address --- */ /* diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h index 1eae5ab056..34d906593b 100644 --- a/include/hw/qdev-properties.h +++ b/include/hw/qdev-properties.h @@ -23,6 +23,7 @@ extern const PropertyInfo qdev_prop_tpm; extern const PropertyInfo qdev_prop_ptr; extern const PropertyInfo qdev_prop_macaddr; extern const PropertyInfo qdev_prop_on_off_auto; +extern const PropertyInfo qdev_prop_multifd_compress; extern const PropertyInfo qdev_prop_losttickpolicy; extern const PropertyInfo qdev_prop_blockdev_on_error; extern const PropertyInfo qdev_prop_bios_chs_trans; @@ -205,6 +206,8 @@ extern const PropertyInfo qdev_prop_pcie_link_width; DEFINE_PROP(_n, _s, _f, qdev_prop_macaddr, MACAddr) #define DEFINE_PROP_ON_OFF_AUTO(_n, _s, _f, _d) \ DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_on_off_auto, OnOffAuto) +#define DEFINE_PROP_MULTIFD_COMPRESS(_n, _s, _f, _d) \ + DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_multifd_compress, MultifdCompress) #define DEFINE_PROP_LOSTTICKPOLICY(_n, _s, _f, _d) \ DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_losttickpolicy, \ LostTickPolicy) diff --git a/migration/migration.c b/migration/migration.c index 4246bdd661..3f17d8f2f8 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -82,6 +82,7 @@ /* The delay time (in ms) between two COLO checkpoints */ #define DEFAULT_MIGRATE_X_CHECKPOINT_DELAY (200 * 100) #define DEFAULT_MIGRATE_MULTIFD_CHANNELS 2 +#define DEFAULT_MIGRATE_MULTIFD_COMPRESS MULTIFD_COMPRESS_NONE /* Background transfer rate for postcopy, 0 means unlimited, note * that page requests can still exceed this limit. @@ -769,6 +770,8 @@ MigrationParameters *qmp_query_migrate_parameters(Error **errp) params->block_incremental = s->parameters.block_incremental; params->has_multifd_channels = true; params->multifd_channels = s->parameters.multifd_channels; + params->has_multifd_compress = true; + params->multifd_compress = s->parameters.multifd_compress; params->has_xbzrle_cache_size = true; params->xbzrle_cache_size = s->parameters.xbzrle_cache_size; params->has_max_postcopy_bandwidth = true; @@ -1268,6 +1271,9 @@ static void migrate_params_test_apply(MigrateSetParameters *params, if (params->has_multifd_channels) { dest->multifd_channels = params->multifd_channels; } + if (params->has_multifd_compress) { + dest->multifd_compress = params->multifd_compress; + } if (params->has_xbzrle_cache_size) { dest->xbzrle_cache_size = params->xbzrle_cache_size; } @@ -1364,6 +1370,9 @@ static void migrate_params_apply(MigrateSetParameters *params, Error **errp) if (params->has_multifd_channels) { s->parameters.multifd_channels = params->multifd_channels; } + if (params->has_multifd_compress) { + s->parameters.multifd_compress = params->multifd_compress; + } if (params->has_xbzrle_cache_size) { s->parameters.xbzrle_cache_size = params->xbzrle_cache_size; xbzrle_cache_resize(params->xbzrle_cache_size, errp); @@ -3406,6 +3415,9 @@ static Property migration_properties[] = { DEFINE_PROP_UINT8("multifd-channels", MigrationState, parameters.multifd_channels, DEFAULT_MIGRATE_MULTIFD_CHANNELS), + DEFINE_PROP_MULTIFD_COMPRESS("multifd-compress", MigrationState, + parameters.multifd_compress, + DEFAULT_MIGRATE_MULTIFD_COMPRESS), DEFINE_PROP_SIZE("xbzrle-cache-size", MigrationState, parameters.xbzrle_cache_size, DEFAULT_MIGRATE_XBZRLE_CACHE_SIZE), @@ -3495,6 +3507,7 @@ static void migration_instance_init(Object *obj) params->has_x_checkpoint_delay = true; params->has_block_incremental = true; params->has_multifd_channels = true; + params->has_multifd_compress = true; params->has_xbzrle_cache_size = true; params->has_max_postcopy_bandwidth = true; params->has_max_cpu_throttle = true; diff --git a/qapi/migration.json b/qapi/migration.json index 9cfbaf8c6c..153527e120 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -482,6 +482,19 @@ ## { 'command': 'query-migrate-capabilities', 'returns': ['MigrationCapabilityStatus']} +## +# @MultifdCompress: +# +# An enumeration of multifd compression. +# +# @none: no compression. +# +# Since: 4.1 +# +## +{ 'enum': 'MultifdCompress', + 'data': [ 'none' ] } + ## # @MigrationParameter: # @@ -580,6 +593,9 @@ # @max-cpu-throttle: maximum cpu throttle percentage. # Defaults to 99. (Since 3.1) # +# @multifd-compress: Which compression method to use. +# Defaults to none. (Since 4.1) +# # Since: 2.4 ## { 'enum': 'MigrationParameter', @@ -592,7 +608,7 @@ 'downtime-limit', 'x-checkpoint-delay', 'block-incremental', 'multifd-channels', 'xbzrle-cache-size', 'max-postcopy-bandwidth', - 'max-cpu-throttle' ] } + 'max-cpu-throttle', 'multifd-compress' ] } ## # @MigrateSetParameters: @@ -682,6 +698,9 @@ # @max-cpu-throttle: maximum cpu throttle percentage. # The default value is 99. (Since 3.1) # +# @multifd-compress: Which compression method to use. +# Defaults to none. (Since 4.1) +# # Since: 2.4 ## # TODO either fuse back into MigrationParameters, or make @@ -707,7 +726,8 @@ '*multifd-channels': 'int', '*xbzrle-cache-size': 'size', '*max-postcopy-bandwidth': 'size', - '*max-cpu-throttle': 'int' } } + '*max-cpu-throttle': 'int', + '*multifd-compress': 'MultifdCompress' } } ## # @migrate-set-parameters: @@ -817,6 +837,9 @@ # Defaults to 99. # (Since 3.1) # +# @multifd-compress: Which compression method to use. +# Defaults to none. (Since 4.1) +# # Since: 2.4 ## { 'struct': 'MigrationParameters', @@ -840,7 +863,8 @@ '*multifd-channels': 'uint8', '*xbzrle-cache-size': 'size', '*max-postcopy-bandwidth': 'size', - '*max-cpu-throttle':'uint8'} } + '*max-cpu-throttle': 'uint8', + '*multifd-compress': 'MultifdCompress' } } ## # @query-migrate-parameters: diff --git a/tests/migration-test.c b/tests/migration-test.c index c7c311e02c..e5b8125e1c 100644 --- a/tests/migration-test.c +++ b/tests/migration-test.c @@ -464,7 +464,6 @@ static void migrate_check_parameter_str(QTestState *who, const char *parameter, g_free(result); } -__attribute__((unused)) static void migrate_set_parameter_str(QTestState *who, const char *parameter, const char *value) { @@ -1165,7 +1164,7 @@ static void test_migrate_fd_proto(void) test_migrate_end(from, to, true); } -static void test_multifd_tcp(void) +static void test_multifd_tcp(const char *method) { char *uri; QTestState *from, *to; @@ -1187,6 +1186,9 @@ static void test_multifd_tcp(void) migrate_set_parameter_int(from, "multifd-channels", 2); migrate_set_parameter_int(to, "multifd-channels", 2); + migrate_set_parameter_str(from, "multifd-compress", method); + migrate_set_parameter_str(to, "multifd-compress", method); + migrate_set_capability(from, "multifd", "true"); migrate_set_capability(to, "multifd", "true"); /* Wait for the first serial output from the source */ @@ -1212,6 +1214,11 @@ static void test_multifd_tcp(void) free(uri); } +static void test_multifd_tcp_none(void) +{ + test_multifd_tcp("none"); +} + int main(int argc, char **argv) { char template[] = "/tmp/migration-test-XXXXXX"; @@ -1267,7 +1274,7 @@ int main(int argc, char **argv) /* qtest_add_func("/migration/ignore_shared", test_ignore_shared); */ qtest_add_func("/migration/xbzrle/unix", test_xbzrle_unix); qtest_add_func("/migration/fd_proto", test_migrate_fd_proto); - qtest_add_func("/migration/multifd/tcp", test_multifd_tcp); + qtest_add_func("/migration/multifd/tcp/none", test_multifd_tcp_none); ret = g_test_run();