From patchwork Wed Dec 18 02:01:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 11299351 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B0B3C13B6 for ; Wed, 18 Dec 2019 02:09:16 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8636421582 for ; Wed, 18 Dec 2019 02:09:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Ee5zCcJF" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8636421582 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:48482 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihOm3-0003s5-Er for patchwork-qemu-devel@patchwork.kernel.org; Tue, 17 Dec 2019 21:09:15 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52380) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihOek-0002zz-5Q for qemu-devel@nongnu.org; Tue, 17 Dec 2019 21:01:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ihOeb-0005eJ-T0 for qemu-devel@nongnu.org; Tue, 17 Dec 2019 21:01:37 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:24478 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 1ihOea-0005bc-Ep for qemu-devel@nongnu.org; Tue, 17 Dec 2019 21:01:32 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576634490; 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=Pe09oFj+dplfSAmWzK13nOJ+j8pDv/xrYGnj1YjPya4=; b=Ee5zCcJFqU2kOWHFzOzw6f6zYrWsQWNLn4r8jUJ/T5Yzv9+cqpe+TMsqR7vQK0QmCcUh+J t1DD8oWTlqc+WccRoHTxS2XPv2PsecZfPcf6nPt0Q6OSswPP4zDbaaQvK9mR1g6vBWLDoP 48E2L00CKDrkCISLAg1cYcsH/8p19x8= 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-316-4QlvFONpMYqfMy2ZRD_CXg-1; Tue, 17 Dec 2019 21:01: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 4A303800053 for ; Wed, 18 Dec 2019 02:01:25 +0000 (UTC) Received: from secure.mitica (ovpn-116-32.ams2.redhat.com [10.36.116.32]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0EA6419C58; Wed, 18 Dec 2019 02:01:22 +0000 (UTC) From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PATCH v2 01/10] migration: Increase default number of multifd channels to 16 Date: Wed, 18 Dec 2019 03:01:10 +0100 Message-Id: <20191218020119.3776-2-quintela@redhat.com> In-Reply-To: <20191218020119.3776-1-quintela@redhat.com> References: <20191218020119.3776-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: 4QlvFONpMYqfMy2ZRD_CXg-1 X-Mimecast-Spam-Score: 0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] 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: Laurent Vivier , Thomas Huth , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Eduardo Habkost , Juan Quintela , "Dr. David Alan Gilbert" , Markus Armbruster , Paolo Bonzini Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" We can scale much better with 16, so we can scale to higher numbers. Signed-off-by: Juan Quintela Reviewed-by: Dr. David Alan Gilbert --- migration/migration.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/migration/migration.c b/migration/migration.c index 354ad072fa..e7f707e033 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -86,7 +86,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_CHANNELS 16 /* Background transfer rate for postcopy, 0 means unlimited, note * that page requests can still exceed this limit. From patchwork Wed Dec 18 02:01:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 11299341 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2F2C614B7 for ; Wed, 18 Dec 2019 02:07:07 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 056D621582 for ; Wed, 18 Dec 2019 02:07:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="hzw+k+1E" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 056D621582 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:48462 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihOjx-0001CN-Vw for patchwork-qemu-devel@patchwork.kernel.org; Tue, 17 Dec 2019 21:07:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52373) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihOek-0002zy-6b for qemu-devel@nongnu.org; Tue, 17 Dec 2019 21:01:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ihOec-0005ed-27 for qemu-devel@nongnu.org; Tue, 17 Dec 2019 21:01:37 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:29237 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 1ihOea-0005bO-Cl for qemu-devel@nongnu.org; Tue, 17 Dec 2019 21:01:32 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576634490; 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=AbVUoPWAQnOweIpazKXxx/LAkrdliiYL/S22zpBO/sQ=; b=hzw+k+1EF5WO/fva4uApXNIYceVzhqKhGAlqy4cQC20Xn68FxJksLgevvM37E5piVyIiNS PFMU196Z11SLBbQ8bBKFL18TyhRFmMleQI1gVFxcpC6zhI1nDjXshYKhKlfQwVvPhtTqD5 jtoa7+fMHEtfR5PNsGpF2+VPDHFmS14= 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-353-RAVmLdEdPJS5QuNzn5wWgw-1; Tue, 17 Dec 2019 21:01:29 -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 1EA30DB20; Wed, 18 Dec 2019 02:01:28 +0000 (UTC) Received: from secure.mitica (ovpn-116-32.ams2.redhat.com [10.36.116.32]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9F53219C58; Wed, 18 Dec 2019 02:01:25 +0000 (UTC) From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PATCH v2 02/10] migration-test: Add migration multifd test Date: Wed, 18 Dec 2019 03:01:11 +0100 Message-Id: <20191218020119.3776-3-quintela@redhat.com> In-Reply-To: <20191218020119.3776-1-quintela@redhat.com> References: <20191218020119.3776-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: RAVmLdEdPJS5QuNzn5wWgw-1 X-Mimecast-Spam-Score: 0 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: Laurent Vivier , Thomas Huth , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Eduardo Habkost , Juan Quintela , "Dr. David Alan Gilbert" , Markus Armbruster , Wei Yang , Paolo Bonzini Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" We set multifd-channels. Signed-off-by: Juan Quintela Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Thomas Huth Tested-by: Wei Yang Signed-off-by: Juan Quintela --- tests/migration-test.c | 56 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/tests/migration-test.c b/tests/migration-test.c index f58430c1cb..1c9f2c4e6a 100644 --- a/tests/migration-test.c +++ b/tests/migration-test.c @@ -1361,6 +1361,61 @@ static void test_migrate_auto_converge(void) test_migrate_end(from, to, true); } +static void test_multifd_tcp(void) +{ + MigrateStart *args = migrate_start_new(); + QTestState *from, *to; + QDict *rsp; + char *uri; + + if (test_migrate_start(&from, &to, "defer", args)) { + return; + } + + /* + * We want to pick a speed slow enough that the test completes + * quickly, but that it doesn't complete precopy even on a slow + * machine, so also set the downtime. + */ + /* 1 ms should make it not converge*/ + migrate_set_parameter_int(from, "downtime-limit", 1); + /* 1GB/s */ + migrate_set_parameter_int(from, "max-bandwidth", 1000000000); + + migrate_set_parameter_int(from, "multifd-channels", 16); + migrate_set_parameter_int(to, "multifd-channels", 16); + + migrate_set_capability(from, "multifd", "true"); + migrate_set_capability(to, "multifd", "true"); + + /* Start incoming migration from the 1st socket */ + rsp = wait_command(to, "{ 'execute': 'migrate-incoming'," + " 'arguments': { 'uri': 'tcp:127.0.0.1:0' }}"); + qobject_unref(rsp); + + /* Wait for the first serial output from the source */ + wait_for_serial("src_serial"); + + uri = migrate_get_socket_address(to, "socket-address"); + + migrate(from, uri, "{}"); + + wait_for_migration_pass(from); + + /* 300ms it should converge */ + migrate_set_parameter_int(from, "downtime-limit", 600); + + if (!got_stop) { + qtest_qmp_eventwait(from, "STOP"); + } + qtest_qmp_eventwait(to, "RESUME"); + + wait_for_serial("dest_serial"); + wait_for_migration_complete(from); + test_migrate_end(from, to, true); + free(uri); +} + int main(int argc, char **argv) { char template[] = "/tmp/migration-test-XXXXXX"; @@ -1425,6 +1480,7 @@ int main(int argc, char **argv) test_validate_uuid_dst_not_set); qtest_add_func("/migration/auto_converge", test_migrate_auto_converge); + qtest_add_func("/migration/multifd/tcp", test_multifd_tcp); ret = g_test_run(); From patchwork Wed Dec 18 02:01:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 11299357 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 601EB109A for ; Wed, 18 Dec 2019 02:11:38 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3631021582 for ; Wed, 18 Dec 2019 02:11:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ZIHdWjkE" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3631021582 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:48512 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihOoL-0006mE-1p for patchwork-qemu-devel@patchwork.kernel.org; Tue, 17 Dec 2019 21:11:37 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52489) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihOem-00031m-H8 for qemu-devel@nongnu.org; Tue, 17 Dec 2019 21:01:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ihOek-0005ku-56 for qemu-devel@nongnu.org; Tue, 17 Dec 2019 21:01:44 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:23705 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 1ihOef-0005e2-NO for qemu-devel@nongnu.org; Tue, 17 Dec 2019 21:01:40 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576634493; 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=mv2SnFdQsuqDIHEqHijU1eHiBdKn1tQVskm301BhwCk=; b=ZIHdWjkEwV7d6/10zPiHwxPBLeSg/TG0vrjiXkL6LTKRc8sZNCuWVqQt1mFyvxvfElPDL+ 8hNscP6OK4wXjhGmPZqZeLGgAhRw15ZquqKnyopuhf+DdDXXyHtk3hyMDPbOGAddne2USk /9DR0y1PhdhM4W8LBVKfTmHfRu5CNjw= 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-336-45RvbkazPh6US4hTj1AkbQ-1; Tue, 17 Dec 2019 21:01:31 -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 B48671005502 for ; Wed, 18 Dec 2019 02:01:30 +0000 (UTC) Received: from secure.mitica (ovpn-116-32.ams2.redhat.com [10.36.116.32]) by smtp.corp.redhat.com (Postfix) with ESMTP id 72C8919C58; Wed, 18 Dec 2019 02:01:28 +0000 (UTC) From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PATCH v2 03/10] migration-test: introduce functions to handle string parameters Date: Wed, 18 Dec 2019 03:01:12 +0100 Message-Id: <20191218020119.3776-4-quintela@redhat.com> In-Reply-To: <20191218020119.3776-1-quintela@redhat.com> References: <20191218020119.3776-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: 45RvbkazPh6US4hTj1AkbQ-1 X-Mimecast-Spam-Score: 0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] 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: Laurent Vivier , Thomas Huth , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Eduardo Habkost , Juan Quintela , "Dr. David Alan Gilbert" , Markus Armbruster , Paolo Bonzini Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Juan Quintela Reviewed-by: Dr. David Alan Gilbert --- tests/migration-test.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/tests/migration-test.c b/tests/migration-test.c index 1c9f2c4e6a..fc221f172a 100644 --- a/tests/migration-test.c +++ b/tests/migration-test.c @@ -460,6 +460,43 @@ static void migrate_set_parameter_int(QTestState *who, const char *parameter, migrate_check_parameter_int(who, parameter, value); } +static char *migrate_get_parameter_str(QTestState *who, + const char *parameter) +{ + QDict *rsp; + char *result; + + rsp = wait_command(who, "{ 'execute': 'query-migrate-parameters' }"); + result = g_strdup(qdict_get_str(rsp, parameter)); + qobject_unref(rsp); + return result; +} + +static void migrate_check_parameter_str(QTestState *who, const char *parameter, + const char *value) +{ + char *result; + + result = migrate_get_parameter_str(who, parameter); + g_assert_cmpstr(result, ==, value); + g_free(result); +} + +__attribute__((unused)) +static void migrate_set_parameter_str(QTestState *who, const char *parameter, + const char *value) +{ + QDict *rsp; + + rsp = qtest_qmp(who, + "{ 'execute': 'migrate-set-parameters'," + "'arguments': { %s: %s } }", + parameter, value); + g_assert(qdict_haskey(rsp, "return")); + qobject_unref(rsp); + migrate_check_parameter_str(who, parameter, value); +} + static void migrate_pause(QTestState *who) { QDict *rsp; From patchwork Wed Dec 18 02:01:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 11299337 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C5AFB14B7 for ; Wed, 18 Dec 2019 02:06:29 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9AEB821775 for ; Wed, 18 Dec 2019 02:06:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="iGyuN4/8" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9AEB821775 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:48458 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihOjM-0000Hq-FJ for patchwork-qemu-devel@patchwork.kernel.org; Tue, 17 Dec 2019 21:06:28 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52495) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihOem-00031u-JE for qemu-devel@nongnu.org; Tue, 17 Dec 2019 21:01:46 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ihOek-0005lX-9j for qemu-devel@nongnu.org; Tue, 17 Dec 2019 21:01:44 -0500 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:47259 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 1ihOek-0005gR-5Y for qemu-devel@nongnu.org; Tue, 17 Dec 2019 21:01:42 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576634497; 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=gvvZhu/xFvz1U3Hf+/Yigdo8O7qRPkr3UgL8NVTZMng=; b=iGyuN4/8Ys5k5Xv79oJxTnsBOp1cEZ6WRzTDF8vk1cVUaLqoyfq5kaMarRptJyQh6pWTHo doH9Z7OEFb822JAVAZpXV98jVK1LfOz/tDY/W8ip3MA+G7ifaIhwSkpS51qRx1cdQFFsB3 EQvLfYg+6gVOkaMPH2Udu8+rWQWuEIQ= 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-401-dB8nvs-CMRKPZv6uDflWKg-1; Tue, 17 Dec 2019 21:01:34 -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 50715107ACC4 for ; Wed, 18 Dec 2019 02:01:33 +0000 (UTC) Received: from secure.mitica (ovpn-116-32.ams2.redhat.com [10.36.116.32]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1265619C58; Wed, 18 Dec 2019 02:01:30 +0000 (UTC) From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PATCH v2 04/10] migration: Make multifd_save_setup() get an Error parameter Date: Wed, 18 Dec 2019 03:01:13 +0100 Message-Id: <20191218020119.3776-5-quintela@redhat.com> In-Reply-To: <20191218020119.3776-1-quintela@redhat.com> References: <20191218020119.3776-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: dB8nvs-CMRKPZv6uDflWKg-1 X-Mimecast-Spam-Score: 0 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: Laurent Vivier , Thomas Huth , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Eduardo Habkost , Juan Quintela , "Dr. David Alan Gilbert" , Markus Armbruster , Paolo Bonzini Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Juan Quintela --- migration/migration.c | 2 +- migration/ram.c | 2 +- migration/ram.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index e7f707e033..5a56bd0c91 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -3400,7 +3400,7 @@ void migrate_fd_connect(MigrationState *s, Error *error_in) return; } - if (multifd_save_setup() != 0) { + if (multifd_save_setup(&error_in) != 0) { migrate_set_state(&s->state, MIGRATION_STATUS_SETUP, MIGRATION_STATUS_FAILED); migrate_fd_cleanup(s); diff --git a/migration/ram.c b/migration/ram.c index 38070f1bb2..1f364cc23d 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -1208,7 +1208,7 @@ static void multifd_new_send_channel_async(QIOTask *task, gpointer opaque) } } -int multifd_save_setup(void) +int multifd_save_setup(Error **errp) { int thread_count; uint32_t page_count = MULTIFD_PACKET_SIZE / qemu_target_page_size(); diff --git a/migration/ram.h b/migration/ram.h index bd0eee79b6..da22a417ea 100644 --- a/migration/ram.h +++ b/migration/ram.h @@ -41,7 +41,7 @@ int xbzrle_cache_resize(int64_t new_size, Error **errp); uint64_t ram_bytes_remaining(void); uint64_t ram_bytes_total(void); -int multifd_save_setup(void); +int multifd_save_setup(Error **errp); void multifd_save_cleanup(void); int multifd_load_setup(void); int multifd_load_cleanup(Error **errp); From patchwork Wed Dec 18 02:01:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 11299345 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5A98213B6 for ; Wed, 18 Dec 2019 02:08:29 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 30E3021582 for ; Wed, 18 Dec 2019 02:08:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="i08PW2BW" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 30E3021582 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:48479 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihOlH-0002xM-UZ for patchwork-qemu-devel@patchwork.kernel.org; Tue, 17 Dec 2019 21:08:27 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52494) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihOem-00031s-J1 for qemu-devel@nongnu.org; Tue, 17 Dec 2019 21:01:46 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ihOek-0005lj-BK for qemu-devel@nongnu.org; Tue, 17 Dec 2019 21:01:44 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:47335 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 1ihOek-0005js-63 for qemu-devel@nongnu.org; Tue, 17 Dec 2019 21:01:42 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576634500; 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=IqM3Kq9hFeOHL8zFMDTIxhzsJBYbrbpYhbnBIsEKtNc=; b=i08PW2BWTRy4hBEKkWDX5/Saivudgg5A0FTQe74AOvRRmWkz7XSOOSg0Y8J6A0agFodOsw Mtk8unYTc8MIDeRuZCY90m+UMF6Xh5g4M2MPL7w4Y2dm0W/Py1JDPzVBSdFwIZsDDLBuWO DWsUFX58CUitlOe9Fp3lZxr1MQJV0tE= 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-160-wPx4yIzgPNG5DbS4yc1vcg-1; Tue, 17 Dec 2019 21:01:36 -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 E13EA107ACC4 for ; Wed, 18 Dec 2019 02:01:35 +0000 (UTC) Received: from secure.mitica (ovpn-116-32.ams2.redhat.com [10.36.116.32]) by smtp.corp.redhat.com (Postfix) with ESMTP id A32C919C58; Wed, 18 Dec 2019 02:01:33 +0000 (UTC) From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PATCH v2 05/10] migration: Make multifd_load_setup() get an Error parameter Date: Wed, 18 Dec 2019 03:01:14 +0100 Message-Id: <20191218020119.3776-6-quintela@redhat.com> In-Reply-To: <20191218020119.3776-1-quintela@redhat.com> References: <20191218020119.3776-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: wPx4yIzgPNG5DbS4yc1vcg-1 X-Mimecast-Spam-Score: 0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] 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: Laurent Vivier , Thomas Huth , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Eduardo Habkost , Juan Quintela , "Dr. David Alan Gilbert" , Markus Armbruster , Paolo Bonzini Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" We need to change the full chain to pass the Error parameter. Signed-off-by: Juan Quintela --- migration/migration.c | 10 +++++----- migration/migration.h | 2 +- migration/ram.c | 2 +- migration/ram.h | 2 +- migration/rdma.c | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 5a56bd0c91..cf6cec5fb6 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -518,11 +518,11 @@ fail: exit(EXIT_FAILURE); } -static void migration_incoming_setup(QEMUFile *f) +static void migration_incoming_setup(QEMUFile *f, Error **errp) { MigrationIncomingState *mis = migration_incoming_get_current(); - if (multifd_load_setup() != 0) { + if (multifd_load_setup(errp) != 0) { /* We haven't been able to create multifd threads nothing better to do */ exit(EXIT_FAILURE); @@ -572,13 +572,13 @@ static bool postcopy_try_recover(QEMUFile *f) return false; } -void migration_fd_process_incoming(QEMUFile *f) +void migration_fd_process_incoming(QEMUFile *f, Error **errp) { if (postcopy_try_recover(f)) { return; } - migration_incoming_setup(f); + migration_incoming_setup(f, errp); migration_incoming_process(); } @@ -596,7 +596,7 @@ void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp) return; } - migration_incoming_setup(f); + migration_incoming_setup(f, errp); /* * Common migration only needs one channel, so we can start diff --git a/migration/migration.h b/migration/migration.h index 79b3dda146..545f283ae7 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -265,7 +265,7 @@ struct MigrationState void migrate_set_state(int *state, int old_state, int new_state); -void migration_fd_process_incoming(QEMUFile *f); +void migration_fd_process_incoming(QEMUFile *f, Error **errp); void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp); void migration_incoming_process(void); diff --git a/migration/ram.c b/migration/ram.c index 1f364cc23d..fcf50e648a 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -1421,7 +1421,7 @@ static void *multifd_recv_thread(void *opaque) return NULL; } -int multifd_load_setup(void) +int multifd_load_setup(Error **errp) { int thread_count; uint32_t page_count = MULTIFD_PACKET_SIZE / qemu_target_page_size(); diff --git a/migration/ram.h b/migration/ram.h index da22a417ea..42be471d52 100644 --- a/migration/ram.h +++ b/migration/ram.h @@ -43,7 +43,7 @@ uint64_t ram_bytes_total(void); int multifd_save_setup(Error **errp); void multifd_save_cleanup(void); -int multifd_load_setup(void); +int multifd_load_setup(Error **errp); int multifd_load_cleanup(Error **errp); bool multifd_recv_all_channels_created(void); bool multifd_recv_new_channel(QIOChannel *ioc, Error **errp); diff --git a/migration/rdma.c b/migration/rdma.c index e241dcb992..2379b8345b 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -4004,7 +4004,7 @@ static void rdma_accept_incoming_migration(void *opaque) } rdma->migration_started_on_destination = 1; - migration_fd_process_incoming(f); + migration_fd_process_incoming(f, errp); } void rdma_start_incoming_migration(const char *host_port, Error **errp) From patchwork Wed Dec 18 02:01:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 11299355 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E7F7114B7 for ; Wed, 18 Dec 2019 02:10:44 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id ABF4A21582 for ; Wed, 18 Dec 2019 02:10:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="M6MFRT9C" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org ABF4A21582 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:48510 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihOnT-0005sQ-CP for patchwork-qemu-devel@patchwork.kernel.org; Tue, 17 Dec 2019 21:10:43 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52560) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihOeo-00032Q-Dn for qemu-devel@nongnu.org; Tue, 17 Dec 2019 21:01:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ihOem-0005nn-FM for qemu-devel@nongnu.org; Tue, 17 Dec 2019 21:01:46 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:35608 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 1ihOel-0005mY-PC for qemu-devel@nongnu.org; Tue, 17 Dec 2019 21:01:43 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576634502; 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=iVRIBO5wyUrsQa52u78XdUvKUuObp4iAocslgdnORJw=; b=M6MFRT9C1IltZ9zE6bRWYLKQVDxM3JzWTYvePnyxIJDouf30c85vRBeSwnkyLBEeqh6pt3 2tbFSWeKwN+hRGDrLDsbdT2KHnB3PN+wzxD1ditpE7JYUfqTEhmxRVlBrHOdR2Ec3A60qJ JSlnmdm508sEl5iY2W3kuj282mj6v7Y= 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-163-ujEIcne4M42VAqocn6TrSQ-1; Tue, 17 Dec 2019 21:01:39 -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 82D46DB21 for ; Wed, 18 Dec 2019 02:01:38 +0000 (UTC) Received: from secure.mitica (ovpn-116-32.ams2.redhat.com [10.36.116.32]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3FA6519C58; Wed, 18 Dec 2019 02:01:36 +0000 (UTC) From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PATCH v2 06/10] migration: Add multifd-compress parameter Date: Wed, 18 Dec 2019 03:01:15 +0100 Message-Id: <20191218020119.3776-7-quintela@redhat.com> In-Reply-To: <20191218020119.3776-1-quintela@redhat.com> References: <20191218020119.3776-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: ujEIcne4M42VAqocn6TrSQ-1 X-Mimecast-Spam-Score: 0 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: Laurent Vivier , Thomas Huth , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Eduardo Habkost , Juan Quintela , "Dr. David Alan Gilbert" , Markus Armbruster , Paolo Bonzini Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Juan Quintela Acked-by: Markus Armbruster Reviewed-by: Dr. David Alan Gilbert --- Rename it to NONE Fix typos (dave) We don't need to chek values returned by visit_type_MultifdCompress (markus) Fix yet more typos (wei) --- hw/core/qdev-properties.c | 13 +++++++++++++ include/hw/qdev-properties.h | 3 +++ migration/migration.c | 13 +++++++++++++ monitor/hmp-cmds.c | 13 +++++++++++++ qapi/migration.json | 30 +++++++++++++++++++++++++++--- tests/migration-test.c | 13 ++++++++++--- 6 files changed, 79 insertions(+), 6 deletions(-) diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c index ac28890e5a..644705235e 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" @@ -648,6 +649,18 @@ const PropertyInfo qdev_prop_fdc_drive_type = { .set_default_value = set_default_value_enum, }; +/* --- MultifdCompress --- */ + +const PropertyInfo qdev_prop_multifd_compress = { + .name = "MultifdCompress", + .description = "multifd_compress values, " + "none", + .enum_table = &MultifdCompress_lookup, + .get = get_enum, + .set = set_enum, + .set_default_value = set_default_value_enum, +}; + /* --- pci address --- */ /* diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h index c6a8cb5516..07d7bba682 100644 --- a/include/hw/qdev-properties.h +++ b/include/hw/qdev-properties.h @@ -21,6 +21,7 @@ extern const PropertyInfo qdev_prop_tpm; extern const PropertyInfo qdev_prop_ptr; extern const PropertyInfo qdev_prop_macaddr; extern const PropertyInfo qdev_prop_on_off_auto; +extern const PropertyInfo qdev_prop_multifd_compress; extern const PropertyInfo qdev_prop_losttickpolicy; extern const PropertyInfo qdev_prop_blockdev_on_error; extern const PropertyInfo qdev_prop_bios_chs_trans; @@ -204,6 +205,8 @@ extern const PropertyInfo qdev_prop_pcie_link_width; DEFINE_PROP(_n, _s, _f, qdev_prop_macaddr, MACAddr) #define DEFINE_PROP_ON_OFF_AUTO(_n, _s, _f, _d) \ DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_on_off_auto, OnOffAuto) +#define DEFINE_PROP_MULTIFD_COMPRESS(_n, _s, _f, _d) \ + DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_multifd_compress, MultifdCompress) #define DEFINE_PROP_LOSTTICKPOLICY(_n, _s, _f, _d) \ DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_losttickpolicy, \ LostTickPolicy) diff --git a/migration/migration.c b/migration/migration.c index cf6cec5fb6..93c6ed10a6 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -87,6 +87,7 @@ /* The delay time (in ms) between two COLO checkpoints */ #define DEFAULT_MIGRATE_X_CHECKPOINT_DELAY (200 * 100) #define DEFAULT_MIGRATE_MULTIFD_CHANNELS 16 +#define DEFAULT_MIGRATE_MULTIFD_COMPRESS MULTIFD_COMPRESS_NONE /* Background transfer rate for postcopy, 0 means unlimited, note * that page requests can still exceed this limit. @@ -774,6 +775,8 @@ MigrationParameters *qmp_query_migrate_parameters(Error **errp) params->block_incremental = s->parameters.block_incremental; params->has_multifd_channels = true; params->multifd_channels = s->parameters.multifd_channels; + params->has_multifd_compress = true; + params->multifd_compress = s->parameters.multifd_compress; params->has_xbzrle_cache_size = true; params->xbzrle_cache_size = s->parameters.xbzrle_cache_size; params->has_max_postcopy_bandwidth = true; @@ -1281,6 +1284,9 @@ static void migrate_params_test_apply(MigrateSetParameters *params, if (params->has_multifd_channels) { dest->multifd_channels = params->multifd_channels; } + if (params->has_multifd_compress) { + dest->multifd_compress = params->multifd_compress; + } if (params->has_xbzrle_cache_size) { dest->xbzrle_cache_size = params->xbzrle_cache_size; } @@ -1377,6 +1383,9 @@ static void migrate_params_apply(MigrateSetParameters *params, Error **errp) if (params->has_multifd_channels) { s->parameters.multifd_channels = params->multifd_channels; } + if (params->has_multifd_compress) { + s->parameters.multifd_compress = params->multifd_compress; + } if (params->has_xbzrle_cache_size) { s->parameters.xbzrle_cache_size = params->xbzrle_cache_size; xbzrle_cache_resize(params->xbzrle_cache_size, errp); @@ -3474,6 +3483,9 @@ static Property migration_properties[] = { DEFINE_PROP_UINT8("multifd-channels", MigrationState, parameters.multifd_channels, DEFAULT_MIGRATE_MULTIFD_CHANNELS), + DEFINE_PROP_MULTIFD_COMPRESS("multifd-compress", MigrationState, + parameters.multifd_compress, + DEFAULT_MIGRATE_MULTIFD_COMPRESS), DEFINE_PROP_SIZE("xbzrle-cache-size", MigrationState, parameters.xbzrle_cache_size, DEFAULT_MIGRATE_XBZRLE_CACHE_SIZE), @@ -3564,6 +3576,7 @@ static void migration_instance_init(Object *obj) params->has_x_checkpoint_delay = true; params->has_block_incremental = true; params->has_multifd_channels = true; + params->has_multifd_compress = true; params->has_xbzrle_cache_size = true; params->has_max_postcopy_bandwidth = true; params->has_max_cpu_throttle = true; diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index b2551c16d1..caf06b0668 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" @@ -448,6 +449,9 @@ void hmp_info_migrate_parameters(Monitor *mon, const QDict *qdict) monitor_printf(mon, "%s: %u\n", MigrationParameter_str(MIGRATION_PARAMETER_MULTIFD_CHANNELS), params->multifd_channels); + monitor_printf(mon, "%s: %s\n", + MigrationParameter_str(MIGRATION_PARAMETER_MULTIFD_COMPRESS), + MultifdCompress_str(params->multifd_compress)); monitor_printf(mon, "%s: %" PRIu64 "\n", MigrationParameter_str(MIGRATION_PARAMETER_XBZRLE_CACHE_SIZE), params->xbzrle_cache_size); @@ -1739,6 +1743,7 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict) MigrateSetParameters *p = g_new0(MigrateSetParameters, 1); uint64_t valuebw = 0; uint64_t cache_size; + MultifdCompress compress_type; Error *err = NULL; int val, ret; @@ -1824,6 +1829,14 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict) p->has_multifd_channels = true; visit_type_int(v, param, &p->multifd_channels, &err); break; + case MIGRATION_PARAMETER_MULTIFD_COMPRESS: + p->has_multifd_compress = true; + visit_type_MultifdCompress(v, param, &compress_type, &err); + if (err) { + break; + } + p->multifd_compress = compress_type; + break; case MIGRATION_PARAMETER_XBZRLE_CACHE_SIZE: p->has_xbzrle_cache_size = true; visit_type_size(v, param, &cache_size, &err); diff --git a/qapi/migration.json b/qapi/migration.json index b7348d0c8b..430a39382e 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -488,6 +488,19 @@ ## { 'command': 'query-migrate-capabilities', 'returns': ['MigrationCapabilityStatus']} +## +# @MultifdCompress: +# +# An enumeration of multifd compression. +# +# @none: no compression. +# +# Since: 4.1 +# +## +{ 'enum': 'MultifdCompress', + 'data': [ 'none' ] } + ## # @MigrationParameter: # @@ -586,6 +599,9 @@ # @max-cpu-throttle: maximum cpu throttle percentage. # Defaults to 99. (Since 3.1) # +# @multifd-compress: Which compression method to use. +# Defaults to none. (Since 4.1) +# # Since: 2.4 ## { 'enum': 'MigrationParameter', @@ -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-compress' ] } ## # @MigrateSetParameters: @@ -688,6 +704,9 @@ # @max-cpu-throttle: maximum cpu throttle percentage. # The default value is 99. (Since 3.1) # +# @multifd-compress: Which compression method to use. +# Defaults to none. (Since 4.1) +# # Since: 2.4 ## # TODO either fuse back into MigrationParameters, or make @@ -713,7 +732,8 @@ '*multifd-channels': 'int', '*xbzrle-cache-size': 'size', '*max-postcopy-bandwidth': 'size', - '*max-cpu-throttle': 'int' } } + '*max-cpu-throttle': 'int', + '*multifd-compress': 'MultifdCompress' } } ## # @migrate-set-parameters: @@ -823,6 +843,9 @@ # Defaults to 99. # (Since 3.1) # +# @multifd-compress: Which compression method to use. +# Defaults to none. (Since 4.1) +# # Since: 2.4 ## { 'struct': 'MigrationParameters', @@ -846,7 +869,8 @@ '*multifd-channels': 'uint8', '*xbzrle-cache-size': 'size', '*max-postcopy-bandwidth': 'size', - '*max-cpu-throttle':'uint8'} } + '*max-cpu-throttle': 'uint8', + '*multifd-compress': 'MultifdCompress' } } ## # @query-migrate-parameters: diff --git a/tests/migration-test.c b/tests/migration-test.c index fc221f172a..e5b6e54cfa 100644 --- a/tests/migration-test.c +++ b/tests/migration-test.c @@ -482,7 +482,6 @@ static void migrate_check_parameter_str(QTestState *who, const char *parameter, g_free(result); } -__attribute__((unused)) static void migrate_set_parameter_str(QTestState *who, const char *parameter, const char *value) { @@ -1398,7 +1397,7 @@ static void test_migrate_auto_converge(void) test_migrate_end(from, to, true); } -static void test_multifd_tcp(void) +static void test_multifd_tcp(const char *method) { MigrateStart *args = migrate_start_new(); QTestState *from, *to; @@ -1422,6 +1421,9 @@ static void test_multifd_tcp(void) migrate_set_parameter_int(from, "multifd-channels", 16); migrate_set_parameter_int(to, "multifd-channels", 16); + migrate_set_parameter_str(from, "multifd-compress", method); + migrate_set_parameter_str(to, "multifd-compress", method); + migrate_set_capability(from, "multifd", "true"); migrate_set_capability(to, "multifd", "true"); @@ -1453,6 +1455,11 @@ static void test_multifd_tcp(void) free(uri); } +static void test_multifd_tcp_none(void) +{ + test_multifd_tcp("none"); +} + int main(int argc, char **argv) { char template[] = "/tmp/migration-test-XXXXXX"; @@ -1517,7 +1524,7 @@ int main(int argc, char **argv) test_validate_uuid_dst_not_set); 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); ret = g_test_run(); From patchwork Wed Dec 18 02:01:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 11299343 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 605B913B6 for ; Wed, 18 Dec 2019 02:08:26 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 261CA21582 for ; Wed, 18 Dec 2019 02:08:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="g/mQBGqV" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 261CA21582 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:48476 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihOlF-0002tG-1j for patchwork-qemu-devel@patchwork.kernel.org; Tue, 17 Dec 2019 21:08:25 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52564) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihOeo-00032X-FZ for qemu-devel@nongnu.org; Tue, 17 Dec 2019 21:01:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ihOem-0005nz-H8 for qemu-devel@nongnu.org; Tue, 17 Dec 2019 21:01:46 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:21843 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 1ihOel-0005mc-U0 for qemu-devel@nongnu.org; Tue, 17 Dec 2019 21:01:44 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576634503; 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=JCF79OgkifHXkDZ6UIDSsQbkPYWximap7jUWIkoikGY=; b=g/mQBGqVjN7AU7GZau2PD7WqGQfod28jZf7gHUj2UXbAvohM8R1JP0XMSx7Se/xNeuG52V T0dcKTmUGDuHyrB5KBCS+hMSCwarxx+OzaccuXJH1hK7coe9gMTvWbrLb8Hf2DWihTcLwX FIevqRxEWsMrWynisxt0GXSDLA6wuGg= 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-108-RadDFdAPPACTLQ1MIch5EA-1; Tue, 17 Dec 2019 21:01: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 1CD3C1809A2A for ; Wed, 18 Dec 2019 02:01:41 +0000 (UTC) Received: from secure.mitica (ovpn-116-32.ams2.redhat.com [10.36.116.32]) by smtp.corp.redhat.com (Postfix) with ESMTP id D523819C58; Wed, 18 Dec 2019 02:01:38 +0000 (UTC) From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PATCH v2 07/10] migration: Make no compression operations into its own structure Date: Wed, 18 Dec 2019 03:01:16 +0100 Message-Id: <20191218020119.3776-8-quintela@redhat.com> In-Reply-To: <20191218020119.3776-1-quintela@redhat.com> References: <20191218020119.3776-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: RadDFdAPPACTLQ1MIch5EA-1 X-Mimecast-Spam-Score: 0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] 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: Laurent Vivier , Thomas Huth , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Eduardo Habkost , Juan Quintela , "Dr. David Alan Gilbert" , Markus Armbruster , Paolo Bonzini Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" It will be used later. Signed-off-by: Juan Quintela --- Move setup of ->ops helper to proper place (wei) Rename s/none/nocomp/ (dave) Introduce MULTIFD_FLAG_NOCOMP --- migration/migration.c | 9 ++ migration/migration.h | 1 + migration/ram.c | 194 ++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 196 insertions(+), 8 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 93c6ed10a6..56203eb536 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -2213,6 +2213,15 @@ int migrate_multifd_channels(void) return s->parameters.multifd_channels; } +int migrate_multifd_method(void) +{ + MigrationState *s; + + s = migrate_get_current(); + + return s->parameters.multifd_compress; +} + int migrate_use_xbzrle(void) { MigrationState *s; diff --git a/migration/migration.h b/migration/migration.h index 545f283ae7..d3ea45e25a 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -299,6 +299,7 @@ bool migrate_auto_converge(void); bool migrate_use_multifd(void); bool migrate_pause_before_switchover(void); int migrate_multifd_channels(void); +int migrate_multifd_method(void); int migrate_use_xbzrle(void); int64_t migrate_xbzrle_cache_size(void); diff --git a/migration/ram.c b/migration/ram.c index fcf50e648a..10661e03ae 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -44,6 +44,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" @@ -581,6 +582,7 @@ exit: #define MULTIFD_VERSION 1 #define MULTIFD_FLAG_SYNC (1 << 0) +#define MULTIFD_FLAG_NOCOMP (1 << 1) /* This value needs to be a multiple of qemu_target_page_size() */ #define MULTIFD_PACKET_SIZE (512 * 1024) @@ -662,6 +664,8 @@ typedef struct { uint64_t num_pages; /* syncs main thread and channels */ QemuSemaphore sem_sync; + /* used for compression methods */ + void *data; } MultiFDSendParams; typedef struct { @@ -699,8 +703,153 @@ typedef struct { uint64_t num_pages; /* syncs main thread and channels */ QemuSemaphore sem_sync; + /* used for de-compression methods */ + void *data; } MultiFDRecvParams; +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; + +/* 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 = used * qemu_target_page_size(); + p->flags |= 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) +{ + if (p->flags != MULTIFD_FLAG_NOCOMP) { + error_setg(errp, "multifd %d: flags received %x flags expected %x", + p->id, MULTIFD_FLAG_NOCOMP, p->flags); + return -1; + } + return qio_channel_readv_all(p->c, p->pages->iov, used, errp); +} + +static MultiFDMethods multifd_nocomp_ops = { + .send_setup = nocomp_send_setup, + .send_cleanup = nocomp_send_cleanup, + .send_prepare = nocomp_send_prepare, + .send_write = nocomp_send_write, + .recv_setup = nocomp_recv_setup, + .recv_cleanup = nocomp_recv_cleanup, + .recv_pages = nocomp_recv_pages +}; + +static MultiFDMethods *multifd_ops[MULTIFD_COMPRESS__MAX] = { + [MULTIFD_COMPRESS_NONE] = &multifd_nocomp_ops, +}; + static int multifd_send_initial_packet(MultiFDSendParams *p, Error **errp) { MultiFDInit_t msg; @@ -898,6 +1047,8 @@ struct { uint64_t packet_num; /* send channels ready */ QemuSemaphore channels_ready; + /* multifd ops */ + MultiFDMethods *ops; } *multifd_send_state; /* @@ -1027,6 +1178,7 @@ void multifd_save_cleanup(void) multifd_send_terminate_threads(NULL); for (i = 0; i < migrate_multifd_channels(); i++) { MultiFDSendParams *p = &multifd_send_state->params[i]; + Error *local_err = NULL; if (p->running) { qemu_thread_join(&p->thread); @@ -1043,6 +1195,10 @@ void multifd_save_cleanup(void) p->packet_len = 0; g_free(p->packet); p->packet = 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); @@ -1123,7 +1279,14 @@ static void *multifd_send_thread(void *opaque) uint64_t packet_num = p->packet_num; flags = p->flags; - p->next_packet_size = used * qemu_target_page_size(); + if (used) { + ret = multifd_send_state->ops->send_prepare(p, used, + &local_err); + if (ret != 0) { + qemu_mutex_unlock(&p->mutex); + break; + } + } multifd_send_fill_packet(p); p->flags = 0; p->num_packets++; @@ -1140,8 +1303,7 @@ static void *multifd_send_thread(void *opaque) } if (used) { - ret = qio_channel_writev_all(p->c, p->pages->iov, - used, &local_err); + ret = multifd_send_state->ops->send_write(p, used, &local_err); if (ret != 0) { break; } @@ -1212,6 +1374,7 @@ int multifd_save_setup(Error **errp) { int thread_count; uint32_t page_count = MULTIFD_PACKET_SIZE / qemu_target_page_size(); + int ret = 0; uint8_t i; if (!migrate_use_multifd()) { @@ -1222,9 +1385,11 @@ int multifd_save_setup(Error **errp) multifd_send_state->params = g_new0(MultiFDSendParams, thread_count); multifd_send_state->pages = multifd_pages_init(page_count); qemu_sem_init(&multifd_send_state->channels_ready, 0); + multifd_send_state->ops = multifd_ops[migrate_multifd_method()]; for (i = 0; i < thread_count; i++) { MultiFDSendParams *p = &multifd_send_state->params[i]; + int res; qemu_mutex_init(&p->mutex); qemu_sem_init(&p->sem, 0); @@ -1240,8 +1405,12 @@ int multifd_save_setup(Error **errp) p->packet->version = cpu_to_be32(MULTIFD_VERSION); p->name = g_strdup_printf("multifdsend_%d", i); socket_send_channel_create(multifd_new_send_channel_async, p); + res = multifd_send_state->ops->send_setup(p, errp); + if (ret == 0) { + ret = res; + } } - return 0; + return ret; } struct { @@ -1252,6 +1421,8 @@ struct { QemuSemaphore sem_sync; /* global number of generated multifd packets */ uint64_t packet_num; + /* multifd ops */ + MultiFDMethods *ops; } *multifd_recv_state; static void multifd_recv_terminate_threads(Error *err) @@ -1287,7 +1458,6 @@ static void multifd_recv_terminate_threads(Error *err) int multifd_load_cleanup(Error **errp) { int i; - int ret = 0; if (!migrate_use_multifd()) { return 0; @@ -1316,6 +1486,7 @@ int multifd_load_cleanup(Error **errp) p->packet_len = 0; g_free(p->packet); p->packet = NULL; + multifd_recv_state->ops->recv_cleanup(p); } qemu_sem_destroy(&multifd_recv_state->sem_sync); g_free(multifd_recv_state->params); @@ -1323,7 +1494,7 @@ int multifd_load_cleanup(Error **errp) g_free(multifd_recv_state); multifd_recv_state = NULL; - return ret; + return 0; } static void multifd_recv_sync_main(void) @@ -1388,6 +1559,8 @@ static void *multifd_recv_thread(void *opaque) used = p->pages->used; flags = p->flags; + /* recv methods don't know how to handle the SYNC flag */ + p->flags &= ~MULTIFD_FLAG_SYNC; trace_multifd_recv(p->id, p->packet_num, used, flags, p->next_packet_size); p->num_packets++; @@ -1395,8 +1568,7 @@ static void *multifd_recv_thread(void *opaque) qemu_mutex_unlock(&p->mutex); if (used) { - ret = qio_channel_readv_all(p->c, p->pages->iov, - used, &local_err); + ret = multifd_recv_state->ops->recv_pages(p, used, &local_err); if (ret != 0) { break; } @@ -1435,9 +1607,11 @@ int multifd_load_setup(Error **errp) multifd_recv_state->params = 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 = multifd_ops[migrate_multifd_method()]; for (i = 0; i < thread_count; i++) { MultiFDRecvParams *p = &multifd_recv_state->params[i]; + int ret; qemu_mutex_init(&p->mutex); qemu_sem_init(&p->sem_sync, 0); @@ -1448,6 +1622,10 @@ int multifd_load_setup(Error **errp) + sizeof(ram_addr_t) * page_count; p->packet = g_malloc0(p->packet_len); p->name = g_strdup_printf("multifdrecv_%d", i); + ret = multifd_recv_state->ops->recv_setup(p, errp); + if (ret != 0) { + return ret; + } } return 0; } From patchwork Wed Dec 18 02:01:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 11299353 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 231E814B7 for ; Wed, 18 Dec 2019 02:10:35 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EBAC921582 for ; Wed, 18 Dec 2019 02:10:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="RLfoi1yT" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EBAC921582 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:48508 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihOnJ-0005Yd-Md for patchwork-qemu-devel@patchwork.kernel.org; Tue, 17 Dec 2019 21:10:33 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52790) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihOet-00038z-N0 for qemu-devel@nongnu.org; Tue, 17 Dec 2019 21:01:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ihOes-0005wK-Hd for qemu-devel@nongnu.org; Tue, 17 Dec 2019 21:01:51 -0500 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:42585 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 1ihOes-0005vb-Df for qemu-devel@nongnu.org; Tue, 17 Dec 2019 21:01:50 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576634510; 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=b2vemv0zRpYDz/uUdckp1sNwESkzjwYs9euWZf0G7CM=; b=RLfoi1yT1XEqKX9K2iKqFTsQfDvnKYXWp3TwMnS1Mvn3TQNVYqcwMPi8nnv6gqNUMfQ7TE qGeAJOpLoBDBbMjLJH9lMaLRb6EH7Z1c9D1RDT5f6AScGhR5nVic/vAi87NCuncDQsNoxr 3Uz/N0/OnR0/UF06muvFQvLW5J2EXmA= 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-349-TJbZOpZnOUOg9uRxdwQerA-1; Tue, 17 Dec 2019 21:01:47 -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 4D112100550E for ; Wed, 18 Dec 2019 02:01:46 +0000 (UTC) Received: from secure.mitica (ovpn-116-32.ams2.redhat.com [10.36.116.32]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0E6CD19C58; Wed, 18 Dec 2019 02:01:43 +0000 (UTC) From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PATCH v2 09/10] configure: Enable test and libs for zstd Date: Wed, 18 Dec 2019 03:01:18 +0100 Message-Id: <20191218020119.3776-10-quintela@redhat.com> In-Reply-To: <20191218020119.3776-1-quintela@redhat.com> References: <20191218020119.3776-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: TJbZOpZnOUOg9uRxdwQerA-1 X-Mimecast-Spam-Score: 0 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: Laurent Vivier , Thomas Huth , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Eduardo Habkost , Juan Quintela , "Dr. David Alan Gilbert" , Markus Armbruster , Paolo Bonzini Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Juan Quintela --- configure | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/configure b/configure index 84b413dbfc..a8f3027c67 100755 --- a/configure +++ b/configure @@ -447,6 +447,7 @@ lzo="" snappy="" bzip2="" lzfse="" +zstd="" guest_agent="" guest_agent_with_vss="no" guest_agent_ntddscsi="no" @@ -1341,6 +1342,10 @@ for opt do ;; --disable-lzfse) lzfse="no" ;; + --disable-zstd) zstd="no" + ;; + --enable-zstd) zstd="yes" + ;; --enable-guest-agent) guest_agent="yes" ;; --disable-guest-agent) guest_agent="no" @@ -1788,6 +1793,8 @@ disabled with --disable-FEATURE, default is enabled if 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 @@ -2401,6 +2408,24 @@ EOF fi fi +########################################## +# zstd check + +if test "$zstd" != "no" ; then + if $pkg_config --exist libzstd ; then + zstd_cflags="$($pkg_config --cflags libzstd)" + zstd_libs="$($pkg_config --libs libzstd)" + LIBS="$zstd_libs $LIBS" + QEMU_CFLAGS="$QEMU_CFLAGS $zstd_cflags" + zstd="yes" + else + if test "$zstd" = "yes" ; then + feature_not_found "libzstd" "Install libzstd devel" + fi + zstd="no" + fi +fi + ########################################## # libseccomp check @@ -6535,6 +6560,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" @@ -7102,6 +7128,10 @@ if test "$lzfse" = "yes" ; then echo "LZFSE_LIBS=-llzfse" >> $config_host_mak fi +if test "$zstd" = "yes" ; then + echo "CONFIG_ZSTD=y" >> $config_host_mak +fi + if test "$libiscsi" = "yes" ; then echo "CONFIG_LIBISCSI=m" >> $config_host_mak echo "LIBISCSI_CFLAGS=$libiscsi_cflags" >> $config_host_mak From patchwork Wed Dec 18 02:01:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 11299359 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A372E14B7 for ; Wed, 18 Dec 2019 02:12:33 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 67F8321582 for ; Wed, 18 Dec 2019 02:12:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="gK3h/Vq4" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 67F8321582 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:48524 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihOpE-0007ow-Ix for patchwork-qemu-devel@patchwork.kernel.org; Tue, 17 Dec 2019 21:12:32 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52957) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihOev-0003Bi-N6 for qemu-devel@nongnu.org; Tue, 17 Dec 2019 21:01:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ihOet-0005yp-PF for qemu-devel@nongnu.org; Tue, 17 Dec 2019 21:01:53 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:37752 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 1ihOet-0005xa-K2 for qemu-devel@nongnu.org; Tue, 17 Dec 2019 21:01:51 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576634511; 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=K73i1xFaBt3L7a/Q1hsX6M6ZSoHf01uwOXYScWoiKYw=; b=gK3h/Vq479sCGWZXnnW+BhY+TfSquoMK+BxbWPZu++8B7d+/wGOaxVn2xV+hgIt8RpHTvq yanQ7q9E+R9CMtqrsnTIqf3KgJKi8KIyMYhmirtfQyMQfTkrPn7Wxn7WCbY9qc8pv7kC+R 2xCNpOWW0qu5t9gI7GFPXdGGs3zpqY0= 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-411-Z3pq1oYDOX2oOltm7lOfrA-1; Tue, 17 Dec 2019 21:01:49 -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 E5469107ACC5 for ; Wed, 18 Dec 2019 02:01:48 +0000 (UTC) Received: from secure.mitica (ovpn-116-32.ams2.redhat.com [10.36.116.32]) by smtp.corp.redhat.com (Postfix) with ESMTP id A091919C58; Wed, 18 Dec 2019 02:01:46 +0000 (UTC) From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PATCH v2 10/10] migration: Add zstd compression multifd support Date: Wed, 18 Dec 2019 03:01:19 +0100 Message-Id: <20191218020119.3776-11-quintela@redhat.com> In-Reply-To: <20191218020119.3776-1-quintela@redhat.com> References: <20191218020119.3776-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: Z3pq1oYDOX2oOltm7lOfrA-1 X-Mimecast-Spam-Score: 0 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: Laurent Vivier , Thomas Huth , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Eduardo Habkost , Juan Quintela , "Dr. David Alan Gilbert" , Markus Armbruster , Paolo Bonzini Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Juan Quintela --- hw/core/qdev-properties.c | 2 +- migration/ram.c | 288 ++++++++++++++++++++++++++++++++++++++ qapi/migration.json | 2 +- tests/migration-test.c | 6 + 4 files changed, 296 insertions(+), 2 deletions(-) diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c index e8ff317a60..b75467704f 100644 --- a/hw/core/qdev-properties.c +++ b/hw/core/qdev-properties.c @@ -654,7 +654,7 @@ const PropertyInfo qdev_prop_fdc_drive_type = { const PropertyInfo qdev_prop_multifd_compress = { .name = "MultifdCompress", .description = "multifd_compress values, " - "none/zlib", + "none/zlib/zstd", .enum_table = &MultifdCompress_lookup, .get = get_enum, .set = set_enum, diff --git a/migration/ram.c b/migration/ram.c index 5006d719b4..db90237977 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -29,6 +29,9 @@ #include "qemu/osdep.h" #include "cpu.h" #include +#ifdef CONFIG_ZSTD +#include +#endif #include "qemu/cutils.h" #include "qemu/bitops.h" #include "qemu/bitmap.h" @@ -584,6 +587,7 @@ exit: #define MULTIFD_FLAG_SYNC (1 << 0) #define MULTIFD_FLAG_NOCOMP (1 << 1) #define MULTIFD_FLAG_ZLIB (1 << 2) +#define MULTIFD_FLAG_ZSTD (1 << 3) /* This value needs to be a multiple of qemu_target_page_size() */ #define MULTIFD_PACKET_SIZE (512 * 1024) @@ -635,6 +639,22 @@ struct zlib_data { uint32_t zbuff_len; }; +#ifdef CONFIG_ZSTD +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; +}; +#endif + typedef struct { /* this fields are not changed once the thread is created */ /* channel number */ @@ -1109,9 +1129,277 @@ static MultiFDMethods multifd_zlib_ops = { .recv_pages = zlib_recv_pages }; +#ifdef CONFIG_ZSTD +/* 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 = MULTIFD_PACKET_SIZE / qemu_target_page_size(); + struct zstd_data *z = g_new0(struct zstd_data, 1); + int res; + + p->data = z; + z->zcs = ZSTD_createCStream(); + if (!z->zcs) { + g_free(z); + error_setg(errp, "multifd %d: zstd createCStream failed", p->id); + return -1; + } + + res = ZSTD_initCStream(z->zcs, migrate_compress_level()); + if (ZSTD_isError(res)) { + ZSTD_freeCStream(z->zcs); + g_free(z); + error_setg(errp, "multifd %d: initCStream failed", p->id); + return -1; + } + /* We will never have more than page_count pages */ + z->zbuff_len = page_count * qemu_target_page_size(); + z->zbuff_len *= 2; + z->zbuff = 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 = p->data; + + ZSTD_freeCStream(z->zcs); + z->zcs = NULL; + g_free(z->zbuff); + z->zbuff = NULL; + g_free(p->data); + p->data = 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 = p->pages->iov; + struct zstd_data *z = p->data; + int ret; + uint32_t i; + + z->out.dst = z->zbuff; + z->out.size = z->zbuff_len; + z->out.pos = 0; + + for (i = 0; i < used; i++) { + ZSTD_EndDirective flush = ZSTD_e_continue; + + if (i == used - 1) { + flush = ZSTD_e_flush; + } + z->in.src = iov[i].iov_base; + z->in.size = iov[i].iov_len; + z->in.pos = 0; + + ret = ZSTD_compressStream2(z->zcs, &z->out, &z->in, flush); + if (ZSTD_isError(ret)) { + error_setg(errp, "multifd %d: compressStream error %s", + p->id, ZSTD_getErrorName(ret)); + return -1; + } + } + p->next_packet_size = z->out.pos; + p->flags |= 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 **errp) +{ + struct zstd_data *z = p->data; + + return qio_channel_write_all(p->c, (void *)z->zbuff, p->next_packet_size, + 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 = MULTIFD_PACKET_SIZE / qemu_target_page_size(); + struct zstd_data *z = g_new0(struct zstd_data, 1); + int res; + + p->data = z; + z->zds = ZSTD_createDStream(); + if (!z->zds) { + g_free(z); + error_setg(errp, "multifd %d: zstd createDStream failed", p->id); + return -1; + } + + res = ZSTD_initDStream(z->zds); + if (ZSTD_isError(res)) { + ZSTD_freeDStream(z->zds); + g_free(z); + error_setg(errp, "multifd %d: initDStream failed", p->id); + return -1; + } + + /* We will never have more than page_count pages */ + z->zbuff_len = page_count * qemu_target_page_size(); + /* We know compression "could" use more space */ + z->zbuff_len *= 2; + z->zbuff = 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 = p->data; + + ZSTD_freeDStream(z->zds); + z->zds = NULL; + g_free(z->zbuff); + z->zbuff = NULL; + g_free(p->data); + p->data = 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 **errp) +{ + uint32_t in_size = p->next_packet_size; + uint32_t out_size = 0; + uint32_t expected_size = used * qemu_target_page_size(); + struct zstd_data *z = p->data; + int ret; + int i; + + if (p->flags != MULTIFD_FLAG_ZSTD) { + error_setg(errp, "multifd %d: flags received %x flags expected %x", + p->id, MULTIFD_FLAG_ZSTD, p->flags); + return -1; + } + ret = qio_channel_read_all(p->c, (void *)z->zbuff, in_size, errp); + + if (ret != 0) { + return ret; + } + + z->in.src = z->zbuff; + z->in.size = in_size; + z->in.pos = 0; + + for (i = 0; i < used; i++) { + struct iovec *iov = &p->pages->iov[i]; + + z->out.dst = iov->iov_base; + z->out.size = iov->iov_len; + z->out.pos = 0; + + ret = ZSTD_decompressStream(z->zds, &z->out, &z->in); + if (ZSTD_isError(ret)) { + error_setg(errp, "multifd %d: decompressStream returned %s", + p->id, ZSTD_getErrorName(ret)); + return ret; + } + out_size += iov->iov_len; + } + if (out_size != expected_size) { + error_setg(errp, "multifd %d: packet size received %d size expected %d", + p->id, out_size, expected_size); + return -1; + } + return 0; +} + +static MultiFDMethods multifd_zstd_ops = { + .send_setup = zstd_send_setup, + .send_cleanup = zstd_send_cleanup, + .send_prepare = zstd_send_prepare, + .send_write = zstd_send_write, + .recv_setup = zstd_recv_setup, + .recv_cleanup = zstd_recv_cleanup, + .recv_pages = zstd_recv_pages +}; +#endif /* CONFIG_ZSTD */ + static MultiFDMethods *multifd_ops[MULTIFD_COMPRESS__MAX] = { [MULTIFD_COMPRESS_NONE] = &multifd_nocomp_ops, [MULTIFD_COMPRESS_ZLIB] = &multifd_zlib_ops, +#ifdef CONFIG_ZSTD + [MULTIFD_COMPRESS_ZSTD] = &multifd_zstd_ops, +#endif }; static int multifd_send_initial_packet(MultiFDSendParams *p, Error **errp) diff --git a/qapi/migration.json b/qapi/migration.json index 0e3a3db8d0..1b827e55b6 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -499,7 +499,7 @@ # ## { 'enum': 'MultifdCompress', - 'data': [ 'none', 'zlib' ] } + 'data': [ 'none', 'zlib', 'zstd' ] } ## # @MigrationParameter: diff --git a/tests/migration-test.c b/tests/migration-test.c index 8985e05c69..7588f50b9b 100644 --- a/tests/migration-test.c +++ b/tests/migration-test.c @@ -1465,6 +1465,11 @@ static void test_multifd_tcp_zlib(void) test_multifd_tcp("zlib"); } +static void test_multifd_tcp_zstd(void) +{ + test_multifd_tcp("zstd"); +} + int main(int argc, char **argv) { char template[] = "/tmp/migration-test-XXXXXX"; @@ -1531,6 +1536,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/zlib", test_multifd_tcp_zlib); + qtest_add_func("/migration/multifd/tcp/zstd", test_multifd_tcp_zstd); ret = g_test_run();