From nobody Tue Feb 10 09:24:22 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=quarantine dis=quarantine) header.from=huawei.com ARC-Seal: i=1; a=rsa-sha256; t=1674204914; cv=none; d=zohomail.com; s=zohoarc; b=DXc6j3QMdZ1BwnvRqaGNy7bd14KBE1wnjx629XLxW/YfqTksoqICq6PDilVzkxwoDo294mHHT3q5rG0IQnY/UavznWoAZWAWOvIqaxhBjza/sFEeKqLpPn/XPySkZCosnqmtdJvvG+7mQBaZGfWROBbOsI3CV8LA8qv/YSg6Owc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1674204914; 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=Jbj596iCNoVtI3FvCwhSY+ucp2lkQKumFUKk8FhYtbQ=; b=cvyAYEQFQyLAkR4Wr6EhN19QQwh7kZTfyDIkMvSusw0sx5U6+LKgx2MmWAROJm9IACQl03ux8Ah+kguWgrP3R8eAVIndWRb52Sjv6ulEQhC9d+lezWcURWS8Hi/ZOzXR+/Gipmf7pC8NlSokX4L/5IjSTttNvVSncuBPR9YCb+E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=quarantine dis=quarantine) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1674204914659217.0317583290821; Fri, 20 Jan 2023 00:55:14 -0800 (PST) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-500-rhQdDB0POf2MqFq3bPYHsA-1; Fri, 20 Jan 2023 03:55:10 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E033729324B5; Fri, 20 Jan 2023 08:55:08 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id C93F040C2064; Fri, 20 Jan 2023 08:55:08 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 1A32B1947051; Fri, 20 Jan 2023 08:55:08 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 32B491946A6D for ; Fri, 20 Jan 2023 08:55:07 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 2539F492C3F; Fri, 20 Jan 2023 08:55:07 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1E0DF492C3E for ; Fri, 20 Jan 2023 08:55:07 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id F3D268533DF for ; Fri, 20 Jan 2023 08:55:06 +0000 (UTC) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-198-UTvBLqVpN-KOjdMIRlco9A-1; Fri, 20 Jan 2023 03:55:04 -0500 Received: from dggpeml500022.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4NytZ14GVDzZfp5 for ; Fri, 20 Jan 2023 16:53:13 +0800 (CST) Received: from localhost.localdomain (10.175.124.27) by dggpeml500022.china.huawei.com (7.185.36.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Fri, 20 Jan 2023 16:55:00 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1674204913; h=from:from:sender:sender: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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=Jbj596iCNoVtI3FvCwhSY+ucp2lkQKumFUKk8FhYtbQ=; b=RWlLrWBl9IHZRk7b8+KM1W47d1XLzx0vNQD7Ikzq+IgO2m8U2CbYlrnvdaIljnP+wPdA5O 9Z0SEln6p2SpwViH6CIp86z5kM2hu6eWvlU24ew3kUpZ2X00K70mfgSbgQbgGxsTmhyjDI J5pKoXZIuc+nAxosVKWtDcwckJJkcok= X-MC-Unique: rhQdDB0POf2MqFq3bPYHsA-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: UTvBLqVpN-KOjdMIRlco9A-1 From: Jiang Jiacheng To: Subject: [PATCH 3/4] qemu: support set parallel migration compression method Date: Fri, 20 Jan 2023 16:47:42 +0800 Message-ID: <20230120084743.825806-4-jiangjiacheng@huawei.com> In-Reply-To: <20230120084743.825806-1-jiangjiacheng@huawei.com> References: <20230120084743.825806-1-jiangjiacheng@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpeml500022.china.huawei.com (7.185.36.66) X-CFilter-Loop: Reflected X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: yubihong@huawei.com, zhengchuan@huawei.com, linyilu@huawei.com, jiangjiacheng@huawei.com, xiexiangyou@huawei.com Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1674204917082100001 Content-Type: text/plain; charset="utf-8" Add 'qemuMigrationParamsSetParallelCompression' to support set parallel migration compression method. Depending on whether '--parallel' is set, we invoke different functions to select compression method from the same param 'VIR_MIGRATE_PARAM_COMPRESSION'. Signed-off-by: Jiang Jiacheng --- src/qemu/qemu_migration_params.c | 76 +++++++++++++++++++++++++++++++- 1 file changed, 74 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_migration_params.c b/src/qemu/qemu_migration_par= ams.c index 380fc7dccd..4980761712 100644 --- a/src/qemu/qemu_migration_params.c +++ b/src/qemu/qemu_migration_params.c @@ -71,6 +71,8 @@ struct _qemuMigrationParams { typedef enum { QEMU_MIGRATION_COMPRESS_XBZRLE =3D 0, QEMU_MIGRATION_COMPRESS_MT, + QEMU_MIGRATION_COMPRESS_ZLIB, + QEMU_MIGRATION_COMPRESS_ZSTD, =20 QEMU_MIGRATION_COMPRESS_LAST } qemuMigrationCompressMethod; @@ -79,6 +81,8 @@ VIR_ENUM_IMPL(qemuMigrationCompressMethod, QEMU_MIGRATION_COMPRESS_LAST, "xbzrle", "mt", + "zlib", + "zstd", ); =20 VIR_ENUM_IMPL(qemuMigrationCapability, @@ -524,6 +528,60 @@ qemuMigrationParamsSetTPString(qemuMigrationParams *mi= gParams, migParams->params[param].value.s); } =20 +static int +qemuMigrationParamsSetParallelCompression(virTypedParameterPtr params, + int nparams, + qemuMigrationParams *migParams) +{ + size_t i; + int method; + const char *value =3D NULL; + int rc; + + for (i =3D 0; i < nparams; i++) { + if (STRNEQ(params[i].field, VIR_MIGRATE_PARAM_COMPRESSION)) + continue; + if (migParams->params[QEMU_MIGRATION_PARAM_MULTIFD_COMPRESSION].se= t) { + virReportError(VIR_ERR_INVALID_ARG, "%s", + _("Only one compression method could be specifi= ed with " + "multifd compression")); + return -1; + } + + method =3D qemuMigrationCompressMethodTypeFromString(params[i].val= ue.s); + if (method < 2) { + virReportError(VIR_ERR_INVALID_ARG, + _("Unsupported compression method '%s' with mul= tifd migration"), + params[i].value.s); + return -1; + } + + migParams->compMethods |=3D 1ULL << method; + + if ((rc =3D virTypedParamsGetString(params, nparams, + VIR_MIGRATE_PARAM_COMPRESSION, &= value)) < 0) + return -1; + + migParams->params[QEMU_MIGRATION_PARAM_MULTIFD_COMPRESSION].value.= s =3D g_strdup(value); + migParams->params[QEMU_MIGRATION_PARAM_MULTIFD_COMPRESSION].set = =3D !!rc; + } + + if (migParams->params[QEMU_MIGRATION_PARAM_MULTIFD_ZLIB_LEVEL].set && + !(migParams->compMethods & (1ULL << QEMU_MIGRATION_COMPRESS_ZLIB))= ) { + virReportError(VIR_ERR_INVALID_ARG, "%s", + _("Turn zlib compression on to tune it")); + return -1; + } + + if (migParams->params[QEMU_MIGRATION_PARAM_MULTIFD_ZSTD_LEVEL].set && + !(migParams->compMethods & (1ULL << QEMU_MIGRATION_COMPRESS_ZSTD))= ) { + virReportError(VIR_ERR_INVALID_ARG, "%s", + _("Turn zstd compression on to tune it")); + return -1; + } + + return 0; +} =20 =20 static int @@ -548,6 +606,13 @@ qemuMigrationParamsSetCompression(virTypedParameterPtr= params, return -1; } =20 + if (method > 1) { + virReportError(VIR_ERR_INVALID_ARG, + _("Trun parallel migration on to use compressio= n method '%s'"), + params[i].value.s); + return -1; + } + if (migParams->compMethods & (1ULL << method)) { virReportError(VIR_ERR_INVALID_ARG, _("Compression method '%s' is specified twice"), @@ -566,6 +631,8 @@ qemuMigrationParamsSetCompression(virTypedParameterPtr = params, cap =3D QEMU_MIGRATION_CAP_COMPRESS; break; =20 + case QEMU_MIGRATION_COMPRESS_ZLIB: + case QEMU_MIGRATION_COMPRESS_ZSTD: case QEMU_MIGRATION_COMPRESS_LAST: default: continue; @@ -691,8 +758,13 @@ qemuMigrationParamsFromFlags(virTypedParameterPtr para= ms, return NULL; } =20 - if (qemuMigrationParamsSetCompression(params, nparams, flags, migParam= s) < 0) - return NULL; + if (flags & VIR_MIGRATE_PARALLEL) { + if (qemuMigrationParamsSetParallelCompression(params, nparams, mig= Params) < 0) + return NULL; + } else { + if (qemuMigrationParamsSetCompression(params, nparams, flags, migP= arams) < 0) + return NULL; + } =20 return g_steal_pointer(&migParams); } --=20 2.33.0