From nobody Mon Feb 9 09:33:03 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=git.sr.ht ARC-Seal: i=1; a=rsa-sha256; t=1691423786; cv=none; d=zohomail.com; s=zohoarc; b=njkhwNM2mMviv5oVJ5E8q8LeuhGsMBkEimhh865wrNvH7oVpmU9JlEfH10r2XNSnQ5iNt1oOnEnsO/1EsI1uULqNMfzkAKnudv5hxAc+Z+cLa0XuiINdQsXF7xz8LXMIynq1DbhcpECbjnmP8rTtHJzHdkPtIgk68OhQyagGxdQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1691423786; 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:Reply-To:Sender:Subject:To; bh=tiTWb7Ek9/aTA7BqYuumeGmtLFfqblq/MqEbI0BC1bE=; b=e3t74H2qnbxcc1bsPNrEcLQx7drz7yA+9MIPMbRKf3faM1Z+Q5K2cqtIJOLrzRPLJw6Z7c2KMLktZPNi9DVa8lxPvsOk4p5rxket9cbXNDVEtPY0F64Jo3YrvpKsoSVbniKvrh9pB0k77DtzDTGUTJET4PCISV/iHlIgvDdwm0g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1691423786581521.5815159448123; Mon, 7 Aug 2023 08:56:26 -0700 (PDT) Received: from mimecast-mx02.redhat.com (66.187.233.73 [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-199-FohSkqhHNjSlBmhEQ0nVpA-1; Mon, 07 Aug 2023 11:56:22 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D1EA23C108CD; Mon, 7 Aug 2023 15:56:18 +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 923E3440C7; Mon, 7 Aug 2023 15:56:18 +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 A9F9E1946A48; Mon, 7 Aug 2023 15:56:11 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id F24831946589 for ; Mon, 7 Aug 2023 15:56:09 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id D32E2C15BAE; Mon, 7 Aug 2023 15:56:09 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast08.extmail.prod.ext.rdu2.redhat.com [10.11.55.24]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CBFC3C15BAD for ; Mon, 7 Aug 2023 15:56:09 +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 A4D18381C16A for ; Mon, 7 Aug 2023 15:56:09 +0000 (UTC) Received: from mail-b.sr.ht (mail-b.sr.ht [173.195.146.151]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-240-nH0QXuo8M42HGcauu4z6Tw-1; Mon, 07 Aug 2023 11:56:07 -0400 Received: from git.sr.ht (unknown [173.195.146.142]) by mail-b.sr.ht (Postfix) with ESMTPSA id 775E711EEAC; Mon, 7 Aug 2023 15:56:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1691423785; h=from:from:sender:sender:reply-to: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:list-id:list-help:list-unsubscribe: list-subscribe:list-post; bh=tiTWb7Ek9/aTA7BqYuumeGmtLFfqblq/MqEbI0BC1bE=; b=eBOSJ/GYMYzFHmjRZGK5eOyPkV71OBfyyy4XDIrjIclTBhjZIamdiZygtH5FN2BC3oGRor FMJts2ZACPYeWXdduJuidVNHfuMxNJsqTEKjcsg7zltcXWUVeV5PFcUlyYlsddJffHlVMq fW0p5DMQzW16IC99UCqehtzp+URsm44= X-MC-Unique: FohSkqhHNjSlBmhEQ0nVpA-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: nH0QXuo8M42HGcauu4z6Tw-1 From: ~hyman Date: Tue, 01 Aug 2023 17:31:12 +0800 Subject: [PATCH Libvirt v2 02/10] conf: Introduce XML for dirty limit configuration MIME-Version: 1.0 Message-ID: <169142376567.1452.17600824269401067909-2@git.sr.ht> In-Reply-To: <169142376567.1452.17600824269401067909-0@git.sr.ht> To: libvir-list@redhat.com 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.8 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: , Reply-To: ~hyman Cc: Peter Krempa , yong.huang@smartx.com Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: git.sr.ht Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1691423786968100007 From: Hyman Huang(=E9=BB=84=E5=8B=87) The upper limit (MB/s) of the dirty page rate configured by the user can be tracked by the XML. To allow this, add the following XML: ... 3 ... The "dirty_limit" attribute in "vcpu" sub-element within "vcpus" element allows to set an upper limit for the individual vCPU. The value can be set dynamically by limit-dirty-page-rate API. Note that the dirty limit feature is based on the dirty-ring feature, so it requires dirty-ring size configuration in XML. Signed-off-by: Hyman Huang(=E9=BB=84=E5=8B=87) --- docs/formatdomain.rst | 7 ++++++- src/conf/domain_conf.c | 26 ++++++++++++++++++++++++ src/conf/domain_conf.h | 8 ++++++++ src/conf/domain_validate.c | 33 +++++++++++++++++++++++++++++++ src/conf/schemas/domaincommon.rng | 5 +++++ 5 files changed, 78 insertions(+), 1 deletion(-) diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst index cd9cb02bf8..7305ba38ea 100644 --- a/docs/formatdomain.rst +++ b/docs/formatdomain.rst @@ -649,7 +649,7 @@ CPU Allocation ... 2 - + ... @@ -715,6 +715,11 @@ CPU Allocation be enabled and non-hotpluggable. On PPC64 along with it vCPUs that are = in the same core need to be enabled as well. All non-hotpluggable CPUs present= at boot need to be grouped after vCPU 0. :since:`Since 2.2.0 (QEMU only)` + ``dirty_limit`` :since:`Since 9.6.0 (QEMU and KVM only)` + The optional attribute ``dirty_limit`` allows to set an upper limit (MB= /s) + of the dirty page rate for the vCPU. User can change the upper limit va= lue + dynamically by using ``limit-dirty-page-rate`` API. Require ``dirty-rin= g`` + size configured. =20 =20 IOThreads Allocation diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 47693a49bf..0af6ddd358 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -17061,6 +17061,7 @@ virDomainVcpuParse(virDomainDef *def, virDomainXMLOption *xmlopt) { int n; + int rv; xmlNodePtr vcpuNode; size_t i; unsigned int maxvcpus; @@ -17148,6 +17149,13 @@ virDomainVcpuParse(virDomainDef *def, if (virXMLPropUInt(nodes[i], "order", 10, VIR_XML_PROP_NONE, &vcpu->order) < 0) return -1; + + if ((rv =3D virXMLPropULongLong(nodes[i], "dirty_limit", 10, V= IR_XML_PROP_NONNEGATIVE, + &vcpu->dirty_limit)) < 0) { + return -1; + } else if (rv > 0) { + vcpu->dirtyLimitSet =3D true; + } } } else { if (virDomainDefSetVcpus(def, vcpus) < 0) @@ -21147,6 +21155,20 @@ virDomainDefVcpuCheckAbiStability(virDomainDef *sr= c, i); return false; } + + if (svcpu->dirtyLimitSet !=3D dvcpu->dirtyLimitSet) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Dirty limit state of vCPU '%1$zu' differs be= tween source and destination definitions"), + i); + return false; + } + + if (svcpu->dirty_limit !=3D dvcpu->dirty_limit) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Dirty limit of vCPU '%1$zu' differs between = source and destination definitions"), + i); + return false; + } } =20 return true; @@ -26712,6 +26734,10 @@ virDomainCpuDefFormat(virBuffer *buf, if (vcpu->order !=3D 0) virBufferAsprintf(buf, " order=3D'%d'", vcpu->order); =20 + if (vcpu->dirtyLimitSet) { + virBufferAsprintf(buf, " dirty_limit=3D'%llu'", vcpu->dirt= y_limit); + } + virBufferAddLit(buf, "/>\n"); } virBufferAdjustIndent(buf, -2); diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index c857ba556f..7e8bfcb884 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2785,6 +2785,14 @@ struct _virDomainVcpuDef { virDomainThreadSchedParam sched; =20 virObject *privateData; + + /* set to true if the dirty page rate upper limit for + * the virtual CPU is configured + * */ + bool dirtyLimitSet; + + /* dirty page rate upper limit */ + unsigned long long dirty_limit; }; =20 struct _virDomainBlkiotune { diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c index ad383b604e..db3b7e1d9d 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -1798,6 +1798,36 @@ virDomainDefValidateIOThreads(const virDomainDef *de= f) return 0; } =20 +static int +virDomainDefHasDirtyLimitStartupVcpus(const virDomainDef *def) +{ + size_t maxvcpus =3D virDomainDefGetVcpusMax(def); + virDomainVcpuDef *vcpu; + size_t i; + + for (i =3D 0; i < maxvcpus; i++) { + vcpu =3D def->vcpus[i]; + + if (vcpu->dirtyLimitSet && (vcpu->dirty_limit !=3D 0)) + return true; + } + + return false; +} + +static int +virDomainDefDirtyLimitValidate(const virDomainDef *def) +{ + if (virDomainDefHasDirtyLimitStartupVcpus(def)) { + if (def->kvm_features->dirty_ring_size =3D=3D 0) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("Dirty limit requires dirty-ring size configu= ration")); + return -1; + } + } + + return 0; +} =20 static int virDomainDefValidateInternal(const virDomainDef *def, @@ -1854,6 +1884,9 @@ virDomainDefValidateInternal(const virDomainDef *def, if (virDomainDefValidateIOThreads(def) < 0) return -1; =20 + if (virDomainDefDirtyLimitValidate(def) < 0) + return -1; + return 0; } =20 diff --git a/src/conf/schemas/domaincommon.rng b/src/conf/schemas/domaincom= mon.rng index c2f56b0490..da0986b7c3 100644 --- a/src/conf/schemas/domaincommon.rng +++ b/src/conf/schemas/domaincommon.rng @@ -859,6 +859,11 @@ + + + + + --=20 2.38.5