From nobody Mon May 6 20:45:07 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 ARC-Seal: i=1; a=rsa-sha256; t=1576634980; cv=none; d=zohomail.com; s=zohoarc; b=nwzK8kob7RwpXwgMSq0vSyuxUVG3iFy3bzTA2WF5+U4B409j9mvETs55U2i32Sv8fM6wiQCF9quWsA4BbxaWgSPnyjoT4na3MuvElHxpOX+Ade9PhRWIXr4iPjJ/NVf2E0mPN6NgwK9eYE94PROYRafpY7RMbZxdMW3/SzowcyQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576634980; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Pe09oFj+dplfSAmWzK13nOJ+j8pDv/xrYGnj1YjPya4=; b=GVCCzPAJwDELH1kEjgqBtq4LH7eFj5hLudY3VQ/StggAq2r1vbZ0gfKEKS3cqyfNtAvJGu+6JTiGO8OUbM3wKvzm6AJRx1PxN2f94WfBPd2NKJc3MVC9vYZ8IGtKw6WUNsQbuCn3+m10cgs+vUV38dGgac/kp8eKN4CQiGBRJzc= ARC-Authentication-Results: i=1; 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 header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1576634980496999.3462811622887; Tue, 17 Dec 2019 18:09:40 -0800 (PST) Received: from localhost ([::1]:48482 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihOmQ-0003s5-Vn for importer@patchew.org; Tue, 17 Dec 2019 21:09:39 -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 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) 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= 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 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: 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=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , Juan Quintela , "Dr. David Alan Gilbert" , Markus Armbruster , Paolo Bonzini 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" 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 @@ =20 /* 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 =20 /* Background transfer rate for postcopy, 0 means unlimited, note * that page requests can still exceed this limit. --=20 2.23.0 From nobody Mon May 6 20:45:07 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 ARC-Seal: i=1; a=rsa-sha256; t=1576634845; cv=none; d=zohomail.com; s=zohoarc; b=cuelYRADPrpDHFXMw1aHcqwZmdCTDMJz2Ubiajx1axEwj6zESXKNyLQ1QzbfkZzAkyMdGLUh//oaN/F+RwFS+t63dNZPXiC52KoSyg/JVkI7ogRD1js0/MqX0AYou84kprp8HKwOis1uW/MSeHx6tNoVQ153egk75SNrSQMqLeQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576634845; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=AbVUoPWAQnOweIpazKXxx/LAkrdliiYL/S22zpBO/sQ=; b=dn1stsja21/RhDiK+8gxNkl9GEnDmyZr0kTPbfTE/pJlhu9/kFXBM/X+zYJV/bruWgJ0Xziew/kFwKd6xNOUZzeJBeKkAVInIwa0ZdV/8BHDgZUQU6/Z97rmGOo4uotGSaRzsqznt5NqRdQlaZ/avF829eZZRUb6o+qkMxdrbMQ= ARC-Authentication-Results: i=1; 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 header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1576634845959402.19348021540577; Tue, 17 Dec 2019 18:07:25 -0800 (PST) Received: from localhost ([::1]:48462 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihOkG-0001CN-EQ for importer@patchew.org; Tue, 17 Dec 2019 21:07:24 -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 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) 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= 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 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: Laurent Vivier , Thomas Huth , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , Juan Quintela , "Dr. David Alan Gilbert" , Markus Armbruster , Wei Yang , Paolo Bonzini 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" 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); } =20 +static void test_multifd_tcp(void) +{ + MigrateStart *args =3D 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 =3D 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 =3D 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[] =3D "/tmp/migration-test-XXXXXX"; @@ -1425,6 +1480,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); =20 ret =3D g_test_run(); =20 --=20 2.23.0 From nobody Mon May 6 20:45:07 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 ARC-Seal: i=1; a=rsa-sha256; t=1576635118; cv=none; d=zohomail.com; s=zohoarc; b=hDQWZGczbeNBRb7595FPxQzleCrzWPaNjVvtuKMQK+XNRErIy/8ljbobhqH8K8OTQXpJpNChHdd1Iv31tt/sKevpggJnBqXsfjo5Sul71Jt4WLoguzzJNHqFHZwKULix0DnHjFF8nIuvvXY1lWaZTTMyXRSnQZIzMEYUxv/AzK4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576635118; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=mv2SnFdQsuqDIHEqHijU1eHiBdKn1tQVskm301BhwCk=; b=KvFdB56w80itI1ljEXH0cX0DmYPD6Fqsi+04t5JT1H4IBMCAmxm2s0LMeHXIOaW6DaQ5lg/KkZhIvm2QaxVGiWC7JxDEyOAn3xmpF5+DmNI6Q4ERDVE1ishTS2ytHbem9BYrh2stNLbLs88IWtO7H1Mij9p8Ahyg8whYb2gOQg0= ARC-Authentication-Results: i=1; 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 header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1576635118678820.6522186352043; Tue, 17 Dec 2019 18:11:58 -0800 (PST) Received: from localhost ([::1]:48512 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihOof-0006mE-Hs for importer@patchew.org; Tue, 17 Dec 2019 21:11:57 -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 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) 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= 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 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: 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=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , Juan Quintela , "Dr. David Alan Gilbert" , Markus Armbruster , Paolo Bonzini 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 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); } =20 +static char *migrate_get_parameter_str(QTestState *who, + const char *parameter) +{ + QDict *rsp; + char *result; + + rsp =3D wait_command(who, "{ 'execute': 'query-migrate-parameters' }"); + result =3D g_strdup(qdict_get_str(rsp, parameter)); + qobject_unref(rsp); + return result; +} + +static void migrate_check_parameter_str(QTestState *who, const char *param= eter, + const char *value) +{ + char *result; + + result =3D migrate_get_parameter_str(who, parameter); + g_assert_cmpstr(result, =3D=3D, value); + g_free(result); +} + +__attribute__((unused)) +static void migrate_set_parameter_str(QTestState *who, const char *paramet= er, + const char *value) +{ + QDict *rsp; + + rsp =3D 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; --=20 2.23.0 From nobody Mon May 6 20:45:07 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 ARC-Seal: i=1; a=rsa-sha256; t=1576634812; cv=none; d=zohomail.com; s=zohoarc; b=UDpxBHu4wU8ngKxtkjrRIz4sRUDfyW8j6yoPjKzCMWGyiacniIIk5PpFOH3yZiuDtoM4/zx5OA/KSxw0GWJVa/9DK6i0Z724SC5/OPO1CoPR/vPHgXKsi571wOqktSWTAnOh0HbSGkwl7Wp/qh4x7BFuJSQ81QeIzl+5iXQoZmM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576634812; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=gvvZhu/xFvz1U3Hf+/Yigdo8O7qRPkr3UgL8NVTZMng=; b=cY3oYgefsW8XJGZPP3slRtl1r0UynLti0KdifFWW+cK+WlOvQ1Vq+Xg+tyvdzVvOr2facQB1pPPx3dIebMIraoqKMtYyqHiYW5nbphtQyBaNTXaQO1hJ9KoEW1CAhLF16kyd4S91APKmMw6d3im4l3pvLtJQJI9tQgUgh5GhQD4= ARC-Authentication-Results: i=1; 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 header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1576634812372350.87401708993514; Tue, 17 Dec 2019 18:06:52 -0800 (PST) Received: from localhost ([::1]:48458 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihOji-0000Hq-TJ for importer@patchew.org; Tue, 17 Dec 2019 21:06:50 -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 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) 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= 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 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: Laurent Vivier , Thomas Huth , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , Juan Quintela , "Dr. David Alan Gilbert" , Markus Armbruster , Paolo Bonzini 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 --- 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 *err= or_in) return; } =20 - if (multifd_save_setup() !=3D 0) { + if (multifd_save_setup(&error_in) !=3D 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 *t= ask, gpointer opaque) } } =20 -int multifd_save_setup(void) +int multifd_save_setup(Error **errp) { int thread_count; uint32_t page_count =3D 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); =20 -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); --=20 2.23.0 From nobody Mon May 6 20:45:07 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 ARC-Seal: i=1; a=rsa-sha256; t=1576634941; cv=none; d=zohomail.com; s=zohoarc; b=leSgedOlF7JF3to8h5LoEhf0DhYweB736lJvoKRrXCvIkpfNfNSb8A6SryFlExJEO17FNFMPnlv+D7wwY5daCgyTForXKbaAq95OmQjUsoot+qibOOh6ehZ+3Qe2AW1iA/ty7iQGSXpCevADl7oOZfWYioc98XZBJZCwMupSzSc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576634941; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=IqM3Kq9hFeOHL8zFMDTIxhzsJBYbrbpYhbnBIsEKtNc=; b=ESPAfx9QLhOYhUS95zwMHf/Rrsb/UKb1zeJXyAZUUUHAUB8Edmb6ujsm4v8PlhpDcoASsu8h1JCHAjCIfyFnpiHplnvqSlLSag3PbQ5L5pBsIgQjM5LyR9dIAiYilU4MNpmL0D3d2Jrmo5QxgzcO7Ykb2khivd1ljUxfIjdEz14= ARC-Authentication-Results: i=1; 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 header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1576634941183454.26603447321736; Tue, 17 Dec 2019 18:09:01 -0800 (PST) Received: from localhost ([::1]:48479 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihOln-0002xM-2K for importer@patchew.org; Tue, 17 Dec 2019 21:09:00 -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 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) 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= 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 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: 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=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , Juan Quintela , "Dr. David Alan Gilbert" , Markus Armbruster , Paolo Bonzini 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" 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); } =20 -static void migration_incoming_setup(QEMUFile *f) +static void migration_incoming_setup(QEMUFile *f, Error **errp) { MigrationIncomingState *mis =3D migration_incoming_get_current(); =20 - if (multifd_load_setup() !=3D 0) { + if (multifd_load_setup(errp) !=3D 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; } =20 -void migration_fd_process_incoming(QEMUFile *f) +void migration_fd_process_incoming(QEMUFile *f, Error **errp) { if (postcopy_try_recover(f)) { return; } =20 - migration_incoming_setup(f); + migration_incoming_setup(f, errp); migration_incoming_process(); } =20 @@ -596,7 +596,7 @@ void migration_ioc_process_incoming(QIOChannel *ioc, Er= ror **errp) return; } =20 - migration_incoming_setup(f); + migration_incoming_setup(f, errp); =20 /* * 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 =20 void migrate_set_state(int *state, int old_state, int new_state); =20 -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); =20 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; } =20 -int multifd_load_setup(void) +int multifd_load_setup(Error **errp) { int thread_count; uint32_t page_count =3D 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); =20 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 *opaq= ue) } =20 rdma->migration_started_on_destination =3D 1; - migration_fd_process_incoming(f); + migration_fd_process_incoming(f, errp); } =20 void rdma_start_incoming_migration(const char *host_port, Error **errp) --=20 2.23.0 From nobody Mon May 6 20:45:07 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 ARC-Seal: i=1; a=rsa-sha256; t=1576635070; cv=none; d=zohomail.com; s=zohoarc; b=EM89t8ph3IMPvR1mAoEXpgq/c68ScxxWQyPr26OVvDKiPv+S1w52D6ikY2fzjgF8gwlN4OhEuy1SuVuce7X58DrWk/0ZZDdCcoNSitHBH+JhKccJxTTNUFNSdcx4OfQ6Xd9rcB7fCVscbh0LCN2VxEn0Pq/HiJr+OQX0wTiHoZE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576635070; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=iVRIBO5wyUrsQa52u78XdUvKUuObp4iAocslgdnORJw=; b=COhBroxjXV0uVMny0sedRaYmKi28Ed7NbEJ9Y53W9930gfPFA5ZXqJOCg5bP1feQ7gD72YQqm3OlAVBkPfjrPZB2cMnMnGyqsd5xrGxdKN/DPZMUl89fL0nkfSiMAB/ecaLrEZlsDCSKErFLojHE591nJefvadMdpwQ5wdSVWbM= ARC-Authentication-Results: i=1; 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 header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1576635070168524.4242194204503; Tue, 17 Dec 2019 18:11:10 -0800 (PST) Received: from localhost ([::1]:48510 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihOns-0005sQ-OQ for importer@patchew.org; Tue, 17 Dec 2019 21:11:08 -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 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) 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= 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 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: Laurent Vivier , Thomas Huth , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , Juan Quintela , "Dr. David Alan Gilbert" , Markus Armbruster , Paolo Bonzini 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 --- 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 =3D { .set_default_value =3D set_default_value_enum, }; =20 +/* --- MultifdCompress --- */ + +const PropertyInfo qdev_prop_multifd_compress =3D { + .name =3D "MultifdCompress", + .description =3D "multifd_compress values, " + "none", + .enum_table =3D &MultifdCompress_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 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, Multifd= Compress) #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 =20 /* 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 =3D s->parameters.block_incremental; params->has_multifd_channels =3D true; params->multifd_channels =3D s->parameters.multifd_channels; + params->has_multifd_compress =3D true; + params->multifd_compress =3D s->parameters.multifd_compress; params->has_xbzrle_cache_size =3D true; params->xbzrle_cache_size =3D s->parameters.xbzrle_cache_size; params->has_max_postcopy_bandwidth =3D true; @@ -1281,6 +1284,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_compress) { + dest->multifd_compress =3D params->multifd_compress; + } if (params->has_xbzrle_cache_size) { dest->xbzrle_cache_size =3D 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 =3D params->multifd_channels; } + if (params->has_multifd_compress) { + s->parameters.multifd_compress =3D params->multifd_compress; + } if (params->has_xbzrle_cache_size) { s->parameters.xbzrle_cache_size =3D params->xbzrle_cache_size; xbzrle_cache_resize(params->xbzrle_cache_size, errp); @@ -3474,6 +3483,9 @@ static Property migration_properties[] =3D { 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 =3D true; params->has_block_incremental =3D true; params->has_multifd_channels =3D true; + params->has_multifd_compress =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 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 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_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 QD= ict *qdict) MigrateSetParameters *p =3D g_new0(MigrateSetParameters, 1); uint64_t valuebw =3D 0; uint64_t cache_size; + MultifdCompress compress_type; Error *err =3D NULL; int val, ret; =20 @@ -1824,6 +1829,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_COMPRESS: + p->has_multifd_compress =3D true; + visit_type_MultifdCompress(v, param, &compress_type, &err); + if (err) { + break; + } + p->multifd_compress =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..430a39382e 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -488,6 +488,19 @@ ## { 'command': 'query-migrate-capabilities', 'returns': ['MigrationCapabil= ityStatus']} =20 +## +# @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' ] } =20 ## # @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' } } =20 ## # @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' } } =20 ## # @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); } =20 -__attribute__((unused)) static void migrate_set_parameter_str(QTestState *who, const char *paramet= er, const char *value) { @@ -1398,7 +1397,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; @@ -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); =20 + 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"); =20 @@ -1453,6 +1455,11 @@ static void test_multifd_tcp(void) free(uri); } =20 +static void test_multifd_tcp_none(void) +{ + test_multifd_tcp("none"); +} + int main(int argc, char **argv) { char template[] =3D "/tmp/migration-test-XXXXXX"; @@ -1517,7 +1524,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); =20 ret =3D g_test_run(); =20 --=20 2.23.0 From nobody Mon May 6 20:45:07 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 ARC-Seal: i=1; a=rsa-sha256; t=1576634933; cv=none; d=zohomail.com; s=zohoarc; b=LFV/Ewc0wcVMxtnZKOZEee0LNT3+1ba3ZGA3Vr8k4f16YVgqqbglXQilhJEJwXsSCmByvceFkWxqdNcy7FlumBrn7bOPiQ+IB+HzUVoJkyXRCdsJgB1A4sPGi16akXAieZSEG8wrs65DTZwKVmapqG5swGtRadQD37drk3KTOUs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576634933; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=JCF79OgkifHXkDZ6UIDSsQbkPYWximap7jUWIkoikGY=; b=XbgTkmsoEbRx3GOMaDwjuAPpGeFcvDVlQopeTIO/jRGqwpntmkY2AAcQ5ZA2DUSNlD1A14xmZFpHTufHYa4bUDsksQHn01+xKjRuwOVRawX0yyAcKcquvanXHBCPT0R3mucwCDJs3RfvnbDbVennNZcKMNtCwsbKVn4Qg6wqqX4= ARC-Authentication-Results: i=1; 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 header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 157663493382754.114042894676686; Tue, 17 Dec 2019 18:08:53 -0800 (PST) Received: from localhost ([::1]:48476 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihOlg-0002tG-Ap for importer@patchew.org; Tue, 17 Dec 2019 21:08:52 -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 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) 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= 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 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: 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=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , Juan Quintela , "Dr. David Alan Gilbert" , Markus Armbruster , Paolo Bonzini 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 --- 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; } =20 +int migrate_multifd_method(void) +{ + MigrationState *s; + + s =3D 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); =20 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 =20 #define MULTIFD_FLAG_SYNC (1 << 0) +#define MULTIFD_FLAG_NOCOMP (1 << 1) =20 /* 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; =20 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; =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; + +/* 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) +{ + if (p->flags !=3D 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 =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_COMPRESS__MAX] =3D { + [MULTIFD_COMPRESS_NONE] =3D &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; =20 /* @@ -1027,6 +1178,7 @@ void multifd_save_cleanup(void) multifd_send_terminate_threads(NULL); for (i =3D 0; i < migrate_multifd_channels(); i++) { MultiFDSendParams *p =3D &multifd_send_state->params[i]; + Error *local_err =3D NULL; =20 if (p->running) { qemu_thread_join(&p->thread); @@ -1043,6 +1195,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); @@ -1123,7 +1279,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++; @@ -1140,8 +1303,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; } @@ -1212,6 +1374,7 @@ int multifd_save_setup(Error **errp) { int thread_count; uint32_t page_count =3D MULTIFD_PACKET_SIZE / qemu_target_page_size(); + int ret =3D 0; uint8_t i; =20 if (!migrate_use_multifd()) { @@ -1222,9 +1385,11 @@ int multifd_save_setup(Error **errp) multifd_send_state->params =3D g_new0(MultiFDSendParams, thread_count); multifd_send_state->pages =3D multifd_pages_init(page_count); qemu_sem_init(&multifd_send_state->channels_ready, 0); + multifd_send_state->ops =3D multifd_ops[migrate_multifd_method()]; =20 for (i =3D 0; i < thread_count; i++) { MultiFDSendParams *p =3D &multifd_send_state->params[i]; + int res; =20 qemu_mutex_init(&p->mutex); qemu_sem_init(&p->sem, 0); @@ -1240,8 +1405,12 @@ int multifd_save_setup(Error **errp) p->packet->version =3D cpu_to_be32(MULTIFD_VERSION); p->name =3D g_strdup_printf("multifdsend_%d", i); socket_send_channel_create(multifd_new_send_channel_async, p); + res =3D multifd_send_state->ops->send_setup(p, errp); + if (ret =3D=3D 0) { + ret =3D res; + } } - return 0; + return ret; } =20 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; =20 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 =3D 0; =20 if (!migrate_use_multifd()) { return 0; @@ -1316,6 +1486,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); @@ -1323,7 +1494,7 @@ int multifd_load_cleanup(Error **errp) g_free(multifd_recv_state); multifd_recv_state =3D NULL; =20 - return ret; + return 0; } =20 static void multifd_recv_sync_main(void) @@ -1388,6 +1559,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++; @@ -1395,8 +1568,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; } @@ -1435,9 +1607,11 @@ 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_method()]; =20 for (i =3D 0; i < thread_count; i++) { MultiFDRecvParams *p =3D &multifd_recv_state->params[i]; + int ret; =20 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 =3D g_malloc0(p->packet_len); p->name =3D g_strdup_printf("multifdrecv_%d", i); + ret =3D multifd_recv_state->ops->recv_setup(p, errp); + if (ret !=3D 0) { + return ret; + } } return 0; } --=20 2.23.0 From nobody Mon May 6 20:45:07 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 ARC-Seal: i=1; a=rsa-sha256; t=1576634651; cv=none; d=zohomail.com; s=zohoarc; b=ZClzOs7FSmjkLYXU1LjHrIzSeoQogJHEJQMndqDPAYhBHhbZA56dViVXlewppkdfdRoZ9f7j5agzveUuKQACUk1kQi31qf1jq9SX3Agq8s7Cv3tZPPUj1UGBhdBX/DkJCYxsLaPlA3Bgkzdk0j279TnsVpwACthAEMqHpmqUHvM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576634651; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Me4XmzGVB9RFQGRy0j0KZ+xUAkGjfGYztPgLVWPqsT0=; b=cw6bCwi/CYRdS1bEw6X6k5lg1CUwXtY7tTobhHbxMsMTc082f2LbeIG7iP64qZzYy9IlimzeJx4OoMnfqfjE0a28BIUp5b8WM6QQ6cW9Poy6ttu/zTkKRzyfMfG/XKhj1YFQQ1jYD08vWW26+PYvyOBs+2L+QX2oAU+4Gbo7XIU= ARC-Authentication-Results: i=1; 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 header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1576634651003126.13454532896446; Tue, 17 Dec 2019 18:04:11 -0800 (PST) Received: from localhost ([::1]:48418 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihOh6-000538-Uf for importer@patchew.org; Tue, 17 Dec 2019 21:04:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52728) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihOes-00037H-Bx 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 1ihOep-0005s7-GC for qemu-devel@nongnu.org; Tue, 17 Dec 2019 21:01:49 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:26638 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 1ihOep-0005qI-Bk for qemu-devel@nongnu.org; Tue, 17 Dec 2019 21:01:47 -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-285-BsJfeguRP4ahMOpQwzO9cQ-1; Tue, 17 Dec 2019 21:01: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 B1F441005502 for ; Wed, 18 Dec 2019 02:01:43 +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 7182A19C58; Wed, 18 Dec 2019 02:01:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576634505; 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=Me4XmzGVB9RFQGRy0j0KZ+xUAkGjfGYztPgLVWPqsT0=; b=WIVF2IVAOQ8j3TtSZrk+BTHofpVl5I69lLPCwhUXMrgBmBbrUapdI5xjWcAsQGMtw+fOu1 qxf0Nu1Q3/UBJyxa+v/2O0+m3A37bJRv7HkEVmzSZu9dEYRtyxRndAz8tfw2XwY3sMxIG+ ZGm7P5W00GXiY5DJ4GSPL/JvyBMMePQ= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PATCH v2 08/10] migration: Add zlib compression multifd support Date: Wed, 18 Dec 2019 03:01:17 +0100 Message-Id: <20191218020119.3776-9-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: BsJfeguRP4ahMOpQwzO9cQ-1 X-Mimecast-Spam-Score: 0 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: Laurent Vivier , Thomas Huth , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , Juan Quintela , "Dr. David Alan Gilbert" , Markus Armbruster , Paolo Bonzini 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 --- hw/core/qdev-properties.c | 2 +- migration/ram.c | 264 ++++++++++++++++++++++++++++++++++++++ qapi/migration.json | 2 +- tests/migration-test.c | 6 + 4 files changed, 272 insertions(+), 2 deletions(-) diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c index 644705235e..e8ff317a60 100644 --- a/hw/core/qdev-properties.c +++ b/hw/core/qdev-properties.c @@ -654,7 +654,7 @@ const PropertyInfo qdev_prop_fdc_drive_type =3D { const PropertyInfo qdev_prop_multifd_compress =3D { .name =3D "MultifdCompress", .description =3D "multifd_compress values, " - "none", + "none/zlib", .enum_table =3D &MultifdCompress_lookup, .get =3D get_enum, .set =3D set_enum, diff --git a/migration/ram.c b/migration/ram.c index 10661e03ae..5006d719b4 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -583,6 +583,7 @@ exit: =20 #define MULTIFD_FLAG_SYNC (1 << 0) #define MULTIFD_FLAG_NOCOMP (1 << 1) +#define MULTIFD_FLAG_ZLIB (1 << 2) =20 /* This value needs to be a multiple of qemu_target_page_size() */ #define MULTIFD_PACKET_SIZE (512 * 1024) @@ -625,6 +626,15 @@ typedef struct { RAMBlock *block; } MultiFDPages_t; =20 +struct zlib_data { + /* stream for compression */ + z_stream zs; + /* compressed buffer */ + uint8_t *zbuff; + /* size of compressed buffer */ + uint32_t zbuff_len; +}; + typedef struct { /* this fields are not changed once the thread is created */ /* channel number */ @@ -846,8 +856,262 @@ static MultiFDMethods multifd_nocomp_ops =3D { .recv_pages =3D nocomp_recv_pages }; =20 +/* 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; + + p->data =3D z; + zs->zalloc =3D Z_NULL; + zs->zfree =3D Z_NULL; + zs->opaque =3D Z_NULL; + if (deflateInit(zs, migrate_compress_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) { + g_free(z); + error_setg(errp, "multifd %d: out of memory for zbuff", p->id); + return -1; + } + 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; + + ret =3D deflate(zs, flush); + 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) { + 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) +{ + 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(); + struct zlib_data *z =3D p->data; + z_stream *zs =3D &z->zs; + int ret; + int i; + + if (p->flags !=3D MULTIFD_FLAG_ZLIB) { + error_setg(errp, "multifd %d: flags received %x flags expected %x", + p->id, MULTIFD_FLAG_ZLIB, p->flags); + 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; + + 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; + + ret =3D inflate(zs, flush); + if (ret !=3D Z_OK) { + error_setg(errp, "multifd %d: inflate returned %d instead of Z= _OK", + p->id, ret); + return ret; + } + out_size +=3D iov->iov_len; + } + 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 MultiFDMethods *multifd_ops[MULTIFD_COMPRESS__MAX] =3D { [MULTIFD_COMPRESS_NONE] =3D &multifd_nocomp_ops, + [MULTIFD_COMPRESS_ZLIB] =3D &multifd_zlib_ops, }; =20 static int multifd_send_initial_packet(MultiFDSendParams *p, Error **errp) diff --git a/qapi/migration.json b/qapi/migration.json index 430a39382e..0e3a3db8d0 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -499,7 +499,7 @@ # ## { 'enum': 'MultifdCompress', - 'data': [ 'none' ] } + 'data': [ 'none', 'zlib' ] } =20 ## # @MigrationParameter: diff --git a/tests/migration-test.c b/tests/migration-test.c index e5b6e54cfa..8985e05c69 100644 --- a/tests/migration-test.c +++ b/tests/migration-test.c @@ -1460,6 +1460,11 @@ static void test_multifd_tcp_none(void) test_multifd_tcp("none"); } =20 +static void test_multifd_tcp_zlib(void) +{ + test_multifd_tcp("zlib"); +} + int main(int argc, char **argv) { char template[] =3D "/tmp/migration-test-XXXXXX"; @@ -1525,6 +1530,7 @@ int main(int argc, char **argv) =20 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); =20 ret =3D g_test_run(); =20 --=20 2.23.0 From nobody Mon May 6 20:45:07 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 ARC-Seal: i=1; a=rsa-sha256; t=1576635057; cv=none; d=zohomail.com; s=zohoarc; b=fSEYRsG0gL18QvV4qExDzKlQe+hZXSJUj6HrJpp9Be9VLYAbaYpuTmPzbA1X5JrbYSJDaLzDQe/bYny+tj7oA+9VuU/pD0NjUMAL0pqv3iyMaIZh/Tzi6Wy0kk7S9dJPSBmACtvruZBwwDrt6rn83kBMW32doQ7jxljCY3hnobg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576635057; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=b2vemv0zRpYDz/uUdckp1sNwESkzjwYs9euWZf0G7CM=; b=GssyzbbdoIBFrM3E/NXj/8CwfCEQVTrvOWexxCOLWKt9cte9kgTMAAaspv507Gk+JnRDpF+IheZmVNjQhbKc1Hd60MiiINZJgSsmO5QJLTNyhwOLqM3k6KGIG3DhePdfx/gQLKdlWiHnPVQmok098WfmmQ4oY9BXcNXTNntAQ1c= ARC-Authentication-Results: i=1; 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 header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1576635057283690.100806398201; Tue, 17 Dec 2019 18:10:57 -0800 (PST) Received: from localhost ([::1]:48508 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihOnf-0005Yd-Qi for importer@patchew.org; Tue, 17 Dec 2019 21:10:55 -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 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) 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= 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 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: Laurent Vivier , Thomas Huth , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , Juan Quintela , "Dr. David Alan Gilbert" , Markus Armbruster , Paolo Bonzini 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 --- 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=3D"" snappy=3D"" bzip2=3D"" lzfse=3D"" +zstd=3D"" guest_agent=3D"" guest_agent_with_vss=3D"no" guest_agent_ntddscsi=3D"no" @@ -1341,6 +1342,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" @@ -1788,6 +1793,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 @@ -2401,6 +2408,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 @@ -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" =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 --=20 2.23.0 From nobody Mon May 6 20:45:07 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 ARC-Seal: i=1; a=rsa-sha256; t=1576635165; cv=none; d=zohomail.com; s=zohoarc; b=OVK286R5amQX9TK3IGu97a5Ug2TRN7VMdUA/mwyem7ZwWah15p/WIXuzaQC6pEKUmVh5pjdIMNZCi5f4DixuzV8BLM2yfoo+7ROrpZN/Dn+PR+ggWfCrHdawFuvlzj9/LkslJpXOrE/1gGJ+xknLGUd100PtDOHcm2TWUUhxQek= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576635165; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=K73i1xFaBt3L7a/Q1hsX6M6ZSoHf01uwOXYScWoiKYw=; b=FDBJr9q9XOmGvDVswJBPZ0ST9VExTu2imG5+btQYXLFOfa+QUDXOP0LaPz95fMEDzlBE8fuexQD/LNy7MZWwss6Fw7Xct5L7hku5pXWAvw5ogwD6UzopLmpPMUY0u8GKy5bgMBi265Udl/eZSEDjinSDWYZFW4/uMQI/5JBXN4k= ARC-Authentication-Results: i=1; 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 header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1576635165686541.5845095102974; Tue, 17 Dec 2019 18:12:45 -0800 (PST) Received: from localhost ([::1]:48524 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihOpQ-0007ow-Ec for importer@patchew.org; Tue, 17 Dec 2019 21:12:44 -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 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) 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= 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 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: Laurent Vivier , Thomas Huth , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , Juan Quintela , "Dr. David Alan Gilbert" , Markus Armbruster , Paolo Bonzini 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 --- 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 =3D { const PropertyInfo qdev_prop_multifd_compress =3D { .name =3D "MultifdCompress", .description =3D "multifd_compress values, " - "none/zlib", + "none/zlib/zstd", .enum_table =3D &MultifdCompress_lookup, .get =3D get_enum, .set =3D 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) =20 /* 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; }; =20 +#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 =3D { .recv_pages =3D zlib_recv_pages }; =20 +#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 =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_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 =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; + + ret =3D 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 =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 res; + + 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; + } + + res =3D 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 =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(); + struct zstd_data *z =3D p->data; + int ret; + int i; + + if (p->flags !=3D MULTIFD_FLAG_ZSTD) { + error_setg(errp, "multifd %d: flags received %x flags expected %x", + p->id, MULTIFD_FLAG_ZSTD, p->flags); + 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; + + ret =3D 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 +=3D iov->iov_len; + } + 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 +}; +#endif /* CONFIG_ZSTD */ + static MultiFDMethods *multifd_ops[MULTIFD_COMPRESS__MAX] =3D { [MULTIFD_COMPRESS_NONE] =3D &multifd_nocomp_ops, [MULTIFD_COMPRESS_ZLIB] =3D &multifd_zlib_ops, +#ifdef CONFIG_ZSTD + [MULTIFD_COMPRESS_ZSTD] =3D &multifd_zstd_ops, +#endif }; =20 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' ] } =20 ## # @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"); } =20 +static void test_multifd_tcp_zstd(void) +{ + test_multifd_tcp("zstd"); +} + int main(int argc, char **argv) { char template[] =3D "/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); =20 ret =3D g_test_run(); =20 --=20 2.23.0