From nobody Thu Apr 25 14:38:39 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1581628747883133.25158375782917; Thu, 13 Feb 2020 13:19:07 -0800 (PST) Received: from localhost ([::1]:59246 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j2Lt4-0006kH-DW for importer@patchew.org; Thu, 13 Feb 2020 16:19:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48522) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j2LrR-0005Jk-Sp for qemu-devel@nongnu.org; Thu, 13 Feb 2020 16:17:27 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j2LrP-0004HA-UK for qemu-devel@nongnu.org; Thu, 13 Feb 2020 16:17:25 -0500 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:57444 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j2LrP-0004Ac-Nt for qemu-devel@nongnu.org; Thu, 13 Feb 2020 16:17:23 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-29-YIDkNKAwPOa3G4Z-hBbIqw-1; Thu, 13 Feb 2020 16:17:20 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4AE5D18AB2C3; Thu, 13 Feb 2020 21:17:19 +0000 (UTC) Received: from secure.mitica (ovpn-116-211.ams2.redhat.com [10.36.116.211]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3363E27061; Thu, 13 Feb 2020 21:17:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581628642; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cKbhhEuZLrI9Pedb2AiOU1kSHZKoJ6mMfxWzXnPrY2w=; b=GjUuGQeFjTkMx3bSBBKnBR7qRCndTr8gXLy+Q89n6qBnRbyuQB3wX6WKVGwQxaLl+VgtvA lL4MssAlskIaEBGFh7XEaWUDSySKBNc0x8ELsO+IsJtKq2QInW4zafXRw0bUhNY00S1FRb 2BTOo+F2hQapiyEOjMZyGWpxDAKmnTA= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PATCH v6 1/8] multifd: Add multifd-compression parameter Date: Thu, 13 Feb 2020 22:17:02 +0100 Message-Id: <20200213211709.59065-2-quintela@redhat.com> In-Reply-To: <20200213211709.59065-1-quintela@redhat.com> References: <20200213211709.59065-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: YIDkNKAwPOa3G4Z-hBbIqw-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 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: Fam Zheng , Laurent Vivier , Thomas Huth , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , Juan Quintela , Markus Armbruster , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Paolo Bonzini , =?UTF-8?q?Alex=20Benn=C3=A9e?= , "Dr. David Alan Gilbert" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" This will store the compression method to use. We start with none. Signed-off-by: Juan Quintela Acked-by: Markus Armbruster Reviewed-by: Dr. David Alan Gilbert --- Rename multifd-method to multifd-compression --- hw/core/qdev-properties.c | 13 +++++++++++++ include/hw/qdev-properties.h | 4 ++++ migration/migration.c | 13 +++++++++++++ monitor/hmp-cmds.c | 13 +++++++++++++ qapi/migration.json | 30 +++++++++++++++++++++++++++--- tests/qtest/migration-test.c | 14 ++++++++++---- 6 files changed, 80 insertions(+), 7 deletions(-) diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c index 7f93bfeb88..fa7edac020 100644 --- a/hw/core/qdev-properties.c +++ b/hw/core/qdev-properties.c @@ -8,6 +8,7 @@ #include "qapi/qmp/qerror.h" #include "qemu/ctype.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" @@ -639,6 +640,18 @@ const PropertyInfo qdev_prop_fdc_drive_type =3D { .set_default_value =3D set_default_value_enum, }; =20 +/* --- MultiFDCompression --- */ + +const PropertyInfo qdev_prop_multifd_compression =3D { + .name =3D "MultiFDCompression", + .description =3D "multifd_compression values, " + "none", + .enum_table =3D &MultiFDCompression_lookup, + .get =3D get_enum, + .set =3D set_enum, + .set_default_value =3D set_default_value_enum, +}; + /* --- pci address --- */ =20 /* diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h index 906e697c58..f161604fb6 100644 --- a/include/hw/qdev-properties.h +++ b/include/hw/qdev-properties.h @@ -20,6 +20,7 @@ extern const PropertyInfo qdev_prop_chr; extern const PropertyInfo qdev_prop_tpm; extern const PropertyInfo qdev_prop_macaddr; extern const PropertyInfo qdev_prop_on_off_auto; +extern const PropertyInfo qdev_prop_multifd_compression; extern const PropertyInfo qdev_prop_losttickpolicy; extern const PropertyInfo qdev_prop_blockdev_on_error; extern const PropertyInfo qdev_prop_bios_chs_trans; @@ -184,6 +185,9 @@ 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_COMPRESSION(_n, _s, _f, _d) \ + DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_multifd_compression, \ + MultiFDCompression) #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 8fb68795dc..bc744d1734 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -88,6 +88,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_COMPRESSION MULTIFD_COMPRESSION_NONE =20 /* Background transfer rate for postcopy, 0 means unlimited, note * that page requests can still exceed this limit. @@ -798,6 +799,8 @@ MigrationParameters *qmp_query_migrate_parameters(Error= **errp) params->block_incremental =3D s->parameters.block_incremental; params->has_multifd_channels =3D true; params->multifd_channels =3D s->parameters.multifd_channels; + params->has_multifd_compression =3D true; + params->multifd_compression =3D s->parameters.multifd_compression; params->has_xbzrle_cache_size =3D true; params->xbzrle_cache_size =3D s->parameters.xbzrle_cache_size; params->has_max_postcopy_bandwidth =3D true; @@ -1315,6 +1318,9 @@ static void migrate_params_test_apply(MigrateSetParam= eters *params, if (params->has_multifd_channels) { dest->multifd_channels =3D params->multifd_channels; } + if (params->has_multifd_compression) { + dest->multifd_compression =3D params->multifd_compression; + } if (params->has_xbzrle_cache_size) { dest->xbzrle_cache_size =3D params->xbzrle_cache_size; } @@ -1411,6 +1417,9 @@ static void migrate_params_apply(MigrateSetParameters= *params, Error **errp) if (params->has_multifd_channels) { s->parameters.multifd_channels =3D params->multifd_channels; } + if (params->has_multifd_compression) { + s->parameters.multifd_compression =3D params->multifd_compression; + } if (params->has_xbzrle_cache_size) { s->parameters.xbzrle_cache_size =3D params->xbzrle_cache_size; xbzrle_cache_resize(params->xbzrle_cache_size, errp); @@ -3523,6 +3532,9 @@ static Property migration_properties[] =3D { DEFINE_PROP_UINT8("multifd-channels", MigrationState, parameters.multifd_channels, DEFAULT_MIGRATE_MULTIFD_CHANNELS), + DEFINE_PROP_MULTIFD_COMPRESSION("multifd-compression", MigrationState, + parameters.multifd_compression, + DEFAULT_MIGRATE_MULTIFD_COMPRESSION), DEFINE_PROP_SIZE("xbzrle-cache-size", MigrationState, parameters.xbzrle_cache_size, DEFAULT_MIGRATE_XBZRLE_CACHE_SIZE), @@ -3613,6 +3625,7 @@ static void migration_instance_init(Object *obj) params->has_x_checkpoint_delay =3D true; params->has_block_incremental =3D true; params->has_multifd_channels =3D true; + params->has_multifd_compression =3D true; params->has_xbzrle_cache_size =3D true; params->has_max_postcopy_bandwidth =3D true; params->has_max_cpu_throttle =3D true; diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index 558fe06b8f..40525b5e95 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -39,6 +39,7 @@ #include "qapi/qapi-commands-tpm.h" #include "qapi/qapi-commands-ui.h" #include "qapi/qapi-visit-net.h" +#include "qapi/qapi-visit-migration.h" #include "qapi/qmp/qdict.h" #include "qapi/qmp/qerror.h" #include "qapi/string-input-visitor.h" @@ -447,6 +448,9 @@ void hmp_info_migrate_parameters(Monitor *mon, const QD= ict *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_COMPRESSION= ), + MultiFDCompression_str(params->multifd_compression)); monitor_printf(mon, "%s: %" PRIu64 "\n", MigrationParameter_str(MIGRATION_PARAMETER_XBZRLE_CACHE_SIZE), params->xbzrle_cache_size); @@ -1738,6 +1742,7 @@ void hmp_migrate_set_parameter(Monitor *mon, const QD= ict *qdict) MigrateSetParameters *p =3D g_new0(MigrateSetParameters, 1); uint64_t valuebw =3D 0; uint64_t cache_size; + MultiFDCompression compress_type; Error *err =3D NULL; int val, ret; =20 @@ -1823,6 +1828,14 @@ void hmp_migrate_set_parameter(Monitor *mon, const Q= Dict *qdict) p->has_multifd_channels =3D true; visit_type_int(v, param, &p->multifd_channels, &err); break; + case MIGRATION_PARAMETER_MULTIFD_COMPRESSION: + p->has_multifd_compression =3D true; + visit_type_MultiFDCompression(v, param, &compress_type, &err); + if (err) { + break; + } + p->multifd_compression =3D compress_type; + break; case MIGRATION_PARAMETER_XBZRLE_CACHE_SIZE: p->has_xbzrle_cache_size =3D true; visit_type_size(v, param, &cache_size, &err); diff --git a/qapi/migration.json b/qapi/migration.json index b7348d0c8b..28593e2a2c 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -488,6 +488,19 @@ ## { 'command': 'query-migrate-capabilities', 'returns': ['MigrationCapabil= ityStatus']} =20 +## +# @MultiFDCompression: +# +# An enumeration of multifd compression methods. +# +# @none: no compression. +# +# Since: 5.0 +# +## +{ 'enum': 'MultiFDCompression', + 'data': [ 'none' ] } + ## # @MigrationParameter: # @@ -586,6 +599,9 @@ # @max-cpu-throttle: maximum cpu throttle percentage. # Defaults to 99. (Since 3.1) # +# @multifd-compression: Which compression method to use. +# Defaults to none. (Since 5.0) +# # Since: 2.4 ## { 'enum': 'MigrationParameter', @@ -598,7 +614,7 @@ 'downtime-limit', 'x-checkpoint-delay', 'block-incremental', 'multifd-channels', 'xbzrle-cache-size', 'max-postcopy-bandwidth', - 'max-cpu-throttle' ] } + 'max-cpu-throttle', 'multifd-compression' ] } =20 ## # @MigrateSetParameters: @@ -688,6 +704,9 @@ # @max-cpu-throttle: maximum cpu throttle percentage. # The default value is 99. (Since 3.1) # +# @multifd-compression: Which compression method to use. +# Defaults to none. (Since 5.0) +# # Since: 2.4 ## # TODO either fuse back into MigrationParameters, or make @@ -713,7 +732,8 @@ '*multifd-channels': 'int', '*xbzrle-cache-size': 'size', '*max-postcopy-bandwidth': 'size', - '*max-cpu-throttle': 'int' } } + '*max-cpu-throttle': 'int', + '*multifd-compression': 'MultiFDCompression' } } =20 ## # @migrate-set-parameters: @@ -823,6 +843,9 @@ # Defaults to 99. # (Since 3.1) # +# @multifd-compression: Which compression method to use. +# Defaults to none. (Since 5.0) +# # Since: 2.4 ## { 'struct': 'MigrationParameters', @@ -846,7 +869,8 @@ '*multifd-channels': 'uint8', '*xbzrle-cache-size': 'size', '*max-postcopy-bandwidth': 'size', - '*max-cpu-throttle':'uint8'} } + '*max-cpu-throttle': 'uint8', + '*multifd-compression': 'MultiFDCompression' } } =20 ## # @query-migrate-parameters: diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index ccf313f288..f84c157285 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -378,7 +378,6 @@ static void migrate_check_parameter_str(QTestState *who= , const char *parameter, g_free(result); } =20 -__attribute__((unused)) static void migrate_set_parameter_str(QTestState *who, const char *paramet= er, const char *value) { @@ -1261,7 +1260,7 @@ static void test_migrate_auto_converge(void) test_migrate_end(from, to, true); } =20 -static void test_multifd_tcp(void) +static void test_multifd_tcp(const char *method) { MigrateStart *args =3D migrate_start_new(); QTestState *from, *to; @@ -1285,6 +1284,9 @@ static void test_multifd_tcp(void) migrate_set_parameter_int(from, "multifd-channels", 16); migrate_set_parameter_int(to, "multifd-channels", 16); =20 + migrate_set_parameter_str(from, "multifd-compression", method); + migrate_set_parameter_str(to, "multifd-compression", method); + migrate_set_capability(from, "multifd", "true"); migrate_set_capability(to, "multifd", "true"); =20 @@ -1316,6 +1318,11 @@ static void test_multifd_tcp(void) g_free(uri); } =20 +static void test_multifd_tcp_none(void) +{ + test_multifd_tcp("none"); +} + /* * This test does: * source target @@ -1327,7 +1334,6 @@ static void test_multifd_tcp(void) * * And see that it works */ - static void test_multifd_tcp_cancel(void) { MigrateStart *args =3D migrate_start_new(); @@ -1478,7 +1484,7 @@ int main(int argc, char **argv) test_validate_uuid_dst_not_set); =20 qtest_add_func("/migration/auto_converge", test_migrate_auto_converge); - qtest_add_func("/migration/multifd/tcp", test_multifd_tcp); + qtest_add_func("/migration/multifd/tcp/none", test_multifd_tcp_none); qtest_add_func("/migration/multifd/tcp/cancel", test_multifd_tcp_cance= l); =20 ret =3D g_test_run(); --=20 2.24.1 From nobody Thu Apr 25 14:38:39 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1581628755135986.4493818223444; Thu, 13 Feb 2020 13:19:15 -0800 (PST) Received: from localhost ([::1]:59248 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j2LtB-0006my-Kf for importer@patchew.org; Thu, 13 Feb 2020 16:19:13 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48662) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j2LrT-0005Kf-Va for qemu-devel@nongnu.org; Thu, 13 Feb 2020 16:17:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j2LrT-0004Sm-1X for qemu-devel@nongnu.org; Thu, 13 Feb 2020 16:17:27 -0500 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:45508 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j2LrS-0004Qc-Tm for qemu-devel@nongnu.org; Thu, 13 Feb 2020 16:17:26 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-253-0MDr3dVkMb23Zg7k1xjhbA-1; Thu, 13 Feb 2020 16:17:23 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8A7CE800D4C; Thu, 13 Feb 2020 21:17:22 +0000 (UTC) Received: from secure.mitica (ovpn-116-211.ams2.redhat.com [10.36.116.211]) by smtp.corp.redhat.com (Postfix) with ESMTP id A471B387; Thu, 13 Feb 2020 21:17:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581628646; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Us0nJoe5KBmHAkcrF4KCZ7UxmpM4SXgZ47zwVhnZWOA=; b=L0c7U/UXMq7F/OG4FIWiiymv3RRL5PQGfQOr/D5n+d6V4D4HBYBcB81KSB6YvKA0tzDqya 6F8NBkYytEFGyA9hvotzvm6ZT+trRkBdHax/uvyhX87U3mehYBaDg37KrdR64ZxQukMBMN wDrifjd55HxQlOJGRYsadwzpbJ1S5Og= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PATCH v6 2/8] migration: Add support for modules Date: Thu, 13 Feb 2020 22:17:03 +0100 Message-Id: <20200213211709.59065-3-quintela@redhat.com> In-Reply-To: <20200213211709.59065-1-quintela@redhat.com> References: <20200213211709.59065-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: 0MDr3dVkMb23Zg7k1xjhbA-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 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: Fam Zheng , Laurent Vivier , Thomas Huth , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , Juan Quintela , Markus Armbruster , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Paolo Bonzini , =?UTF-8?q?Alex=20Benn=C3=A9e?= , "Dr. David Alan Gilbert" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" So we don't have to compile everything in, or have ifdefs Signed-off-by: Juan Quintela Reviewed-by: Dr. David Alan Gilbert --- include/qemu/module.h | 2 ++ vl.c | 1 + 2 files changed, 3 insertions(+) diff --git a/include/qemu/module.h b/include/qemu/module.h index 65ba596e46..907cb5c0a5 100644 --- a/include/qemu/module.h +++ b/include/qemu/module.h @@ -40,6 +40,7 @@ static void __attribute__((constructor)) do_qemu_init_ ##= function(void) \ #endif =20 typedef enum { + MODULE_INIT_MIGRATION, MODULE_INIT_BLOCK, MODULE_INIT_OPTS, MODULE_INIT_QOM, @@ -56,6 +57,7 @@ typedef enum { #define xen_backend_init(function) module_init(function, \ MODULE_INIT_XEN_BACKEND) #define libqos_init(function) module_init(function, MODULE_INIT_LIBQOS) +#define migration_init(function) module_init(function, MODULE_INIT_MIGRATI= ON) =20 #define block_module_load_one(lib) module_load_one("block-", lib) #define ui_module_load_one(lib) module_load_one("ui-", lib) diff --git a/vl.c b/vl.c index b0ee318f99..11355f6b9a 100644 --- a/vl.c +++ b/vl.c @@ -2899,6 +2899,7 @@ int main(int argc, char **argv, char **envp) qemu_init_exec_dir(argv[0]); =20 module_call_init(MODULE_INIT_QOM); + module_call_init(MODULE_INIT_MIGRATION); =20 qemu_add_opts(&qemu_drive_opts); qemu_add_drive_opts(&qemu_legacy_drive_opts); --=20 2.24.1 From nobody Thu Apr 25 14:38:39 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1581628929676400.02732233531367; Thu, 13 Feb 2020 13:22:09 -0800 (PST) Received: from localhost ([::1]:59284 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j2Lw0-0002ML-AD for importer@patchew.org; Thu, 13 Feb 2020 16:22:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48969) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j2LrZ-0005Sn-Nz for qemu-devel@nongnu.org; Thu, 13 Feb 2020 16:17:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j2LrX-0004hk-NH for qemu-devel@nongnu.org; Thu, 13 Feb 2020 16:17:33 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:50964 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j2LrX-0004cl-GW for qemu-devel@nongnu.org; Thu, 13 Feb 2020 16:17:31 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-352-d5xudeVFNvat4auFT5q4ag-1; Thu, 13 Feb 2020 16:17:26 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C88A818AB2C9; Thu, 13 Feb 2020 21:17:25 +0000 (UTC) Received: from secure.mitica (ovpn-116-211.ams2.redhat.com [10.36.116.211]) by smtp.corp.redhat.com (Postfix) with ESMTP id E114B387; Thu, 13 Feb 2020 21:17:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581628649; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Xc3+uJuusEZyG1DeGoomEoWk0n/cJ7wu7menfoVSmn0=; b=h1VchHuuHRVV5bf9MG+3Q24583kaYl+1dFVkU5aLoTATroy1IjHxMdDdetY2Vbb8CCdioD zyHzMxjNxRDk2G6e/ciddlqAHelgLs5/78Ntirqe+4+uqujeVm+u8meZKr7uxKxCAo/00F EwZWjigObYDTVsIgYC05C1dXHyLLmM4= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PATCH v6 3/8] multifd: Make no compression operations into its own structure Date: Thu, 13 Feb 2020 22:17:04 +0100 Message-Id: <20200213211709.59065-4-quintela@redhat.com> In-Reply-To: <20200213211709.59065-1-quintela@redhat.com> References: <20200213211709.59065-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: d5xudeVFNvat4auFT5q4ag-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.61 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: Fam Zheng , Laurent Vivier , Thomas Huth , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , Juan Quintela , Markus Armbruster , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Paolo Bonzini , =?UTF-8?q?Alex=20Benn=C3=A9e?= , "Dr. David Alan Gilbert" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" It will be used later. Signed-off-by: Juan Quintela Reviewed-by: Dr. David Alan Gilbert --- No comp value needs to be zero. --- migration/migration.c | 9 ++ migration/migration.h | 1 + migration/multifd.c | 185 ++++++++++++++++++++++++++++++++++++++++-- migration/multifd.h | 26 ++++++ migration/ram.c | 1 + 5 files changed, 214 insertions(+), 8 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index bc744d1734..eb7b0a2df0 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -2245,6 +2245,15 @@ int migrate_multifd_channels(void) return s->parameters.multifd_channels; } =20 +MultiFDCompression migrate_multifd_compression(void) +{ + MigrationState *s; + + s =3D migrate_get_current(); + + return s->parameters.multifd_compression; +} + int migrate_use_xbzrle(void) { MigrationState *s; diff --git a/migration/migration.h b/migration/migration.h index 8473ddfc88..59fea02482 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -300,6 +300,7 @@ bool migrate_auto_converge(void); bool migrate_use_multifd(void); bool migrate_pause_before_switchover(void); int migrate_multifd_channels(void); +MultiFDCompression migrate_multifd_compression(void); =20 int migrate_use_xbzrle(void); int64_t migrate_xbzrle_cache_size(void); diff --git a/migration/multifd.c b/migration/multifd.c index b3e8ae9bcc..97433e5135 100644 --- a/migration/multifd.c +++ b/migration/multifd.c @@ -38,6 +38,134 @@ typedef struct { uint64_t unused2[4]; /* Reserved for future use */ } __attribute__((packed)) MultiFDInit_t; =20 +/* Multifd without compression */ + +/** + * nocomp_send_setup: setup send side + * + * For no compression this function does nothing. + * + * Returns 0 for success or -1 for error + * + * @p: Params for the channel that we are using + * @errp: pointer to an error + */ +static int nocomp_send_setup(MultiFDSendParams *p, Error **errp) +{ + return 0; +} + +/** + * nocomp_send_cleanup: cleanup send side + * + * For no compression this function does nothing. + * + * @p: Params for the channel that we are using + */ +static void nocomp_send_cleanup(MultiFDSendParams *p, Error **errp) +{ + return; +} + +/** + * nocomp_send_prepare: prepare date to be able to send + * + * For no compression we just have to calculate the size of the + * packet. + * + * Returns 0 for success or -1 for error + * + * @p: Params for the channel that we are using + * @used: number of pages used + * @errp: pointer to an error + */ +static int nocomp_send_prepare(MultiFDSendParams *p, uint32_t used, + Error **errp) +{ + p->next_packet_size =3D used * qemu_target_page_size(); + p->flags |=3D MULTIFD_FLAG_NOCOMP; + return 0; +} + +/** + * nocomp_send_write: do the actual write of the data + * + * For no compression we just have to write the data. + * + * Returns 0 for success or -1 for error + * + * @p: Params for the channel that we are using + * @used: number of pages used + * @errp: pointer to an error + */ +static int nocomp_send_write(MultiFDSendParams *p, uint32_t used, Error **= errp) +{ + return qio_channel_writev_all(p->c, p->pages->iov, used, errp); +} + +/** + * nocomp_recv_setup: setup receive side + * + * For no compression this function does nothing. + * + * Returns 0 for success or -1 for error + * + * @p: Params for the channel that we are using + * @errp: pointer to an error + */ +static int nocomp_recv_setup(MultiFDRecvParams *p, Error **errp) +{ + return 0; +} + +/** + * nocomp_recv_cleanup: setup receive side + * + * For no compression this function does nothing. + * + * @p: Params for the channel that we are using + */ +static void nocomp_recv_cleanup(MultiFDRecvParams *p) +{ +} + +/** + * nocomp_recv_pages: read the data from the channel into actual pages + * + * For no compression we just need to read things into the correct place. + * + * Returns 0 for success or -1 for error + * + * @p: Params for the channel that we are using + * @used: number of pages used + * @errp: pointer to an error + */ +static int nocomp_recv_pages(MultiFDRecvParams *p, uint32_t used, Error **= errp) +{ + uint32_t flags =3D p->flags & MULTIFD_FLAG_COMPRESSION_MASK; + + if (flags !=3D MULTIFD_FLAG_NOCOMP) { + error_setg(errp, "multifd %d: flags received %x flags expected %x", + p->id, flags, MULTIFD_FLAG_NOCOMP); + return -1; + } + return qio_channel_readv_all(p->c, p->pages->iov, used, errp); +} + +static MultiFDMethods multifd_nocomp_ops =3D { + .send_setup =3D nocomp_send_setup, + .send_cleanup =3D nocomp_send_cleanup, + .send_prepare =3D nocomp_send_prepare, + .send_write =3D nocomp_send_write, + .recv_setup =3D nocomp_recv_setup, + .recv_cleanup =3D nocomp_recv_cleanup, + .recv_pages =3D nocomp_recv_pages +}; + +static MultiFDMethods *multifd_ops[MULTIFD_COMPRESSION__MAX] =3D { + [MULTIFD_COMPRESSION_NONE] =3D &multifd_nocomp_ops, +}; + static int multifd_send_initial_packet(MultiFDSendParams *p, Error **errp) { MultiFDInit_t msg =3D {}; @@ -246,6 +374,8 @@ struct { * We will use atomic operations. Only valid values are 0 and 1. */ int exiting; + /* multifd ops */ + MultiFDMethods *ops; } *multifd_send_state; =20 /* @@ -397,6 +527,7 @@ void multifd_save_cleanup(void) } for (i =3D 0; i < migrate_multifd_channels(); i++) { MultiFDSendParams *p =3D &multifd_send_state->params[i]; + Error *local_err =3D NULL; =20 socket_send_channel_destroy(p->c); p->c =3D NULL; @@ -410,6 +541,10 @@ void multifd_save_cleanup(void) p->packet_len =3D 0; g_free(p->packet); p->packet =3D NULL; + multifd_send_state->ops->send_cleanup(p, &local_err); + if (local_err) { + migrate_set_error(migrate_get_current(), local_err); + } } qemu_sem_destroy(&multifd_send_state->channels_ready); g_free(multifd_send_state->params); @@ -494,7 +629,14 @@ static void *multifd_send_thread(void *opaque) uint64_t packet_num =3D p->packet_num; flags =3D p->flags; =20 - p->next_packet_size =3D used * qemu_target_page_size(); + if (used) { + ret =3D multifd_send_state->ops->send_prepare(p, used, + &local_err); + if (ret !=3D 0) { + qemu_mutex_unlock(&p->mutex); + break; + } + } multifd_send_fill_packet(p); p->flags =3D 0; p->num_packets++; @@ -513,8 +655,7 @@ static void *multifd_send_thread(void *opaque) } =20 if (used) { - ret =3D qio_channel_writev_all(p->c, p->pages->iov, - used, &local_err); + ret =3D multifd_send_state->ops->send_write(p, used, &loca= l_err); if (ret !=3D 0) { break; } @@ -604,6 +745,7 @@ int multifd_save_setup(Error **errp) multifd_send_state->pages =3D multifd_pages_init(page_count); qemu_sem_init(&multifd_send_state->channels_ready, 0); atomic_set(&multifd_send_state->exiting, 0); + multifd_send_state->ops =3D multifd_ops[migrate_multifd_compression()]; =20 for (i =3D 0; i < thread_count; i++) { MultiFDSendParams *p =3D &multifd_send_state->params[i]; @@ -623,6 +765,18 @@ int multifd_save_setup(Error **errp) p->name =3D g_strdup_printf("multifdsend_%d", i); socket_send_channel_create(multifd_new_send_channel_async, p); } + + for (i =3D 0; i < thread_count; i++) { + MultiFDSendParams *p =3D &multifd_send_state->params[i]; + Error *local_err =3D NULL; + int ret; + + ret =3D multifd_send_state->ops->send_setup(p, &local_err); + if (ret) { + error_propagate(errp, local_err); + return ret; + } + } return 0; } =20 @@ -634,6 +788,8 @@ struct { QemuSemaphore sem_sync; /* global number of generated multifd packets */ uint64_t packet_num; + /* multifd ops */ + MultiFDMethods *ops; } *multifd_recv_state; =20 static void multifd_recv_terminate_threads(Error *err) @@ -673,7 +829,6 @@ static void multifd_recv_terminate_threads(Error *err) int multifd_load_cleanup(Error **errp) { int i; - int ret =3D 0; =20 if (!migrate_use_multifd()) { return 0; @@ -706,6 +861,7 @@ int multifd_load_cleanup(Error **errp) p->packet_len =3D 0; g_free(p->packet); p->packet =3D NULL; + multifd_recv_state->ops->recv_cleanup(p); } qemu_sem_destroy(&multifd_recv_state->sem_sync); g_free(multifd_recv_state->params); @@ -713,7 +869,7 @@ int multifd_load_cleanup(Error **errp) g_free(multifd_recv_state); multifd_recv_state =3D NULL; =20 - return ret; + return 0; } =20 void multifd_recv_sync_main(void) @@ -778,6 +934,8 @@ static void *multifd_recv_thread(void *opaque) =20 used =3D p->pages->used; flags =3D p->flags; + /* recv methods don't know how to handle the SYNC flag */ + p->flags &=3D ~MULTIFD_FLAG_SYNC; trace_multifd_recv(p->id, p->packet_num, used, flags, p->next_packet_size); p->num_packets++; @@ -785,8 +943,7 @@ static void *multifd_recv_thread(void *opaque) qemu_mutex_unlock(&p->mutex); =20 if (used) { - ret =3D qio_channel_readv_all(p->c, p->pages->iov, - used, &local_err); + ret =3D multifd_recv_state->ops->recv_pages(p, used, &local_er= r); if (ret !=3D 0) { break; } @@ -825,6 +982,7 @@ int multifd_load_setup(Error **errp) multifd_recv_state->params =3D g_new0(MultiFDRecvParams, thread_count); atomic_set(&multifd_recv_state->count, 0); qemu_sem_init(&multifd_recv_state->sem_sync, 0); + multifd_recv_state->ops =3D multifd_ops[migrate_multifd_compression()]; =20 for (i =3D 0; i < thread_count; i++) { MultiFDRecvParams *p =3D &multifd_recv_state->params[i]; @@ -839,6 +997,18 @@ int multifd_load_setup(Error **errp) p->packet =3D g_malloc0(p->packet_len); p->name =3D g_strdup_printf("multifdrecv_%d", i); } + + for (i =3D 0; i < thread_count; i++) { + MultiFDRecvParams *p =3D &multifd_recv_state->params[i]; + Error *local_err =3D NULL; + int ret; + + ret =3D multifd_recv_state->ops->recv_setup(p, &local_err); + if (ret) { + error_propagate(errp, local_err); + return ret; + } + } return 0; } =20 @@ -896,4 +1066,3 @@ bool multifd_recv_new_channel(QIOChannel *ioc, Error *= *errp) return atomic_read(&multifd_recv_state->count) =3D=3D migrate_multifd_channels(); } - diff --git a/migration/multifd.h b/migration/multifd.h index d8b0205977..54075ffa7d 100644 --- a/migration/multifd.h +++ b/migration/multifd.h @@ -25,6 +25,11 @@ int multifd_queue_page(QEMUFile *f, RAMBlock *block, ram= _addr_t offset); =20 #define MULTIFD_FLAG_SYNC (1 << 0) =20 +/* We reserve 3 bits for compression methods */ +#define MULTIFD_FLAG_COMPRESSION_MASK (7 << 1) +/* we need to be compatible. Before compression value was 0 */ +#define MULTIFD_FLAG_NOCOMP (0 << 1) + /* This value needs to be a multiple of qemu_target_page_size() */ #define MULTIFD_PACKET_SIZE (512 * 1024) =20 @@ -96,6 +101,8 @@ typedef struct { uint64_t num_pages; /* syncs main thread and channels */ QemuSemaphore sem_sync; + /* used for compression methods */ + void *data; } MultiFDSendParams; =20 typedef struct { @@ -133,7 +140,26 @@ typedef struct { uint64_t num_pages; /* syncs main thread and channels */ QemuSemaphore sem_sync; + /* used for de-compression methods */ + void *data; } MultiFDRecvParams; =20 +typedef struct { + /* Setup for sending side */ + int (*send_setup)(MultiFDSendParams *p, Error **errp); + /* Cleanup for sending side */ + void (*send_cleanup)(MultiFDSendParams *p, Error **errp); + /* Prepare the send packet */ + int (*send_prepare)(MultiFDSendParams *p, uint32_t used, Error **errp); + /* Write the send packet */ + int (*send_write)(MultiFDSendParams *p, uint32_t used, Error **errp); + /* Setup for receiving side */ + int (*recv_setup)(MultiFDRecvParams *p, Error **errp); + /* Cleanup for receiving side */ + void (*recv_cleanup)(MultiFDRecvParams *p); + /* Read all pages */ + int (*recv_pages)(MultiFDRecvParams *p, uint32_t used, Error **errp); +} MultiFDMethods; + #endif =20 diff --git a/migration/ram.c b/migration/ram.c index ed23ed1c7c..73a141bb60 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -43,6 +43,7 @@ #include "page_cache.h" #include "qemu/error-report.h" #include "qapi/error.h" +#include "qapi/qapi-types-migration.h" #include "qapi/qapi-events-migration.h" #include "qapi/qmp/qerror.h" #include "trace.h" --=20 2.24.1 From nobody Thu Apr 25 14:38:39 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1581629043073997.9157526855099; Thu, 13 Feb 2020 13:24:03 -0800 (PST) Received: from localhost ([::1]:59308 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j2Lxp-0004ui-S5 for importer@patchew.org; Thu, 13 Feb 2020 16:24:01 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:49034) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j2Lrc-0005W8-4W for qemu-devel@nongnu.org; Thu, 13 Feb 2020 16:17:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j2LrY-0004ll-LI for qemu-devel@nongnu.org; Thu, 13 Feb 2020 16:17:34 -0500 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:28328 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j2LrY-0004iy-FR for qemu-devel@nongnu.org; Thu, 13 Feb 2020 16:17:32 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-125-Sg3bJBYaNhq_P1knx6xpig-1; Thu, 13 Feb 2020 16:17:30 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1580718AB2C2; Thu, 13 Feb 2020 21:17:29 +0000 (UTC) Received: from secure.mitica (ovpn-116-211.ams2.redhat.com [10.36.116.211]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2C9C619C7F; Thu, 13 Feb 2020 21:17:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581628651; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iIHT3SvTaWFi+I8rdHRF85QIE4IroWCRSlWrm42jaDo=; b=BwUQAoDRQhjtPQgwGqZ7TAE6Xdi6DIr63FG5UNX7wER7or/O+AT2UKjFQ6p+Ojg49RG1dg /gUXy1c7euKr7PQ08UQ+790UyP7iG9M7xrgydf6ryVJFDUxApPIFPJfzVhZZbVJaMZcwQs VKy5l3lWnCgdUl6uZZxmfr/x83Liq2A= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PATCH v6 4/8] multifd: Add multifd-zlib-level parameter Date: Thu, 13 Feb 2020 22:17:05 +0100 Message-Id: <20200213211709.59065-5-quintela@redhat.com> In-Reply-To: <20200213211709.59065-1-quintela@redhat.com> References: <20200213211709.59065-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: Sg3bJBYaNhq_P1knx6xpig-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 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: Fam Zheng , Laurent Vivier , Thomas Huth , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , Juan Quintela , Markus Armbruster , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Paolo Bonzini , =?UTF-8?q?Alex=20Benn=C3=A9e?= , "Dr. David Alan Gilbert" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" This parameter specifies the zlib compression level. The next patch will put it to use. Signed-off-by: Juan Quintela Acked-by: Markus Armbruster Reviewed-by: Dr. David Alan Gilbert --- migration/migration.c | 24 ++++++++++++++++++++++++ migration/migration.h | 1 + monitor/hmp-cmds.c | 4 ++++ qapi/migration.json | 30 +++++++++++++++++++++++++++--- 4 files changed, 56 insertions(+), 3 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index eb7b0a2df0..a09726f679 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -89,6 +89,8 @@ #define DEFAULT_MIGRATE_X_CHECKPOINT_DELAY (200 * 100) #define DEFAULT_MIGRATE_MULTIFD_CHANNELS 2 #define DEFAULT_MIGRATE_MULTIFD_COMPRESSION MULTIFD_COMPRESSION_NONE +/* 0: means nocompress, 1: best speed, ... 9: best compress ratio */ +#define DEFAULT_MIGRATE_MULTIFD_ZLIB_LEVEL 1 =20 /* Background transfer rate for postcopy, 0 means unlimited, note * that page requests can still exceed this limit. @@ -801,6 +803,8 @@ MigrationParameters *qmp_query_migrate_parameters(Error= **errp) params->multifd_channels =3D s->parameters.multifd_channels; params->has_multifd_compression =3D true; params->multifd_compression =3D s->parameters.multifd_compression; + params->has_multifd_zlib_level =3D true; + params->multifd_zlib_level =3D s->parameters.multifd_zlib_level; params->has_xbzrle_cache_size =3D true; params->xbzrle_cache_size =3D s->parameters.xbzrle_cache_size; params->has_max_postcopy_bandwidth =3D true; @@ -1208,6 +1212,13 @@ static bool migrate_params_check(MigrationParameters= *params, Error **errp) return false; } =20 + if (params->has_multifd_zlib_level && + (params->multifd_zlib_level > 9)) { + error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "multifd_zlib_level= ", + "is invalid, it should be in the range of 0 to 9"); + return false; + } + if (params->has_xbzrle_cache_size && (params->xbzrle_cache_size < qemu_target_page_size() || !is_power_of_2(params->xbzrle_cache_size))) { @@ -2254,6 +2265,15 @@ MultiFDCompression migrate_multifd_compression(void) return s->parameters.multifd_compression; } =20 +int migrate_multifd_zlib_level(void) +{ + MigrationState *s; + + s =3D migrate_get_current(); + + return s->parameters.multifd_zlib_level; +} + int migrate_use_xbzrle(void) { MigrationState *s; @@ -3544,6 +3564,9 @@ static Property migration_properties[] =3D { DEFINE_PROP_MULTIFD_COMPRESSION("multifd-compression", MigrationState, parameters.multifd_compression, DEFAULT_MIGRATE_MULTIFD_COMPRESSION), + DEFINE_PROP_UINT8("multifd-zlib-level", MigrationState, + parameters.multifd_zlib_level, + DEFAULT_MIGRATE_MULTIFD_ZLIB_LEVEL), DEFINE_PROP_SIZE("xbzrle-cache-size", MigrationState, parameters.xbzrle_cache_size, DEFAULT_MIGRATE_XBZRLE_CACHE_SIZE), @@ -3635,6 +3658,7 @@ static void migration_instance_init(Object *obj) params->has_block_incremental =3D true; params->has_multifd_channels =3D true; params->has_multifd_compression =3D true; + params->has_multifd_zlib_level =3D true; params->has_xbzrle_cache_size =3D true; params->has_max_postcopy_bandwidth =3D true; params->has_max_cpu_throttle =3D true; diff --git a/migration/migration.h b/migration/migration.h index 59fea02482..c363ef9334 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -301,6 +301,7 @@ bool migrate_use_multifd(void); bool migrate_pause_before_switchover(void); int migrate_multifd_channels(void); MultiFDCompression migrate_multifd_compression(void); +int migrate_multifd_zlib_level(void); =20 int migrate_use_xbzrle(void); int64_t migrate_xbzrle_cache_size(void); diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index 40525b5e95..8a39dff589 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -1836,6 +1836,10 @@ void hmp_migrate_set_parameter(Monitor *mon, const Q= Dict *qdict) } p->multifd_compression =3D compress_type; break; + case MIGRATION_PARAMETER_MULTIFD_ZLIB_LEVEL: + p->has_multifd_zlib_level =3D true; + visit_type_int(v, param, &p->multifd_zlib_level, &err); + break; case MIGRATION_PARAMETER_XBZRLE_CACHE_SIZE: p->has_xbzrle_cache_size =3D true; visit_type_size(v, param, &cache_size, &err); diff --git a/qapi/migration.json b/qapi/migration.json index 28593e2a2c..0845d926f2 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -602,6 +602,13 @@ # @multifd-compression: Which compression method to use. # Defaults to none. (Since 5.0) # +# @multifd-zlib-level: Set the compression level to be used in live +# migration, the compression level is an integer between 0 +# and 9, where 0 means no compression, 1 means the best +# compression speed, and 9 means best compression ratio which +# will consume more CPU. +# Defaults to 1. (Since 5.0) +# # Since: 2.4 ## { 'enum': 'MigrationParameter', @@ -614,7 +621,8 @@ 'downtime-limit', 'x-checkpoint-delay', 'block-incremental', 'multifd-channels', 'xbzrle-cache-size', 'max-postcopy-bandwidth', - 'max-cpu-throttle', 'multifd-compression' ] } + 'max-cpu-throttle', 'multifd-compression', + 'multifd-zlib-level' ] } =20 ## # @MigrateSetParameters: @@ -707,6 +715,13 @@ # @multifd-compression: Which compression method to use. # Defaults to none. (Since 5.0) # +# @multifd-zlib-level: Set the compression level to be used in live +# migration, the compression level is an integer between 0 +# and 9, where 0 means no compression, 1 means the best +# compression speed, and 9 means best compression ratio which +# will consume more CPU. +# Defaults to 1. (Since 5.0) +# # Since: 2.4 ## # TODO either fuse back into MigrationParameters, or make @@ -733,7 +748,8 @@ '*xbzrle-cache-size': 'size', '*max-postcopy-bandwidth': 'size', '*max-cpu-throttle': 'int', - '*multifd-compression': 'MultiFDCompression' } } + '*multifd-compression': 'MultiFDCompression', + '*multifd-zlib-level': 'int' } } =20 ## # @migrate-set-parameters: @@ -846,6 +862,13 @@ # @multifd-compression: Which compression method to use. # Defaults to none. (Since 5.0) # +# @multifd-zlib-level: Set the compression level to be used in live +# migration, the compression level is an integer between 0 +# and 9, where 0 means no compression, 1 means the best +# compression speed, and 9 means best compression ratio which +# will consume more CPU. +# Defaults to 1. (Since 5.0) +# # Since: 2.4 ## { 'struct': 'MigrationParameters', @@ -870,7 +893,8 @@ '*xbzrle-cache-size': 'size', '*max-postcopy-bandwidth': 'size', '*max-cpu-throttle': 'uint8', - '*multifd-compression': 'MultiFDCompression' } } + '*multifd-compression': 'MultiFDCompression', + '*multifd-zlib-level': 'uint8' } } =20 ## # @query-migrate-parameters: --=20 2.24.1 From nobody Thu Apr 25 14:38:39 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 158162935368554.9598957467573; Thu, 13 Feb 2020 13:29:13 -0800 (PST) Received: from localhost ([::1]:59410 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j2M2q-00017H-4v for importer@patchew.org; Thu, 13 Feb 2020 16:29:12 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:49500) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j2Lrt-0005q5-SZ for qemu-devel@nongnu.org; Thu, 13 Feb 2020 16:17:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j2Lrq-0005FO-EE for qemu-devel@nongnu.org; Thu, 13 Feb 2020 16:17:52 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:47383 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j2Lrq-00057r-2R for qemu-devel@nongnu.org; Thu, 13 Feb 2020 16:17:50 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-18-fh0h9WoBPUmTcUS0z9bbuw-1; Thu, 13 Feb 2020 16:17:35 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E61D9DB2D; Thu, 13 Feb 2020 21:17:34 +0000 (UTC) Received: from secure.mitica (ovpn-116-211.ams2.redhat.com [10.36.116.211]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6BFE819C7F; Thu, 13 Feb 2020 21:17:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581628661; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5JRg/qZ6cMLZmgi87lpKIpS7xbo8Kjm1Xi5Wiy0LDQw=; b=LUW2xoSjKQTjt1fRc++Ge4nx8QFnqev2zdjTtJm+/7FdEEYubgyyGngQWV+UCZOnf1Gopg Q+kVo/kPQikkwLpAHCZoJHCeWWBlx6d27RS3xivh+3WXPpclcYzmdxMIRkiSiYp8+Fc8u8 2iaGs8/MfXB4XF1tYDVN75QSkjSw8kk= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PATCH v6 5/8] multifd: Add zlib compression multifd support Date: Thu, 13 Feb 2020 22:17:06 +0100 Message-Id: <20200213211709.59065-6-quintela@redhat.com> In-Reply-To: <20200213211709.59065-1-quintela@redhat.com> References: <20200213211709.59065-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: fh0h9WoBPUmTcUS0z9bbuw-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.120 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: Fam Zheng , Laurent Vivier , Thomas Huth , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , Juan Quintela , Markus Armbruster , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Paolo Bonzini , =?UTF-8?q?Alex=20Benn=C3=A9e?= , "Dr. David Alan Gilbert" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Signed-off-by: Juan Quintela Acked-by: Markus Armbruster Reviewed-by: Dr. David Alan Gilbert --- hw/core/qdev-properties.c | 2 +- migration/Makefile.objs | 1 + migration/multifd-zlib.c | 325 +++++++++++++++++++++++++++++++++++ migration/multifd.c | 6 + migration/multifd.h | 4 + qapi/migration.json | 3 +- tests/qtest/migration-test.c | 6 + 7 files changed, 345 insertions(+), 2 deletions(-) create mode 100644 migration/multifd-zlib.c diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c index fa7edac020..db2a7abfb2 100644 --- a/hw/core/qdev-properties.c +++ b/hw/core/qdev-properties.c @@ -645,7 +645,7 @@ const PropertyInfo qdev_prop_fdc_drive_type =3D { const PropertyInfo qdev_prop_multifd_compression =3D { .name =3D "MultiFDCompression", .description =3D "multifd_compression values, " - "none", + "none/zlib", .enum_table =3D &MultiFDCompression_lookup, .get =3D get_enum, .set =3D set_enum, diff --git a/migration/Makefile.objs b/migration/Makefile.objs index d3623d5f9b..0308caa5c5 100644 --- a/migration/Makefile.objs +++ b/migration/Makefile.objs @@ -8,6 +8,7 @@ common-obj-y +=3D xbzrle.o postcopy-ram.o common-obj-y +=3D qjson.o common-obj-y +=3D block-dirty-bitmap.o common-obj-y +=3D multifd.o +common-obj-y +=3D multifd-zlib.o =20 common-obj-$(CONFIG_RDMA) +=3D rdma.o =20 diff --git a/migration/multifd-zlib.c b/migration/multifd-zlib.c new file mode 100644 index 0000000000..ab4ba75d75 --- /dev/null +++ b/migration/multifd-zlib.c @@ -0,0 +1,325 @@ +/* + * Multifd zlib compression implementation + * + * Copyright (c) 2020 Red Hat Inc + * + * Authors: + * Juan Quintela + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include +#include "qemu/rcu.h" +#include "exec/target_page.h" +#include "qapi/error.h" +#include "migration.h" +#include "trace.h" +#include "multifd.h" + +struct zlib_data { + /* stream for compression */ + z_stream zs; + /* compressed buffer */ + uint8_t *zbuff; + /* size of compressed buffer */ + uint32_t zbuff_len; +}; + +/* Multifd zlib compression */ + +/** + * zlib_send_setup: setup send side + * + * Setup each channel with zlib compression. + * + * Returns 0 for success or -1 for error + * + * @p: Params for the channel that we are using + * @errp: pointer to an error + */ +static int zlib_send_setup(MultiFDSendParams *p, Error **errp) +{ + uint32_t page_count =3D MULTIFD_PACKET_SIZE / qemu_target_page_size(); + struct zlib_data *z =3D g_malloc0(sizeof(struct zlib_data)); + z_stream *zs =3D &z->zs; + + zs->zalloc =3D Z_NULL; + zs->zfree =3D Z_NULL; + zs->opaque =3D Z_NULL; + if (deflateInit(zs, migrate_multifd_zlib_level()) !=3D Z_OK) { + g_free(z); + error_setg(errp, "multifd %d: deflate init failed", p->id); + return -1; + } + /* We will never have more than page_count pages */ + z->zbuff_len =3D page_count * qemu_target_page_size(); + z->zbuff_len *=3D 2; + z->zbuff =3D g_try_malloc(z->zbuff_len); + if (!z->zbuff) { + deflateEnd(&z->zs); + g_free(z); + error_setg(errp, "multifd %d: out of memory for zbuff", p->id); + return -1; + } + p->data =3D z; + return 0; +} + +/** + * zlib_send_cleanup: cleanup send side + * + * Close the channel and return memory. + * + * @p: Params for the channel that we are using + */ +static void zlib_send_cleanup(MultiFDSendParams *p, Error **errp) +{ + struct zlib_data *z =3D p->data; + + deflateEnd(&z->zs); + g_free(z->zbuff); + z->zbuff =3D NULL; + g_free(p->data); + p->data =3D NULL; +} + +/** + * zlib_send_prepare: prepare date to be able to send + * + * Create a compressed buffer with all the pages that we are going to + * send. + * + * Returns 0 for success or -1 for error + * + * @p: Params for the channel that we are using + * @used: number of pages used + */ +static int zlib_send_prepare(MultiFDSendParams *p, uint32_t used, Error **= errp) +{ + struct iovec *iov =3D p->pages->iov; + struct zlib_data *z =3D p->data; + z_stream *zs =3D &z->zs; + uint32_t out_size =3D 0; + int ret; + uint32_t i; + + for (i =3D 0; i < used; i++) { + uint32_t available =3D z->zbuff_len - out_size; + int flush =3D Z_NO_FLUSH; + + if (i =3D=3D used - 1) { + flush =3D Z_SYNC_FLUSH; + } + + zs->avail_in =3D iov[i].iov_len; + zs->next_in =3D iov[i].iov_base; + + zs->avail_out =3D available; + zs->next_out =3D z->zbuff + out_size; + + /* + * Welcome to deflate semantics + * + * We need to loop while: + * - return is Z_OK + * - there are stuff to be compressed + * - there are output space free + */ + do { + ret =3D deflate(zs, flush); + } while (ret =3D=3D Z_OK && zs->avail_in && zs->avail_out); + if (ret =3D=3D Z_OK && zs->avail_in) { + error_setg(errp, "multifd %d: deflate failed to compress all i= nput", + p->id); + return -1; + } + if (ret !=3D Z_OK) { + error_setg(errp, "multifd %d: deflate returned %d instead of Z= _OK", + p->id, ret); + return -1; + } + out_size +=3D available - zs->avail_out; + } + p->next_packet_size =3D out_size; + p->flags |=3D MULTIFD_FLAG_ZLIB; + + return 0; +} + +/** + * zlib_send_write: do the actual write of the data + * + * Do the actual write of the comprresed buffer. + * + * Returns 0 for success or -1 for error + * + * @p: Params for the channel that we are using + * @used: number of pages used + * @errp: pointer to an error + */ +static int zlib_send_write(MultiFDSendParams *p, uint32_t used, Error **er= rp) +{ + struct zlib_data *z =3D p->data; + + return qio_channel_write_all(p->c, (void *)z->zbuff, p->next_packet_si= ze, + errp); +} + +/** + * zlib_recv_setup: setup receive side + * + * Create the compressed channel and buffer. + * + * Returns 0 for success or -1 for error + * + * @p: Params for the channel that we are using + * @errp: pointer to an error + */ +static int zlib_recv_setup(MultiFDRecvParams *p, Error **errp) +{ + uint32_t page_count =3D MULTIFD_PACKET_SIZE / qemu_target_page_size(); + struct zlib_data *z =3D g_malloc0(sizeof(struct zlib_data)); + z_stream *zs =3D &z->zs; + + p->data =3D z; + zs->zalloc =3D Z_NULL; + zs->zfree =3D Z_NULL; + zs->opaque =3D Z_NULL; + zs->avail_in =3D 0; + zs->next_in =3D Z_NULL; + if (inflateInit(zs) !=3D Z_OK) { + error_setg(errp, "multifd %d: inflate init failed", p->id); + return -1; + } + /* We will never have more than page_count pages */ + z->zbuff_len =3D page_count * qemu_target_page_size(); + /* We know compression "could" use more space */ + z->zbuff_len *=3D 2; + z->zbuff =3D g_try_malloc(z->zbuff_len); + if (!z->zbuff) { + inflateEnd(zs); + error_setg(errp, "multifd %d: out of memory for zbuff", p->id); + return -1; + } + return 0; +} + +/** + * zlib_recv_cleanup: setup receive side + * + * For no compression this function does nothing. + * + * @p: Params for the channel that we are using + */ +static void zlib_recv_cleanup(MultiFDRecvParams *p) +{ + struct zlib_data *z =3D p->data; + + inflateEnd(&z->zs); + g_free(z->zbuff); + z->zbuff =3D NULL; + g_free(p->data); + p->data =3D NULL; +} + +/** + * zlib_recv_pages: read the data from the channel into actual pages + * + * Read the compressed buffer, and uncompress it into the actual + * pages. + * + * Returns 0 for success or -1 for error + * + * @p: Params for the channel that we are using + * @used: number of pages used + * @errp: pointer to an error + */ +static int zlib_recv_pages(MultiFDRecvParams *p, uint32_t used, Error **er= rp) +{ + struct zlib_data *z =3D p->data; + z_stream *zs =3D &z->zs; + uint32_t in_size =3D p->next_packet_size; + /* we measure the change of total_out */ + uint32_t out_size =3D zs->total_out; + uint32_t expected_size =3D used * qemu_target_page_size(); + uint32_t flags =3D p->flags & MULTIFD_FLAG_COMPRESSION_MASK; + int ret; + int i; + + if (flags !=3D MULTIFD_FLAG_ZLIB) { + error_setg(errp, "multifd %d: flags received %x flags expected %x", + p->id, flags, MULTIFD_FLAG_ZLIB); + return -1; + } + ret =3D qio_channel_read_all(p->c, (void *)z->zbuff, in_size, errp); + + if (ret !=3D 0) { + return ret; + } + + zs->avail_in =3D in_size; + zs->next_in =3D z->zbuff; + + for (i =3D 0; i < used; i++) { + struct iovec *iov =3D &p->pages->iov[i]; + int flush =3D Z_NO_FLUSH; + unsigned long start =3D zs->total_out; + + if (i =3D=3D used - 1) { + flush =3D Z_SYNC_FLUSH; + } + + zs->avail_out =3D iov->iov_len; + zs->next_out =3D iov->iov_base; + + /* + * Welcome to inflate semantics + * + * We need to loop while: + * - return is Z_OK + * - there are input available + * - we haven't completed a full page + */ + do { + ret =3D inflate(zs, flush); + } while (ret =3D=3D Z_OK && zs->avail_in + && (zs->total_out - start) < iov->iov_len); + if (ret =3D=3D Z_OK && (zs->total_out - start) < iov->iov_len) { + error_setg(errp, "multifd %d: inflate generated too few output= ", + p->id); + return -1; + } + if (ret !=3D Z_OK) { + error_setg(errp, "multifd %d: inflate returned %d instead of Z= _OK", + p->id, ret); + return -1; + } + } + out_size =3D zs->total_out - out_size; + if (out_size !=3D expected_size) { + error_setg(errp, "multifd %d: packet size received %d size expecte= d %d", + p->id, out_size, expected_size); + return -1; + } + return 0; +} + +static MultiFDMethods multifd_zlib_ops =3D { + .send_setup =3D zlib_send_setup, + .send_cleanup =3D zlib_send_cleanup, + .send_prepare =3D zlib_send_prepare, + .send_write =3D zlib_send_write, + .recv_setup =3D zlib_recv_setup, + .recv_cleanup =3D zlib_recv_cleanup, + .recv_pages =3D zlib_recv_pages +}; + +static void multifd_zlib_register(void) +{ + multifd_register_ops(MULTIFD_COMPRESSION_ZLIB, &multifd_zlib_ops); +} + +migration_init(multifd_zlib_register); diff --git a/migration/multifd.c b/migration/multifd.c index 97433e5135..cb6a4a3ab8 100644 --- a/migration/multifd.c +++ b/migration/multifd.c @@ -166,6 +166,12 @@ static MultiFDMethods *multifd_ops[MULTIFD_COMPRESSION= __MAX] =3D { [MULTIFD_COMPRESSION_NONE] =3D &multifd_nocomp_ops, }; =20 +void multifd_register_ops(int method, MultiFDMethods *ops) +{ + assert(0 < method && method < MULTIFD_COMPRESSION__MAX); + multifd_ops[method] =3D ops; +} + static int multifd_send_initial_packet(MultiFDSendParams *p, Error **errp) { MultiFDInit_t msg =3D {}; diff --git a/migration/multifd.h b/migration/multifd.h index 54075ffa7d..c6dad7b990 100644 --- a/migration/multifd.h +++ b/migration/multifd.h @@ -23,12 +23,14 @@ void multifd_recv_sync_main(void); void multifd_send_sync_main(QEMUFile *f); int multifd_queue_page(QEMUFile *f, RAMBlock *block, ram_addr_t offset); =20 +/* Multifd Compression flags */ #define MULTIFD_FLAG_SYNC (1 << 0) =20 /* We reserve 3 bits for compression methods */ #define MULTIFD_FLAG_COMPRESSION_MASK (7 << 1) /* we need to be compatible. Before compression value was 0 */ #define MULTIFD_FLAG_NOCOMP (0 << 1) +#define MULTIFD_FLAG_ZLIB (1 << 1) =20 /* This value needs to be a multiple of qemu_target_page_size() */ #define MULTIFD_PACKET_SIZE (512 * 1024) @@ -161,5 +163,7 @@ typedef struct { int (*recv_pages)(MultiFDRecvParams *p, uint32_t used, Error **errp); } MultiFDMethods; =20 +void multifd_register_ops(int method, MultiFDMethods *ops); + #endif =20 diff --git a/qapi/migration.json b/qapi/migration.json index 0845d926f2..860609231b 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -494,12 +494,13 @@ # An enumeration of multifd compression methods. # # @none: no compression. +# @zlib: use zlib compression method. # # Since: 5.0 # ## { 'enum': 'MultiFDCompression', - 'data': [ 'none' ] } + 'data': [ 'none', 'zlib' ] } =20 ## # @MigrationParameter: diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index f84c157285..90c26e879f 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -1323,6 +1323,11 @@ static void test_multifd_tcp_none(void) test_multifd_tcp("none"); } =20 +static void test_multifd_tcp_zlib(void) +{ + test_multifd_tcp("zlib"); +} + /* * This test does: * source target @@ -1486,6 +1491,7 @@ int main(int argc, char **argv) qtest_add_func("/migration/auto_converge", test_migrate_auto_converge); qtest_add_func("/migration/multifd/tcp/none", test_multifd_tcp_none); qtest_add_func("/migration/multifd/tcp/cancel", test_multifd_tcp_cance= l); + qtest_add_func("/migration/multifd/tcp/zlib", test_multifd_tcp_zlib); =20 ret =3D g_test_run(); =20 --=20 2.24.1 From nobody Thu Apr 25 14:38:39 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1581629126941452.2015315693707; Thu, 13 Feb 2020 13:25:26 -0800 (PST) Received: from localhost ([::1]:59320 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j2LzA-0006O2-VM for importer@patchew.org; Thu, 13 Feb 2020 16:25:24 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:49527) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j2Lrt-0005qp-9a for qemu-devel@nongnu.org; Thu, 13 Feb 2020 16:17:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j2Lrr-0005JA-BZ for qemu-devel@nongnu.org; Thu, 13 Feb 2020 16:17:53 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:32605 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j2Lrr-00057z-0k for qemu-devel@nongnu.org; Thu, 13 Feb 2020 16:17:51 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-105-CpL_zaxbOfCgDNuzQzgrwQ-1; Thu, 13 Feb 2020 16:17:41 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 572A18010E0; Thu, 13 Feb 2020 21:17:40 +0000 (UTC) Received: from secure.mitica (ovpn-116-211.ams2.redhat.com [10.36.116.211]) by smtp.corp.redhat.com (Postfix) with ESMTP id 47C1E19C7F; Thu, 13 Feb 2020 21:17:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581628663; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=uJ/eSWjGNhISR5g6kmChiKPuaISz4a9Rb5fPQgWh9vg=; b=LEGgLIzzbNf29WjKyTH+pKgxNPsDlmA30TkGydg+UtD5wU2BpyDTg9vwY+QFrvEB6EKKPn Ss8q4g1hPsHbFGMYfQyKgmchlwudz2fTHZIBvLXhxDnTtnRIZTmbpZ759FQ51rwoRkODR8 N+dgWAjeeVBoHfK1MpxUUjIwn3zyR7g= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PATCH v6 6/8] configure: Enable test and libs for zstd Date: Thu, 13 Feb 2020 22:17:07 +0100 Message-Id: <20200213211709.59065-7-quintela@redhat.com> In-Reply-To: <20200213211709.59065-1-quintela@redhat.com> References: <20200213211709.59065-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: CpL_zaxbOfCgDNuzQzgrwQ-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 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: Fam Zheng , Laurent Vivier , Thomas Huth , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , Juan Quintela , Markus Armbruster , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Paolo Bonzini , =?UTF-8?q?Alex=20Benn=C3=A9e?= , "Dr. David Alan Gilbert" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Add it to several build systems to make testing good. Signed-off-by: Juan Quintela Reviewed-by: Dr. David Alan Gilbert --- .gitlab-ci.yml | 1 + .travis.yml | 1 + configure | 30 +++++++++++++++++++ tests/docker/dockerfiles/centos7.docker | 3 +- .../dockerfiles/fedora-i386-cross.docker | 3 +- tests/docker/dockerfiles/fedora.docker | 3 +- tests/docker/dockerfiles/ubuntu.docker | 1 + tests/docker/dockerfiles/ubuntu1804.docker | 1 + tests/vm/fedora | 5 +++- tests/vm/freebsd | 3 ++ tests/vm/netbsd | 3 ++ tests/vm/openbsd | 3 ++ 12 files changed, 53 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c15e394f09..72f8b8aa51 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -21,6 +21,7 @@ build-system2: script: - apt-get install -y -qq libsdl2-dev libgcrypt-dev libbrlapi-dev libaio-d= ev libfdt-dev liblzo2-dev librdmacm-dev libibverbs-dev libibumad-dev + libzstd-dev - mkdir build - cd build - ../configure --enable-werror --target-list=3D"tricore-softmmu unicore32= -softmmu diff --git a/.travis.yml b/.travis.yml index 5887055951..dd17301f3b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -48,6 +48,7 @@ addons: - libusb-1.0-0-dev - libvdeplug-dev - libvte-2.91-dev + - libzstd-dev - sparse - uuid-dev - gcovr diff --git a/configure b/configure index 16f94cd96b..e6c12faef4 100755 --- a/configure +++ b/configure @@ -449,6 +449,7 @@ lzo=3D"" snappy=3D"" bzip2=3D"" lzfse=3D"" +zstd=3D"" guest_agent=3D"" guest_agent_with_vss=3D"no" guest_agent_ntddscsi=3D"no" @@ -1348,6 +1349,10 @@ for opt do ;; --disable-lzfse) lzfse=3D"no" ;; + --disable-zstd) zstd=3D"no" + ;; + --enable-zstd) zstd=3D"yes" + ;; --enable-guest-agent) guest_agent=3D"yes" ;; --disable-guest-agent) guest_agent=3D"no" @@ -1801,6 +1806,8 @@ disabled with --disable-FEATURE, default is enabled i= f available: (for reading bzip2-compressed dmg images) lzfse support of lzfse compression library (for reading lzfse-compressed dmg images) + zstd support for zstd compression library + (for migration compression) seccomp seccomp support coroutine-pool coroutine freelist (better performance) glusterfs GlusterFS backend @@ -2415,6 +2422,24 @@ EOF fi fi =20 +########################################## +# zstd check + +if test "$zstd" !=3D "no" ; then + if $pkg_config --exist libzstd ; then + zstd_cflags=3D"$($pkg_config --cflags libzstd)" + zstd_libs=3D"$($pkg_config --libs libzstd)" + LIBS=3D"$zstd_libs $LIBS" + QEMU_CFLAGS=3D"$QEMU_CFLAGS $zstd_cflags" + zstd=3D"yes" + else + if test "$zstd" =3D "yes" ; then + feature_not_found "libzstd" "Install libzstd devel" + fi + zstd=3D"no" + fi +fi + ########################################## # libseccomp check =20 @@ -6600,6 +6625,7 @@ echo "lzo support $lzo" echo "snappy support $snappy" echo "bzip2 support $bzip2" echo "lzfse support $lzfse" +echo "zstd support $zstd" echo "NUMA host support $numa" echo "libxml2 $libxml2" echo "tcmalloc support $tcmalloc" @@ -7173,6 +7199,10 @@ if test "$lzfse" =3D "yes" ; then echo "LZFSE_LIBS=3D-llzfse" >> $config_host_mak fi =20 +if test "$zstd" =3D "yes" ; then + echo "CONFIG_ZSTD=3Dy" >> $config_host_mak +fi + if test "$libiscsi" =3D "yes" ; then echo "CONFIG_LIBISCSI=3Dm" >> $config_host_mak echo "LIBISCSI_CFLAGS=3D$libiscsi_cflags" >> $config_host_mak diff --git a/tests/docker/dockerfiles/centos7.docker b/tests/docker/dockerf= iles/centos7.docker index 562d65be9e..cdd72de7eb 100644 --- a/tests/docker/dockerfiles/centos7.docker +++ b/tests/docker/dockerfiles/centos7.docker @@ -33,6 +33,7 @@ ENV PACKAGES \ tar \ vte-devel \ xen-devel \ - zlib-devel + zlib-devel \ + libzstd-devel RUN yum install -y $PACKAGES RUN rpm -q $PACKAGES | sort > /packages.txt diff --git a/tests/docker/dockerfiles/fedora-i386-cross.docker b/tests/dock= er/dockerfiles/fedora-i386-cross.docker index 9106cf9ebe..cd16cd1bfa 100644 --- a/tests/docker/dockerfiles/fedora-i386-cross.docker +++ b/tests/docker/dockerfiles/fedora-i386-cross.docker @@ -7,7 +7,8 @@ ENV PACKAGES \ gnutls-devel.i686 \ nettle-devel.i686 \ pixman-devel.i686 \ - zlib-devel.i686 + zlib-devel.i686 \ + libzstd-devel.i686 =20 RUN dnf install -y $PACKAGES RUN rpm -q $PACKAGES | sort > /packages.txt diff --git a/tests/docker/dockerfiles/fedora.docker b/tests/docker/dockerfi= les/fedora.docker index 987a3c170a..a6522228c0 100644 --- a/tests/docker/dockerfiles/fedora.docker +++ b/tests/docker/dockerfiles/fedora.docker @@ -92,7 +92,8 @@ ENV PACKAGES \ vte291-devel \ which \ xen-devel \ - zlib-devel + zlib-devel \ + libzstd-devel ENV QEMU_CONFIGURE_OPTS --python=3D/usr/bin/python3 =20 RUN dnf install -y $PACKAGES diff --git a/tests/docker/dockerfiles/ubuntu.docker b/tests/docker/dockerfi= les/ubuntu.docker index 4177f33691..b6c7b41ddd 100644 --- a/tests/docker/dockerfiles/ubuntu.docker +++ b/tests/docker/dockerfiles/ubuntu.docker @@ -58,6 +58,7 @@ ENV PACKAGES flex bison \ libvdeplug-dev \ libvte-2.91-dev \ libxen-dev \ + libzstd-dev \ make \ python3-yaml \ python3-sphinx \ diff --git a/tests/docker/dockerfiles/ubuntu1804.docker b/tests/docker/dock= erfiles/ubuntu1804.docker index 0766f94cf4..1efedeef99 100644 --- a/tests/docker/dockerfiles/ubuntu1804.docker +++ b/tests/docker/dockerfiles/ubuntu1804.docker @@ -44,6 +44,7 @@ ENV PACKAGES flex bison \ libvdeplug-dev \ libvte-2.91-dev \ libxen-dev \ + libzstd-dev \ make \ python3-yaml \ python3-sphinx \ diff --git a/tests/vm/fedora b/tests/vm/fedora index 4d7d6049f4..4843b4175e 100755 --- a/tests/vm/fedora +++ b/tests/vm/fedora @@ -53,7 +53,10 @@ class FedoraVM(basevm.BaseVM): # libs: audio '"pkgconfig(libpulse)"', '"pkgconfig(alsa)"', - ] + + # libs: migration + '"pkgconfig(libzstd)"', +] =20 BUILD_SCRIPT =3D """ set -e; diff --git a/tests/vm/freebsd b/tests/vm/freebsd index fb54334696..86770878b6 100755 --- a/tests/vm/freebsd +++ b/tests/vm/freebsd @@ -55,6 +55,9 @@ class FreeBSDVM(basevm.BaseVM): # libs: opengl "libepoxy", "mesa-libs", + + # libs: migration + "zstd", ] =20 BUILD_SCRIPT =3D """ diff --git a/tests/vm/netbsd b/tests/vm/netbsd index c5069a45f4..55590f4601 100755 --- a/tests/vm/netbsd +++ b/tests/vm/netbsd @@ -49,6 +49,9 @@ class NetBSDVM(basevm.BaseVM): "SDL2", "gtk3+", "libxkbcommon", + + # libs: migration + "zstd", ] =20 BUILD_SCRIPT =3D """ diff --git a/tests/vm/openbsd b/tests/vm/openbsd index 22cd9513dd..ab6abbedab 100755 --- a/tests/vm/openbsd +++ b/tests/vm/openbsd @@ -51,6 +51,9 @@ class OpenBSDVM(basevm.BaseVM): "sdl2", "gtk+3", "libxkbcommon", + + # libs: migration + "zstd", ] =20 BUILD_SCRIPT =3D """ --=20 2.24.1 From nobody Thu Apr 25 14:38:39 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1581629022911954.493024385903; Thu, 13 Feb 2020 13:23:42 -0800 (PST) Received: from localhost ([::1]:59304 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j2LxV-0004XM-PN for importer@patchew.org; Thu, 13 Feb 2020 16:23:41 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:49514) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j2Lrt-0005qd-4n for qemu-devel@nongnu.org; Thu, 13 Feb 2020 16:17:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j2Lrq-0005FB-DC for qemu-devel@nongnu.org; Thu, 13 Feb 2020 16:17:53 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:35482 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j2Lrq-00058w-2W for qemu-devel@nongnu.org; Thu, 13 Feb 2020 16:17:50 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-136-sJ_0sV0wOUOZ8Rr5OqXDxA-1; Thu, 13 Feb 2020 16:17:44 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9681DDB21; Thu, 13 Feb 2020 21:17:43 +0000 (UTC) Received: from secure.mitica (ovpn-116-211.ams2.redhat.com [10.36.116.211]) by smtp.corp.redhat.com (Postfix) with ESMTP id AECCE19C7F; Thu, 13 Feb 2020 21:17:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581628666; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Bk0eYKapoPLtbKAcJuykvB4IMf3GQZPBvSP3q8CPYFo=; b=dL4zb+2VLYaTOo+3aj2ylL+tqsVhf1dX2vdwBHTii3MLAJ3JGIZV8m6SqaAsoSTOXsEK97 dJKarT1euyUTwpvFM0f/niL6mXQiymkniszfdxtUcA/P4t/EmUjGpGDG9RgJYI2n+W7i8s /5F7GCZT5CQf8H8cUTLShw2rioaB+cM= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PATCH v6 7/8] multifd: Add multifd-zstd-level parameter Date: Thu, 13 Feb 2020 22:17:08 +0100 Message-Id: <20200213211709.59065-8-quintela@redhat.com> In-Reply-To: <20200213211709.59065-1-quintela@redhat.com> References: <20200213211709.59065-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: sJ_0sV0wOUOZ8Rr5OqXDxA-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.120 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: Fam Zheng , Laurent Vivier , Thomas Huth , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , Juan Quintela , Markus Armbruster , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Paolo Bonzini , =?UTF-8?q?Alex=20Benn=C3=A9e?= , "Dr. David Alan Gilbert" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" This parameter specifies the zstd compression level. The next patch will put it to use. Signed-off-by: Juan Quintela Acked-by: Markus Armbruster Reviewed-by: Peter Xu --- migration/migration.c | 24 ++++++++++++++++++++++++ migration/migration.h | 1 + monitor/hmp-cmds.c | 4 ++++ qapi/migration.json | 29 ++++++++++++++++++++++++++--- 4 files changed, 55 insertions(+), 3 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index a09726f679..c1814a6861 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -91,6 +91,8 @@ #define DEFAULT_MIGRATE_MULTIFD_COMPRESSION MULTIFD_COMPRESSION_NONE /* 0: means nocompress, 1: best speed, ... 9: best compress ratio */ #define DEFAULT_MIGRATE_MULTIFD_ZLIB_LEVEL 1 +/* 0: means nocompress, 1: best speed, ... 20: best compress ratio */ +#define DEFAULT_MIGRATE_MULTIFD_ZSTD_LEVEL 1 =20 /* Background transfer rate for postcopy, 0 means unlimited, note * that page requests can still exceed this limit. @@ -805,6 +807,8 @@ MigrationParameters *qmp_query_migrate_parameters(Error= **errp) params->multifd_compression =3D s->parameters.multifd_compression; params->has_multifd_zlib_level =3D true; params->multifd_zlib_level =3D s->parameters.multifd_zlib_level; + params->has_multifd_zstd_level =3D true; + params->multifd_zstd_level =3D s->parameters.multifd_zstd_level; params->has_xbzrle_cache_size =3D true; params->xbzrle_cache_size =3D s->parameters.xbzrle_cache_size; params->has_max_postcopy_bandwidth =3D true; @@ -1219,6 +1223,13 @@ static bool migrate_params_check(MigrationParameters= *params, Error **errp) return false; } =20 + if (params->has_multifd_zstd_level && + (params->multifd_zstd_level > 20)) { + error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "multifd_zstd_level= ", + "is invalid, it should be in the range of 0 to 20"); + return false; + } + if (params->has_xbzrle_cache_size && (params->xbzrle_cache_size < qemu_target_page_size() || !is_power_of_2(params->xbzrle_cache_size))) { @@ -2274,6 +2285,15 @@ int migrate_multifd_zlib_level(void) return s->parameters.multifd_zlib_level; } =20 +int migrate_multifd_zstd_level(void) +{ + MigrationState *s; + + s =3D migrate_get_current(); + + return s->parameters.multifd_zstd_level; +} + int migrate_use_xbzrle(void) { MigrationState *s; @@ -3567,6 +3587,9 @@ static Property migration_properties[] =3D { DEFINE_PROP_UINT8("multifd-zlib-level", MigrationState, parameters.multifd_zlib_level, DEFAULT_MIGRATE_MULTIFD_ZLIB_LEVEL), + DEFINE_PROP_UINT8("multifd-zstd-level", MigrationState, + parameters.multifd_zstd_level, + DEFAULT_MIGRATE_MULTIFD_ZSTD_LEVEL), DEFINE_PROP_SIZE("xbzrle-cache-size", MigrationState, parameters.xbzrle_cache_size, DEFAULT_MIGRATE_XBZRLE_CACHE_SIZE), @@ -3659,6 +3682,7 @@ static void migration_instance_init(Object *obj) params->has_multifd_channels =3D true; params->has_multifd_compression =3D true; params->has_multifd_zlib_level =3D true; + params->has_multifd_zstd_level =3D true; params->has_xbzrle_cache_size =3D true; params->has_max_postcopy_bandwidth =3D true; params->has_max_cpu_throttle =3D true; diff --git a/migration/migration.h b/migration/migration.h index c363ef9334..507284e563 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -302,6 +302,7 @@ bool migrate_pause_before_switchover(void); int migrate_multifd_channels(void); MultiFDCompression migrate_multifd_compression(void); int migrate_multifd_zlib_level(void); +int migrate_multifd_zstd_level(void); =20 int migrate_use_xbzrle(void); int64_t migrate_xbzrle_cache_size(void); diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index 8a39dff589..f9f2c4446a 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -1840,6 +1840,10 @@ void hmp_migrate_set_parameter(Monitor *mon, const Q= Dict *qdict) p->has_multifd_zlib_level =3D true; visit_type_int(v, param, &p->multifd_zlib_level, &err); break; + case MIGRATION_PARAMETER_MULTIFD_ZSTD_LEVEL: + p->has_multifd_zstd_level =3D true; + visit_type_int(v, param, &p->multifd_zstd_level, &err); + break; case MIGRATION_PARAMETER_XBZRLE_CACHE_SIZE: p->has_xbzrle_cache_size =3D true; visit_type_size(v, param, &cache_size, &err); diff --git a/qapi/migration.json b/qapi/migration.json index 860609231b..1fba695e2e 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -610,6 +610,13 @@ # will consume more CPU. # Defaults to 1. (Since 5.0) # +# @multifd-zstd-level: Set the compression level to be used in live +# migration, the compression level is an integer between 0 +# and 20, where 0 means no compression, 1 means the best +# compression speed, and 20 means best compression ratio which +# will consume more CPU. +# Defaults to 1. (Since 5.0) +# # Since: 2.4 ## { 'enum': 'MigrationParameter', @@ -623,7 +630,7 @@ 'multifd-channels', 'xbzrle-cache-size', 'max-postcopy-bandwidth', 'max-cpu-throttle', 'multifd-compression', - 'multifd-zlib-level' ] } + 'multifd-zlib-level' ,'multifd-zstd-level' ] } =20 ## # @MigrateSetParameters: @@ -723,6 +730,13 @@ # will consume more CPU. # Defaults to 1. (Since 5.0) # +# @multifd-zstd-level: Set the compression level to be used in live +# migration, the compression level is an integer between 0 +# and 20, where 0 means no compression, 1 means the best +# compression speed, and 20 means best compression ratio which +# will consume more CPU. +# Defaults to 1. (Since 5.0) +# # Since: 2.4 ## # TODO either fuse back into MigrationParameters, or make @@ -750,7 +764,8 @@ '*max-postcopy-bandwidth': 'size', '*max-cpu-throttle': 'int', '*multifd-compression': 'MultiFDCompression', - '*multifd-zlib-level': 'int' } } + '*multifd-zlib-level': 'int', + '*multifd-zstd-level': 'int' } } =20 ## # @migrate-set-parameters: @@ -870,6 +885,13 @@ # will consume more CPU. # Defaults to 1. (Since 5.0) # +# @multifd-zstd-level: Set the compression level to be used in live +# migration, the compression level is an integer between 0 +# and 20, where 0 means no compression, 1 means the best +# compression speed, and 20 means best compression ratio which +# will consume more CPU. +# Defaults to 1. (Since 5.0) +# # Since: 2.4 ## { 'struct': 'MigrationParameters', @@ -895,7 +917,8 @@ '*max-postcopy-bandwidth': 'size', '*max-cpu-throttle': 'uint8', '*multifd-compression': 'MultiFDCompression', - '*multifd-zlib-level': 'uint8' } } + '*multifd-zlib-level': 'uint8', + '*multifd-zstd-level': 'uint8' } } =20 ## # @query-migrate-parameters: --=20 2.24.1 From nobody Thu Apr 25 14:38:39 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1581628960486716.3469990968958; Thu, 13 Feb 2020 13:22:40 -0800 (PST) Received: from localhost ([::1]:59286 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j2LwV-0002wj-5i for importer@patchew.org; Thu, 13 Feb 2020 16:22:39 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:49664) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j2Lrv-0005tc-6r for qemu-devel@nongnu.org; Thu, 13 Feb 2020 16:18:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j2Lrs-0005QL-Sj for qemu-devel@nongnu.org; Thu, 13 Feb 2020 16:17:55 -0500 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:29176 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j2Lrr-0005DP-KC for qemu-devel@nongnu.org; Thu, 13 Feb 2020 16:17:52 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-107-ukL0Sv2fPHSUaAyHaIgltA-1; Thu, 13 Feb 2020 16:17:48 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CFB31800D41; Thu, 13 Feb 2020 21:17:46 +0000 (UTC) Received: from secure.mitica (ovpn-116-211.ams2.redhat.com [10.36.116.211]) by smtp.corp.redhat.com (Postfix) with ESMTP id EC3FE19C7F; Thu, 13 Feb 2020 21:17:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581628669; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NkfYwI2C4vHahJx6He54R00GSRjiN6IZ4DdNh9BTD00=; b=SD6rT1+nYqmuDxfMxt/Z+Id4CGTeHePC6/Cc52ynyp9L0UeZgtRYuxcOrUVtxyuzB7bwID mZLVb1f/SaBTsDaE1hZkftDVGbodNXHlO0uyAId0Ufy4yoChD7ZL7e76J8xA0t6fFAyBH0 xcW8LWmjjSQuuTl/te8DacjGLr0ECHU= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PATCH v6 8/8] multifd: Add zstd compression multifd support Date: Thu, 13 Feb 2020 22:17:09 +0100 Message-Id: <20200213211709.59065-9-quintela@redhat.com> In-Reply-To: <20200213211709.59065-1-quintela@redhat.com> References: <20200213211709.59065-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: ukL0Sv2fPHSUaAyHaIgltA-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 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: Fam Zheng , Laurent Vivier , Thomas Huth , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , Juan Quintela , Markus Armbruster , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Paolo Bonzini , =?UTF-8?q?Alex=20Benn=C3=A9e?= , "Dr. David Alan Gilbert" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Signed-off-by: Juan Quintela Acked-by: Markus Armbruster Reviewed-by: Dr. David Alan Gilbert --- hw/core/qdev-properties.c | 2 +- migration/Makefile.objs | 1 + migration/multifd-zstd.c | 339 +++++++++++++++++++++++++++++++++++ migration/multifd.h | 1 + migration/ram.c | 1 - qapi/migration.json | 4 +- tests/qtest/migration-test.c | 10 ++ 7 files changed, 355 insertions(+), 3 deletions(-) create mode 100644 migration/multifd-zstd.c diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c index db2a7abfb2..2047114fca 100644 --- a/hw/core/qdev-properties.c +++ b/hw/core/qdev-properties.c @@ -645,7 +645,7 @@ const PropertyInfo qdev_prop_fdc_drive_type =3D { const PropertyInfo qdev_prop_multifd_compression =3D { .name =3D "MultiFDCompression", .description =3D "multifd_compression values, " - "none/zlib", + "none/zlib/zstd", .enum_table =3D &MultiFDCompression_lookup, .get =3D get_enum, .set =3D set_enum, diff --git a/migration/Makefile.objs b/migration/Makefile.objs index 0308caa5c5..0fc619e380 100644 --- a/migration/Makefile.objs +++ b/migration/Makefile.objs @@ -9,6 +9,7 @@ common-obj-y +=3D qjson.o common-obj-y +=3D block-dirty-bitmap.o common-obj-y +=3D multifd.o common-obj-y +=3D multifd-zlib.o +common-obj-$(CONFIG_ZSTD) +=3D multifd-zstd.o =20 common-obj-$(CONFIG_RDMA) +=3D rdma.o =20 diff --git a/migration/multifd-zstd.c b/migration/multifd-zstd.c new file mode 100644 index 0000000000..693bddf8c9 --- /dev/null +++ b/migration/multifd-zstd.c @@ -0,0 +1,339 @@ +/* + * Multifd zlib compression implementation + * + * Copyright (c) 2020 Red Hat Inc + * + * Authors: + * Juan Quintela + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include +#include "qemu/rcu.h" +#include "exec/target_page.h" +#include "qapi/error.h" +#include "migration.h" +#include "trace.h" +#include "multifd.h" + +struct zstd_data { + /* stream for compression */ + ZSTD_CStream *zcs; + /* stream for decompression */ + ZSTD_DStream *zds; + /* buffers */ + ZSTD_inBuffer in; + ZSTD_outBuffer out; + /* compressed buffer */ + uint8_t *zbuff; + /* size of compressed buffer */ + uint32_t zbuff_len; +}; + +/* Multifd zstd compression */ + +/** + * zstd_send_setup: setup send side + * + * Setup each channel with zstd compression. + * + * Returns 0 for success or -1 for error + * + * @p: Params for the channel that we are using + * @errp: pointer to an error + */ +static int zstd_send_setup(MultiFDSendParams *p, Error **errp) +{ + uint32_t page_count =3D MULTIFD_PACKET_SIZE / qemu_target_page_size(); + struct zstd_data *z =3D g_new0(struct zstd_data, 1); + int res; + + p->data =3D z; + z->zcs =3D ZSTD_createCStream(); + if (!z->zcs) { + g_free(z); + error_setg(errp, "multifd %d: zstd createCStream failed", p->id); + return -1; + } + + res =3D ZSTD_initCStream(z->zcs, migrate_multifd_zstd_level()); + if (ZSTD_isError(res)) { + ZSTD_freeCStream(z->zcs); + g_free(z); + error_setg(errp, "multifd %d: initCStream failed with error %s", + p->id, ZSTD_getErrorName(res)); + return -1; + } + /* We will never have more than page_count pages */ + z->zbuff_len =3D page_count * qemu_target_page_size(); + z->zbuff_len *=3D 2; + z->zbuff =3D g_try_malloc(z->zbuff_len); + if (!z->zbuff) { + ZSTD_freeCStream(z->zcs); + g_free(z); + error_setg(errp, "multifd %d: out of memory for zbuff", p->id); + return -1; + } + return 0; +} + +/** + * zstd_send_cleanup: cleanup send side + * + * Close the channel and return memory. + * + * @p: Params for the channel that we are using + */ +static void zstd_send_cleanup(MultiFDSendParams *p, Error **errp) +{ + struct zstd_data *z =3D p->data; + + ZSTD_freeCStream(z->zcs); + z->zcs =3D NULL; + g_free(z->zbuff); + z->zbuff =3D NULL; + g_free(p->data); + p->data =3D NULL; +} + +/** + * zstd_send_prepare: prepare date to be able to send + * + * Create a compressed buffer with all the pages that we are going to + * send. + * + * Returns 0 for success or -1 for error + * + * @p: Params for the channel that we are using + * @used: number of pages used + */ +static int zstd_send_prepare(MultiFDSendParams *p, uint32_t used, Error **= errp) +{ + struct iovec *iov =3D p->pages->iov; + struct zstd_data *z =3D p->data; + int ret; + uint32_t i; + + z->out.dst =3D z->zbuff; + z->out.size =3D z->zbuff_len; + z->out.pos =3D 0; + + for (i =3D 0; i < used; i++) { + ZSTD_EndDirective flush =3D ZSTD_e_continue; + + if (i =3D=3D used - 1) { + flush =3D ZSTD_e_flush; + } + z->in.src =3D iov[i].iov_base; + z->in.size =3D iov[i].iov_len; + z->in.pos =3D 0; + + /* + * Welcome to compressStream2 semantics + * + * We need to loop while: + * - return is > 0 + * - there is input available + * - there is output space free + */ + do { + ret =3D ZSTD_compressStream2(z->zcs, &z->out, &z->in, flush); + } while (ret > 0 && (z->in.size - z->in.pos > 0) + && (z->out.size - z->out.pos > 0)); + if (ret > 0 && (z->in.size - z->in.pos > 0)) { + error_setg(errp, "multifd %d: compressStream buffer too small", + p->id); + return -1; + } + if (ZSTD_isError(ret)) { + error_setg(errp, "multifd %d: compressStream error %s", + p->id, ZSTD_getErrorName(ret)); + return -1; + } + } + p->next_packet_size =3D z->out.pos; + p->flags |=3D MULTIFD_FLAG_ZSTD; + + return 0; +} + +/** + * zstd_send_write: do the actual write of the data + * + * Do the actual write of the comprresed buffer. + * + * Returns 0 for success or -1 for error + * + * @p: Params for the channel that we are using + * @used: number of pages used + * @errp: pointer to an error + */ +static int zstd_send_write(MultiFDSendParams *p, uint32_t used, Error **er= rp) +{ + struct zstd_data *z =3D p->data; + + return qio_channel_write_all(p->c, (void *)z->zbuff, p->next_packet_si= ze, + errp); +} + +/** + * zstd_recv_setup: setup receive side + * + * Create the compressed channel and buffer. + * + * Returns 0 for success or -1 for error + * + * @p: Params for the channel that we are using + * @errp: pointer to an error + */ +static int zstd_recv_setup(MultiFDRecvParams *p, Error **errp) +{ + uint32_t page_count =3D MULTIFD_PACKET_SIZE / qemu_target_page_size(); + struct zstd_data *z =3D g_new0(struct zstd_data, 1); + int ret; + + p->data =3D z; + z->zds =3D ZSTD_createDStream(); + if (!z->zds) { + g_free(z); + error_setg(errp, "multifd %d: zstd createDStream failed", p->id); + return -1; + } + + ret =3D ZSTD_initDStream(z->zds); + if (ZSTD_isError(ret)) { + ZSTD_freeDStream(z->zds); + g_free(z); + error_setg(errp, "multifd %d: initDStream failed with error %s", + p->id, ZSTD_getErrorName(ret)); + return -1; + } + + /* We will never have more than page_count pages */ + z->zbuff_len =3D page_count * qemu_target_page_size(); + /* We know compression "could" use more space */ + z->zbuff_len *=3D 2; + z->zbuff =3D g_try_malloc(z->zbuff_len); + if (!z->zbuff) { + ZSTD_freeDStream(z->zds); + g_free(z); + error_setg(errp, "multifd %d: out of memory for zbuff", p->id); + return -1; + } + return 0; +} + +/** + * zstd_recv_cleanup: setup receive side + * + * For no compression this function does nothing. + * + * @p: Params for the channel that we are using + */ +static void zstd_recv_cleanup(MultiFDRecvParams *p) +{ + struct zstd_data *z =3D p->data; + + ZSTD_freeDStream(z->zds); + z->zds =3D NULL; + g_free(z->zbuff); + z->zbuff =3D NULL; + g_free(p->data); + p->data =3D NULL; +} + +/** + * zstd_recv_pages: read the data from the channel into actual pages + * + * Read the compressed buffer, and uncompress it into the actual + * pages. + * + * Returns 0 for success or -1 for error + * + * @p: Params for the channel that we are using + * @used: number of pages used + * @errp: pointer to an error + */ +static int zstd_recv_pages(MultiFDRecvParams *p, uint32_t used, Error **er= rp) +{ + uint32_t in_size =3D p->next_packet_size; + uint32_t out_size =3D 0; + uint32_t expected_size =3D used * qemu_target_page_size(); + uint32_t flags =3D p->flags & MULTIFD_FLAG_COMPRESSION_MASK; + struct zstd_data *z =3D p->data; + int ret; + int i; + + if (flags !=3D MULTIFD_FLAG_ZSTD) { + error_setg(errp, "multifd %d: flags received %x flags expected %x", + p->id, flags, MULTIFD_FLAG_ZSTD); + return -1; + } + ret =3D qio_channel_read_all(p->c, (void *)z->zbuff, in_size, errp); + + if (ret !=3D 0) { + return ret; + } + + z->in.src =3D z->zbuff; + z->in.size =3D in_size; + z->in.pos =3D 0; + + for (i =3D 0; i < used; i++) { + struct iovec *iov =3D &p->pages->iov[i]; + + z->out.dst =3D iov->iov_base; + z->out.size =3D iov->iov_len; + z->out.pos =3D 0; + + /* + * Welcome to decompressStream semantics + * + * We need to loop while: + * - return is > 0 + * - there is input available + * - we haven't put out a full page + */ + do { + ret =3D ZSTD_decompressStream(z->zds, &z->out, &z->in); + } while (ret > 0 && (z->in.size - z->in.pos > 0) + && (z->out.pos < iov->iov_len)); + if (ret > 0 && (z->out.pos < iov->iov_len)) { + error_setg(errp, "multifd %d: decompressStream buffer too smal= l", + p->id); + return -1; + } + if (ZSTD_isError(ret)) { + error_setg(errp, "multifd %d: decompressStream returned %s", + p->id, ZSTD_getErrorName(ret)); + return ret; + } + out_size +=3D z->out.pos; + } + if (out_size !=3D expected_size) { + error_setg(errp, "multifd %d: packet size received %d size expecte= d %d", + p->id, out_size, expected_size); + return -1; + } + return 0; +} + +static MultiFDMethods multifd_zstd_ops =3D { + .send_setup =3D zstd_send_setup, + .send_cleanup =3D zstd_send_cleanup, + .send_prepare =3D zstd_send_prepare, + .send_write =3D zstd_send_write, + .recv_setup =3D zstd_recv_setup, + .recv_cleanup =3D zstd_recv_cleanup, + .recv_pages =3D zstd_recv_pages +}; + +static void multifd_zstd_register(void) +{ + multifd_register_ops(MULTIFD_COMPRESSION_ZSTD, &multifd_zstd_ops); +} + +migration_init(multifd_zstd_register); diff --git a/migration/multifd.h b/migration/multifd.h index c6dad7b990..448a03d89a 100644 --- a/migration/multifd.h +++ b/migration/multifd.h @@ -31,6 +31,7 @@ int multifd_queue_page(QEMUFile *f, RAMBlock *block, ram_= addr_t offset); /* we need to be compatible. Before compression value was 0 */ #define MULTIFD_FLAG_NOCOMP (0 << 1) #define MULTIFD_FLAG_ZLIB (1 << 1) +#define MULTIFD_FLAG_ZSTD (2 << 1) =20 /* This value needs to be a multiple of qemu_target_page_size() */ #define MULTIFD_PACKET_SIZE (512 * 1024) diff --git a/migration/ram.c b/migration/ram.c index 73a141bb60..0ef68798d2 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -28,7 +28,6 @@ =20 #include "qemu/osdep.h" #include "cpu.h" -#include #include "qemu/cutils.h" #include "qemu/bitops.h" #include "qemu/bitmap.h" diff --git a/qapi/migration.json b/qapi/migration.json index 1fba695e2e..0fd41823d3 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -495,12 +495,14 @@ # # @none: no compression. # @zlib: use zlib compression method. +# @zstd: use zstd compression method. # # Since: 5.0 # ## { 'enum': 'MultiFDCompression', - 'data': [ 'none', 'zlib' ] } + 'data': [ 'none', 'zlib', + { 'name': 'zstd', 'if': 'defined(CONFIG_ZSTD)' } ] } =20 ## # @MigrationParameter: diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index 90c26e879f..3d6cc83b88 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -1328,6 +1328,13 @@ static void test_multifd_tcp_zlib(void) test_multifd_tcp("zlib"); } =20 +#ifdef CONFIG_ZSTD +static void test_multifd_tcp_zstd(void) +{ + test_multifd_tcp("zstd"); +} +#endif + /* * This test does: * source target @@ -1492,6 +1499,9 @@ int main(int argc, char **argv) qtest_add_func("/migration/multifd/tcp/none", test_multifd_tcp_none); qtest_add_func("/migration/multifd/tcp/cancel", test_multifd_tcp_cance= l); qtest_add_func("/migration/multifd/tcp/zlib", test_multifd_tcp_zlib); +#ifdef CONFIG_ZSTD + qtest_add_func("/migration/multifd/tcp/zstd", test_multifd_tcp_zstd); +#endif =20 ret =3D g_test_run(); =20 --=20 2.24.1