From nobody Sun Feb 8 19:55:39 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 ARC-Seal: i=1; a=rsa-sha256; t=1661534452; cv=none; d=zohomail.com; s=zohoarc; b=Le9FURlOOH/GBgv1VnA1jqmIURq+mzC8/GkmiOyTYSAan5+8HlTMBRlYfalXpeY762FQshzJbv69BFwae5pnibxWV6SqmKAZWh22930wNtN0VuYwSREXKYn7MRHZ8joxy9ZRWCRM/dGnzucU4mBVZLuUcIdWSj84AfOxo4rHVik= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1661534452; 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=IpJmusA5uGk+l0oHKv+aXBW5X1nuQhE10vo9u4vaOSk=; b=Blhqk8DUR0+Z5JNHaM8flqONSIuQhT6FcbfQ9pZt0X64SQ8tqX4oUeQAKPpp7yoDBWKX3RboReD0WzlnSYjXBP7Z2BkByHogcPXogsOojkWjLsXIRBxwGtdgk1jRBrlRQuV83zMp98soc7oF9I3ObAtjDiqa63H7tde5sbV2Wjw= 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 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 1661534451842462.75834014377006; Fri, 26 Aug 2022 10:20:51 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-161-UhuHR6KHMPGKbc6B80xHMw-1; Fri, 26 Aug 2022 13:20:46 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B43D41011602; Fri, 26 Aug 2022 17:20:42 +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 9ABF32166B29; Fri, 26 Aug 2022 17:20:42 +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 D461D1946A4D; Fri, 26 Aug 2022 17:20:41 +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 751231946A5E for ; Fri, 26 Aug 2022 17:20:40 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 62C76C15BB3; Fri, 26 Aug 2022 17:20:40 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast09.extmail.prod.ext.rdu2.redhat.com [10.11.55.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5E05EC15BBA for ; Fri, 26 Aug 2022 17:20:40 +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 168F229324BE for ; Fri, 26 Aug 2022 17:20:40 +0000 (UTC) Received: from chinatelecom.cn (prt-mail.chinatelecom.cn [42.123.76.222]) by relay.mimecast.com with ESMTP id us-mta-452-ZNkfcds3Ng2UhLguIRXRww-1; Fri, 26 Aug 2022 13:20:37 -0400 Received: from clientip-118.116.19.131 (unknown [172.18.0.48]) by chinatelecom.cn (HERMES) with SMTP id 08A722800C0; Sat, 27 Aug 2022 01:20:35 +0800 (CST) Received: from ([172.18.0.48]) by app0024 with ESMTP id 139daa1e04134dc485d8fd0e3fd2169e for libvir-list@redhat.com; Sat, 27 Aug 2022 01:20:35 CST DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661534450; 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=IpJmusA5uGk+l0oHKv+aXBW5X1nuQhE10vo9u4vaOSk=; b=QVx/MIYq8QbHx4dm/vB/J1TiOQsmQPzs+oIS+XqUbCHQCRplgiW4GOj976FoK/uk5GWZlG 540MU9YSVMegzbUgo2Wg7y89Az5bV/TpM3A1cHmVaWTP2xqwbJJCEvraN+iX3Zyljgd6zw EsQ8P5wv1vgM9E1dI29hltFH7sft4No= X-MC-Unique: UhuHR6KHMPGKbc6B80xHMw-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: ZNkfcds3Ng2UhLguIRXRww-1 HMM_SOURCE_IP: 172.18.0.48:55710.1634875554 HMM_ATTACHE_NUM: 0000 HMM_SOURCE_TYPE: SMTP X-189-SAVE-TO-SEND: +huangy81@chinatelecom.cn X-Transaction-ID: 139daa1e04134dc485d8fd0e3fd2169e X-Real-From: huangy81@chinatelecom.cn X-Receive-IP: 172.18.0.48 X-MEDUSA-Status: 0 From: huangy81@chinatelecom.cn To: Subject: [PATCH v1 04/10] virsh: Introduce vcpudirtylimit api Date: Sat, 27 Aug 2022 01:20:08 +0800 Message-Id: <9155bb009ea655367ddbb0eabd92b6491dfcf8b9.1661533733.git.huangy81@chinatelecom.cn> 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.85 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: , 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.78 on 10.11.54.6 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: 1661534453674100009 Content-Type: text/plain; charset="utf-8" From: Hyman Huang(=E9=BB=84=E5=8B=87) Introduce vcpudirtylimit virsh api to set dirty page rate limit for virtual CPUs: $ virsh vcpudirtylimit [--vcpu ] Signed-off-by: Hyman Huang(=E9=BB=84=E5=8B=87) --- tools/virsh-domain.c | 83 ++++++++++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 83 insertions(+) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 20aadb5..8705090 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -13764,6 +13764,83 @@ cmdDomDirtyRateCalc(vshControl *ctl, const vshCmd = *cmd) return true; } =20 +/* + * "vcpudirtylimit" command + */ +static const vshCmdInfo info_vcpu_dirty_limit[] =3D { + {.name =3D "help", + .data =3D N_("Set vcpu dirty page rate limit.") + }, + {.name =3D "desc", + .data =3D N_("Set dirty page rate limit on virtual CPU.") + }, + {.name =3D NULL} +}; + +static const vshCmdOptDef opts_vcpu_dirty_limit[] =3D { + VIRSH_COMMON_OPT_DOMAIN_FULL(0), + {.name =3D "rate", + .type =3D VSH_OT_INT, + .flags =3D VSH_OFLAG_REQ, + .help =3D N_("Upper limit of dirty page rate (MB/s) for " + "virtual CPUs.") + }, + {.name =3D "vcpu", + .type =3D VSH_OT_INT, + .help =3D N_("Index of a virtual CPU.") + }, + {.name =3D NULL} +}; + +static bool +cmdVcpuDirtyLimit(vshControl *ctl, const vshCmd *cmd) +{ + g_autoptr(virshDomain) dom =3D NULL; + int vcpu_idx =3D -1; + unsigned long long rate =3D 0; + bool vcpu =3D vshCommandOptBool(cmd, "vcpu"); + unsigned int flags =3D 0; + + if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + return false; + + if (vcpu) { + if (vshCommandOptInt(ctl, cmd, "vcpu", &vcpu_idx) < 0) + return false; + + if (vcpu_idx < 0) { + vshError(ctl, "%s", _("Invalid vcpu index, using --vcpu " + "to specify cpu index")); + return false; + } + } + + if (vshCommandOptULongLong(ctl, cmd, "rate", &rate) < 0) + return false; + + if (!rate) { + vshError(ctl, "%s", _("Invalid dirty page rate limit")); + return false; + } + + if (vcpu) { + /* set specified vcpu dirty page rate limit of vm */ + if (virDomainSetVcpuDirtyLimit(dom, vcpu_idx, + rate, flags | VIR_DOMAIN_DIRTYLIMIT_VCPU) < 0) + return false; + vshPrintExtra(ctl, _("Set vcpu[%d] dirty page rate limit " + "%lld successfully.\n"), vcpu_idx, rate); + } else { + /* set all vcpu dirty page rate limit of vm */ + if (virDomainSetVcpuDirtyLimit(dom, -1, + rate, flags | VIR_DOMAIN_DIRTYLIMIT_ALL) < 0) + return false; + vshPrintExtra(ctl, _("Set dirty page rate limit %lld on all " + "virtual CPUs successfully.\n"), rate); + } + + return true; +} =20 const vshCmdDef domManagementCmds[] =3D { {.name =3D "attach-device", @@ -14422,5 +14499,11 @@ const vshCmdDef domManagementCmds[] =3D { .info =3D info_domdirtyrate_calc, .flags =3D 0 }, + {.name =3D "vcpudirtylimit", + .handler =3D cmdVcpuDirtyLimit, + .opts =3D opts_vcpu_dirty_limit, + .info =3D info_vcpu_dirty_limit, + .flags =3D 0 + }, {.name =3D NULL} }; --=20 1.8.3.1