From nobody Sat Feb 7 06:55:08 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 ARC-Seal: i=1; a=rsa-sha256; t=1660409044; cv=none; d=zohomail.com; s=zohoarc; b=DbDEczbXyjIRMsjZA3QLojSLR8m3xa0q9UM1Nu/VgDIfDoTwW7E7e0WauuilhlcAQ64+hkZ0NM+gTBp56bVYfCo3WA0QwdFmb5cXjq+uXOPVBGgUM7iFyXPsuQIzkGFCS40wulmOPMp9P6fyK0OYlq/u9eczf7tv6pctlc8qYE0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1660409044; 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=07z70XJkIT2pFOc2xSLGnrigshzck8TTqMnSXhMBCbY=; b=WlE6Dk3Bf92JF417T444MBlLpFTbuZAlU7/wxZDQJv4AuqLqSgClDcBTk2V1UalO4bfOtJXG1a+IIkZcpTYhbu1OBeMM5GPC7gryhtoeM9Er5KzbUvLpBWt2E/L/Hs6F1ftO12kdcIcnVYGFpFT9nC0erQwX9ippIqHYXzpGOIU= 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 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 1660409044282840.5140809644748; Sat, 13 Aug 2022 09:44:04 -0700 (PDT) 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-467-AMgKQduBPjCLEf_JZr8UTA-1; Sat, 13 Aug 2022 12:43:30 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C354D3C1107B; Sat, 13 Aug 2022 16:43:26 +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 AFB85492CA6; Sat, 13 Aug 2022 16:43:26 +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 A557C1946A68; Sat, 13 Aug 2022 16:43:24 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 0EFE31947049 for ; Sat, 13 Aug 2022 16:43:22 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id DF54B2026D07; Sat, 13 Aug 2022 16:43:21 +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 DBCC22026D64 for ; Sat, 13 Aug 2022 16:43:21 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (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 C52BB8037AF for ; Sat, 13 Aug 2022 16:43:21 +0000 (UTC) Received: from chinatelecom.cn (prt-mail.chinatelecom.cn [42.123.76.226]) by relay.mimecast.com with ESMTP id us-mta-444-9xOt2bppN7Olkafqr7wwxA-1; Sat, 13 Aug 2022 12:43:19 -0400 Received: from clientip-118.116.19.21 (unknown [172.18.0.218]) by chinatelecom.cn (HERMES) with SMTP id 39F5E280097; Sun, 14 Aug 2022 00:31:42 +0800 (CST) Received: from ([172.18.0.218]) by app0025 with ESMTP id 0f207f5425d9490dac262706a64d39ff for libvir-list@redhat.com; Sun, 14 Aug 2022 00:31:42 CST DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660409043; 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:in-reply-to:references:references:references: list-id:list-help:list-unsubscribe:list-subscribe:list-post; bh=07z70XJkIT2pFOc2xSLGnrigshzck8TTqMnSXhMBCbY=; b=eadQfeo6AI9lAzhHEjP3/5IJvw1R25BpLAI1V0A+D3Tb+p61tgQMq/cqnufht82+zzHnlZ ALSCncsAu0DgGKCBbw2+PkonSPHrp6DM3bjVSa5NEduV/PH7L/DDSwMp2NH/4Q8s5mOfPY RpbNOh2xh4SPmQp7Bvf5O8gzqFHJqe0= X-MC-Unique: AMgKQduBPjCLEf_JZr8UTA-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: 9xOt2bppN7Olkafqr7wwxA-1 HMM_SOURCE_IP: 172.18.0.218:42044.1596025118 HMM_ATTACHE_NUM: 0000 HMM_SOURCE_TYPE: SMTP X-189-SAVE-TO-SEND: +huangy81@chinatelecom.cn X-Transaction-ID: 0f207f5425d9490dac262706a64d39ff X-Real-From: huangy81@chinatelecom.cn X-Receive-IP: 172.18.0.218 X-MEDUSA-Status: 0 From: huangy81@chinatelecom.cn To: Subject: [PATCH 02/11] libvirt: Add virDomainSetVcpuDirtyLimit API Date: Sun, 14 Aug 2022 00:31:14 +0800 Message-Id: In-Reply-To: References: In-Reply-To: References: MIME-Version: 1.0 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-Mimecast-Spam-Signature: yes X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 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: =?UTF-8?q?Hyman=20Huang=28=E9=BB=84=E5=8B=87=29?= Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 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: 1660409046031100004 Content-Type: text/plain; charset="utf-8" From: Hyman Huang(=E9=BB=84=E5=8B=87) Introduce virDomainSetVcpuDirtyLimit API to set upper limit of dirty page rate. Signed-off-by: Hyman Huang(=E9=BB=84=E5=8B=87) --- include/libvirt/libvirt-domain.h | 16 +++++++++++++ src/driver-hypervisor.h | 7 ++++++ src/libvirt-domain.c | 51 ++++++++++++++++++++++++++++++++++++= ++++ src/libvirt_public.syms | 5 ++++ src/remote/remote_driver.c | 1 + src/remote/remote_protocol.x | 16 +++++++++++-- src/remote_protocol-structs | 7 ++++++ 7 files changed, 101 insertions(+), 2 deletions(-) diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-dom= ain.h index 7430a08..b0bd2f1 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -6452,4 +6452,20 @@ int virDomainStartDirtyRateCalc(virDomainPtr domain, int seconds, unsigned int flags); =20 +/** + * virDomainDirtyLimitFlags: + * + * Since: 8.7.0 + */ +typedef enum { + VIR_DOMAIN_DIRTYLIMIT_VCPU =3D 0, /* render specified virtual CPU = for + dirty page rate limit (Since: 8= .7.0) */ + VIR_DOMAIN_DIRTYLIMIT_ALL =3D 1 << 0, /* render all virtual CPU for di= rty + page rate limit (Since: 8.7.0) = */ +} virDomainDirtyLimitFlags; + +int virDomainSetVcpuDirtyLimit(virDomainPtr domain, + int vcpu, + unsigned long long rate, + unsigned int flags); #endif /* LIBVIRT_DOMAIN_H */ diff --git a/src/driver-hypervisor.h b/src/driver-hypervisor.h index 016d5ce..ac59da6 100644 --- a/src/driver-hypervisor.h +++ b/src/driver-hypervisor.h @@ -1441,6 +1441,12 @@ typedef int int seconds, unsigned int flags); =20 +typedef int +(*virDrvDomainSetVcpuDirtyLimit)(virDomainPtr domain, + int vcpu, + unsigned long long rate, + unsigned int flags); + typedef struct _virHypervisorDriver virHypervisorDriver; =20 /** @@ -1712,4 +1718,5 @@ struct _virHypervisorDriver { virDrvDomainAuthorizedSSHKeysSet domainAuthorizedSSHKeysSet; virDrvDomainGetMessages domainGetMessages; virDrvDomainStartDirtyRateCalc domainStartDirtyRateCalc; + virDrvDomainSetVcpuDirtyLimit domainSetVcpuDirtyLimit; }; diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index 842663a..be9825b 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -13929,3 +13929,54 @@ virDomainStartDirtyRateCalc(virDomainPtr domain, virDispatchError(conn); return -1; } + +/** + * virDomainSetVcpuDirtyLimit: + * @domain: pointer to domain object, or NULL for Domain0 + * @vcpu: (optional) virtual CPU number + * @rate: upper limit of dirty page rate (MB/s) for virtual CPUs + * @flags: bitwise-OR of supported virDomainDirtyLimitFlags + * + * Dynamically set the upper dirty page rate limit of the virtual CPUs. + * + * Returns 0 in case of success, -1 in case of failure. + * + * Since: 8.7.0 + */ +int +virDomainSetVcpuDirtyLimit(virDomainPtr domain, + int vcpu, + unsigned long long rate, + unsigned int flags) +{ + virConnectPtr conn; + + VIR_DOMAIN_DEBUG(domain, "vcpu=3D%d, dirty page rate limit=3D%lld", + vcpu, rate); + + virResetLastError(); + + virCheckDomainReturn(domain, -1); + conn =3D domain->conn; + + virCheckReadOnlyGoto(conn->flags, error); + virCheckPositiveArgGoto(rate, error); + + VIR_EXCLUSIVE_FLAGS_GOTO(VIR_DOMAIN_DIRTYLIMIT_VCPU, + VIR_DOMAIN_DIRTYLIMIT_ALL, + error); + + if (conn->driver->domainSetVcpuDirtyLimit) { + int ret; + ret =3D conn->driver->domainSetVcpuDirtyLimit(domain, vcpu, rate, = flags); + if (ret < 0) + goto error; + return ret; + } + + virReportUnsupportedError(); + + error: + virDispatchError(domain->conn); + return -1; +} diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms index 297a2c4..8ebcf50 100644 --- a/src/libvirt_public.syms +++ b/src/libvirt_public.syms @@ -927,4 +927,9 @@ LIBVIRT_8.5.0 { virDomainAbortJobFlags; } LIBVIRT_8.4.0; =20 +LIBVIRT_8.7.0 { + global: + virDomainSetVcpuDirtyLimit; +} LIBVIRT_8.5.0; + # .... define new API here using predicted next version number .... diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 0ca365c..f673fed 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -8652,6 +8652,7 @@ static virHypervisorDriver hypervisor_driver =3D { .domainGetMessages =3D remoteDomainGetMessages, /* 7.1.0 */ .domainStartDirtyRateCalc =3D remoteDomainStartDirtyRateCalc, /* 7.2.0= */ .domainSetLaunchSecurityState =3D remoteDomainSetLaunchSecurityState, = /* 8.0.0 */ + .domainSetVcpuDirtyLimit =3D remoteDomainSetVcpuDirtyLimit, /* 8.7.0 */ }; =20 static virNetworkDriver network_driver =3D { diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x index 79ffc63..e6c18a4 100644 --- a/src/remote/remote_protocol.x +++ b/src/remote/remote_protocol.x @@ -3921,7 +3921,6 @@ struct remote_domain_start_dirty_rate_calc_args { unsigned int flags; }; =20 - struct remote_domain_event_memory_device_size_change_msg { int callbackID; remote_nonnull_domain dom; @@ -3929,6 +3928,13 @@ struct remote_domain_event_memory_device_size_change= _msg { unsigned hyper size; }; =20 +struct remote_domain_set_vcpu_dirty_limit_args { + remote_nonnull_domain dom; + int vcpu; + unsigned hyper rate; + unsigned int flags; +}; + /*----- Protocol. -----*/ =20 /* Define the program number, protocol version and procedure numbers here.= */ @@ -6959,5 +6965,11 @@ enum remote_procedure { * @generate: both * @acl: domain:write */ - REMOTE_PROC_DOMAIN_ABORT_JOB_FLAGS =3D 442 + REMOTE_PROC_DOMAIN_ABORT_JOB_FLAGS =3D 442, + + /** + * @generate: both + * @acl: domain:write + */ + REMOTE_PROC_DOMAIN_SET_VCPU_DIRTY_LIMIT =3D 443 }; diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs index ca52224..8ff2a86 100644 --- a/src/remote_protocol-structs +++ b/src/remote_protocol-structs @@ -3268,6 +3268,12 @@ struct remote_domain_event_memory_device_size_change= _msg { remote_nonnull_string alias; uint64_t size; }; +struct remote_domain_set_vcpu_dirty_limit_args { + remote_nonnull_domain dom; + int vcpu; + uint64_t rate; + u_int flags; +}; enum remote_procedure { REMOTE_PROC_CONNECT_OPEN =3D 1, REMOTE_PROC_CONNECT_CLOSE =3D 2, @@ -3711,4 +3717,5 @@ enum remote_procedure { REMOTE_PROC_DOMAIN_SAVE_PARAMS =3D 440, REMOTE_PROC_DOMAIN_RESTORE_PARAMS =3D 441, REMOTE_PROC_DOMAIN_ABORT_JOB_FLAGS =3D 442, + REMOTE_PROC_DOMAIN_SET_VCPU_DIRTY_LIMIT =3D 443, }; --=20 1.8.3.1