From nobody Mon Feb 9 10:21:00 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=1660409024; cv=none; d=zohomail.com; s=zohoarc; b=UKgkV6k6pCLWuuFlB73kUwmS7SVtaaz4rPDig7uAWcK9GESXFYIqGHYB45IztJT5LejLbUw8eI10sQkam926jT6oP/rasHS44e8u7eO9pLNc3gDHl7glLpe5bZrFywxzJAcD3hpt9l6vgZdMCqMT7SnBUabjTGKSn1Z4wPh0L3A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1660409024; 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=N+wIfnr9O7oTSqqSnnzN0iOtj13mYFt2rUlcXxoDCHU=; b=NBf+p9La1Rxsqi44CVRqR+PWvnSCvcLqx+1aSGuHOq1m/c8COmTgIgh45UpgPusni5BEzRZQcP9u1UGrl6SYCE7hQXeUnsZcHCwG/eS1V2op8TN1QNHcwqIP5smzvEtAJVXdK1aa5WG2SQAAHJJMoJikwR3QImg6CgAlGs3hPx8= 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 1660409024424118.08632090861659; Sat, 13 Aug 2022 09:43:44 -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-297-RtgM6GEUP9CxztnKI1x4Og-1; Sat, 13 Aug 2022 12:43:32 -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 68D611C0782E; Sat, 13 Aug 2022 16:43:27 +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 56101909FE; Sat, 13 Aug 2022 16:43:27 +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 EBEB11946A78; Sat, 13 Aug 2022 16:43:24 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 2917C1947049 for ; Sat, 13 Aug 2022 16:43:22 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 0F1AF9458A; Sat, 13 Aug 2022 16:43:22 +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 0B4A2909FE for ; Sat, 13 Aug 2022 16:43:22 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.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 E2D943806723 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-637-3Ks-QUPVPyOLkrSFEZ0aFg-1; Sat, 13 Aug 2022 12:43:14 -0400 Received: from clientip-118.116.19.21 (unknown [172.18.0.218]) by chinatelecom.cn (HERMES) with SMTP id 729E128009D; Sun, 14 Aug 2022 00:31:45 +0800 (CST) Received: from ([172.18.0.218]) by app0025 with ESMTP id d328df0b0ce8438ebfb1d8f53cc66592 for libvir-list@redhat.com; Sun, 14 Aug 2022 00:31:46 CST DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660409023; 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=N+wIfnr9O7oTSqqSnnzN0iOtj13mYFt2rUlcXxoDCHU=; b=f1LqyYGWN8H0UVB5vPf98ywbL123G/iewAQu0HaZxslFQXLnM0Dw4vHIVuwCOnk+KZWeEL uvmmaqOHP7eIQKbeC/RYRzOyaRFgVuRPD23LP6SQQbkbfAJkh17f6AFLSa1++x9cFSeCWW 9egxAeik/kI0vk8Uu58485is6en4oGo= X-MC-Unique: RtgM6GEUP9CxztnKI1x4Og-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: 3Ks-QUPVPyOLkrSFEZ0aFg-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: d328df0b0ce8438ebfb1d8f53cc66592 X-Real-From: huangy81@chinatelecom.cn X-Receive-IP: 172.18.0.218 X-MEDUSA-Status: 0 From: huangy81@chinatelecom.cn To: Subject: [PATCH 04/11] virsh: Introduce vcpudirtylimit api Date: Sun, 14 Aug 2022 00:31:16 +0800 Message-Id: <5931ec1130a00c937ff71774bb517229d58ff438.1660406067.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.79 on 10.11.54.5 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.79 on 10.11.54.5 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: 1660409025942100001 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 451f51d..95104b2 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -13763,6 +13763,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", @@ -14421,5 +14498,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