From nobody Mon Feb 9 20:36:28 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; 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 1643254639463599.9392626661026; Wed, 26 Jan 2022 19:37:19 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-26-N35-ZhJvPMyK-JD-_icMnA-1; Wed, 26 Jan 2022 22:37:15 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 77D741F6B2; Thu, 27 Jan 2022 03:37:10 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 587CD1037F55; Thu, 27 Jan 2022 03:37:10 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 27BD24A70B; Thu, 27 Jan 2022 03:37:10 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20R3b3Tv019988 for ; Wed, 26 Jan 2022 22:37:03 -0500 Received: by smtp.corp.redhat.com (Postfix) id BFAE8202699A; Thu, 27 Jan 2022 03:37:03 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast03.extmail.prod.ext.rdu2.redhat.com [10.11.55.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BBA6B2026609 for ; Thu, 27 Jan 2022 03:37:00 +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 CBC84811E7F for ; Thu, 27 Jan 2022 03:37:00 +0000 (UTC) Received: from chinatelecom.cn (prt-mail.chinatelecom.cn [42.123.76.222]) by relay.mimecast.com with ESMTP id us-mta-101-RK7j_hdWP2uS_j6Ijfxomg-1; Wed, 26 Jan 2022 22:36:58 -0500 Received: from clientip-182.150.57.243 (unknown [172.18.0.218]) by chinatelecom.cn (HERMES) with SMTP id 4CB5528010C; Thu, 27 Jan 2022 11:36:39 +0800 (CST) Received: from ([172.18.0.218]) by app0025 with ESMTP id 969c3cf2830f41c6aa381c047c258715 for libvir-list@redhat.com; Thu, 27 Jan 2022 11:36:40 CST X-MC-Unique: N35-ZhJvPMyK-JD-_icMnA-1 X-MC-Unique: RK7j_hdWP2uS_j6Ijfxomg-1 HMM_SOURCE_IP: 172.18.0.218:40654.597248591 HMM_ATTACHE_NUM: 0000 HMM_SOURCE_TYPE: SMTP X-189-SAVE-TO-SEND: +huangy81@chinatelecom.cn X-Transaction-ID: 969c3cf2830f41c6aa381c047c258715 X-Real-From: huangy81@chinatelecom.cn X-Receive-IP: 172.18.0.218 X-MEDUSA-Status: 0 From: huangy81@chinatelecom.cn To: Subject: [PATCH v1 5/6] virsh: Extend domdirtyrate-calc virsh api Date: Thu, 27 Jan 2022 11:36:21 +0800 Message-Id: <64515c44749c6cf4491f942c1a4f9ebbd3dedbe9.1643250833.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-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 20R3b3Tv019988 X-loop: libvir-list@redhat.com Cc: =?UTF-8?q?Hyman=20Huang=28=E9=BB=84=E5=8B=87=29?= X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1643254641851100001 From: Hyman Huang(=E9=BB=84=E5=8B=87) Extend domdirtyrate-calc virsh api with mode option, either of these three options "page-sampling,dirty-bitmap,dirty-ring" can be specified when calculating dirty page rate. Signed-off-by: Hyman Huang(=E9=BB=84=E5=8B=87) --- docs/manpages/virsh.rst | 7 +++++-- src/libvirt-domain.c | 12 +++++++++++- tools/virsh-domain.c | 28 +++++++++++++++++++++++++++- 3 files changed, 43 insertions(+), 4 deletions(-) diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst index e28927e..e09703c 100644 --- a/docs/manpages/virsh.rst +++ b/docs/manpages/virsh.rst @@ -1714,13 +1714,16 @@ domdirtyrate-calc :: =20 domdirtyrate-calc [--seconds ] + [{--page-sampling | --dirty-bitmap | --dirty-ring}] =20 Calculate an active domain's memory dirty rate which may be expected by user in order to decide whether it's proper to be migrated out or not. The ``seconds`` parameter can be used to calculate dirty rate in a specific time which allows 60s at most now and would be default to 1s -if missing. The calculated dirty rate information is available by calling -'domstats --dirtyrate'. +if missing. These three *--page-sampling, --dirty-bitmap, --dirty-ring* +paremeters are mutually exclusive and used to specify calculation mode, +*--page-sampling* is the default mode if missing. The calculated dirty +rate information is available by calling 'domstats --dirtyrate'. =20 =20 domdisplay diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index 5912551..4caa740 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -13298,7 +13298,7 @@ virDomainGetMessages(virDomainPtr domain, * virDomainStartDirtyRateCalc: * @domain: a domain object * @seconds: specified calculating time in seconds - * @flags: extra flags; not used yet, so callers should always pass 0 + * @flags: bitwise-OR of supported virDomainDirtyRateCalcFlags * * Calculate the current domain's memory dirty rate in next @seconds. * The calculated dirty rate information is available by calling @@ -13322,6 +13322,16 @@ virDomainStartDirtyRateCalc(virDomainPtr domain, =20 virCheckReadOnlyGoto(conn->flags, error); =20 + VIR_EXCLUSIVE_FLAGS_GOTO(VIR_DOMAIN_DIRTYRATE_MODE_PAGE_SAMPLING, + VIR_DOMAIN_DIRTYRATE_MODE_DIRTY_BITMAP, + error); + VIR_EXCLUSIVE_FLAGS_GOTO(VIR_DOMAIN_DIRTYRATE_MODE_PAGE_SAMPLING, + VIR_DOMAIN_DIRTYRATE_MODE_DIRTY_RING, + error); + VIR_EXCLUSIVE_FLAGS_GOTO(VIR_DOMAIN_DIRTYRATE_MODE_DIRTY_BITMAP, + VIR_DOMAIN_DIRTYRATE_MODE_DIRTY_RING, + error); + if (conn->driver->domainStartDirtyRateCalc) { int ret; ret =3D conn->driver->domainStartDirtyRateCalc(domain, seconds, fl= ags); diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index b56f6a9..a032f70 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -14465,6 +14465,20 @@ static const vshCmdOptDef opts_domdirtyrate_calc[]= =3D { .help =3D N_("calculate memory dirty rate within specified seconds, " "the supported value range from 1 to 60, default to 1.") }, + {.name =3D "page-sampling", + .type =3D VSH_OT_BOOL, + .help =3D N_("dirty page rate is calculated by sampling memory.") + }, + {.name =3D "dirty-bitmap", + .type =3D VSH_OT_BOOL, + .help =3D N_("dirty page rate is calculated by recording dirty bitmap= " + "during calculation period.") + }, + {.name =3D "dirty-ring", + .type =3D VSH_OT_BOOL, + .help =3D N_("dirty page rate is calculated by recording dirty pages " + "for a virtual CPU when dirty-ring feature enabled.") + }, {.name =3D NULL} }; =20 @@ -14473,6 +14487,7 @@ cmdDomDirtyRateCalc(vshControl *ctl, const vshCmd *= cmd) { g_autoptr(virshDomain) dom =3D NULL; int seconds =3D 1; /* the default value is 1 */ + unsigned int flags =3D 0; =20 if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; @@ -14480,7 +14495,18 @@ cmdDomDirtyRateCalc(vshControl *ctl, const vshCmd = *cmd) if (vshCommandOptInt(ctl, cmd, "seconds", &seconds) < 0) return false; =20 - if (virDomainStartDirtyRateCalc(dom, seconds, 0) < 0) + if (vshCommandOptBool(cmd, "page-sampling")) + flags |=3D VIR_DOMAIN_DIRTYRATE_MODE_PAGE_SAMPLING; + if (vshCommandOptBool(cmd, "dirty-bitmap")) + flags |=3D VIR_DOMAIN_DIRTYRATE_MODE_DIRTY_BITMAP;; + if (vshCommandOptBool(cmd, "dirty-ring")) + flags |=3D VIR_DOMAIN_DIRTYRATE_MODE_DIRTY_RING;; + + VSH_EXCLUSIVE_OPTIONS("page-sampling", "dirty-bitmap"); + VSH_EXCLUSIVE_OPTIONS("page-sampling", "dirty-ring"); + VSH_EXCLUSIVE_OPTIONS("dirty-bitmap", "dirty-ring"); + + if (virDomainStartDirtyRateCalc(dom, seconds, flags) < 0) return false; =20 vshPrintExtra(ctl, _("Start to calculate domain's memory " --=20 1.8.3.1