From nobody Mon Apr 29 08:03:13 2024 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; 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 1643254631726292.31755621375305; Wed, 26 Jan 2022 19:37:11 -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-511-i8oKnaZCMsiK4A7p5jacNQ-1; Wed, 26 Jan 2022 22:37:07 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 37A431083F64; Thu, 27 Jan 2022 03:37:02 +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 1430E6AB9D; Thu, 27 Jan 2022 03:37:02 +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 DA31A4A7C9; Thu, 27 Jan 2022 03:37:01 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20R3adrS019880 for ; Wed, 26 Jan 2022 22:36:42 -0500 Received: by smtp.corp.redhat.com (Postfix) id 3D174492D57; Thu, 27 Jan 2022 03:36:39 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast02.extmail.prod.ext.rdu2.redhat.com [10.11.55.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 39016492D4E for ; Thu, 27 Jan 2022 03:36:39 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) (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 193118027FA for ; Thu, 27 Jan 2022 03:36:39 +0000 (UTC) Received: from chinatelecom.cn (prt-mail.chinatelecom.cn [42.123.76.222]) by relay.mimecast.com with ESMTP id us-mta-655-lYq2salrM3-lsJ0rlI8w6g-1; Wed, 26 Jan 2022 22:36:36 -0500 Received: from clientip-182.150.57.243 (unknown [172.18.0.218]) by chinatelecom.cn (HERMES) with SMTP id 524A8280103; Thu, 27 Jan 2022 11:36:33 +0800 (CST) Received: from ([172.18.0.218]) by app0025 with ESMTP id aa3b46e891154b6e8df483b7635807bf for libvir-list@redhat.com; Thu, 27 Jan 2022 11:36:34 CST X-MC-Unique: i8oKnaZCMsiK4A7p5jacNQ-1 X-MC-Unique: lYq2salrM3-lsJ0rlI8w6g-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: aa3b46e891154b6e8df483b7635807bf 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 1/6] qemu_capabilities: Introduce QEMU_CAPS_CALC_DIRTY_RATE capability Date: Thu, 27 Jan 2022 11:36:17 +0800 Message-Id: <8b2b806604f6790bd323251114fd633c826e7c86.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-Mimecast-Spam-Signature: yes X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 20R3adrS019880 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.79 on 10.5.11.16 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: 1643254633459100001 From: Hyman Huang(=E9=BB=84=E5=8B=87) calc-dirty-rate command was introduced since qemu >=3D5.2.0. Introduce QEMU_CAPS_CALC_DIRTY_RATE capability definition. Signed-off-by: Hyman Huang(=E9=BB=84=E5=8B=87) --- src/qemu/qemu_capabilities.c | 2 ++ src/qemu/qemu_capabilities.h | 1 + tests/qemucapabilitiesdata/caps_5.2.0.aarch64.xml | 1 + tests/qemucapabilitiesdata/caps_5.2.0.ppc64.xml | 1 + tests/qemucapabilitiesdata/caps_5.2.0.riscv64.xml | 1 + tests/qemucapabilitiesdata/caps_5.2.0.s390x.xml | 1 + tests/qemucapabilitiesdata/caps_5.2.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_6.0.0.aarch64.xml | 1 + tests/qemucapabilitiesdata/caps_6.0.0.s390x.xml | 1 + tests/qemucapabilitiesdata/caps_6.0.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_6.1.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_6.2.0.aarch64.xml | 1 + tests/qemucapabilitiesdata/caps_6.2.0.ppc64.xml | 1 + tests/qemucapabilitiesdata/caps_6.2.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_7.0.0.ppc64.xml | 1 + tests/qemucapabilitiesdata/caps_7.0.0.x86_64.xml | 1 + 16 files changed, 17 insertions(+) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 461a818..de08e81 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -657,6 +657,7 @@ VIR_ENUM_IMPL(virQEMUCaps, =20 /* 420 */ "device.json+hotplug", /* QEMU_CAPS_DEVICE_JSON */ + "calc-dirty-rate", /* QEMU_CAPS_CALC_DIRTY_RATE */ ); =20 =20 @@ -1187,6 +1188,7 @@ struct virQEMUCapsStringFlags virQEMUCapsCommands[] = =3D { { "set-action", QEMU_CAPS_SET_ACTION }, { "query-dirty-rate", QEMU_CAPS_QUERY_DIRTY_RATE }, { "sev-inject-launch-secret", QEMU_CAPS_SEV_INJECT_LAUNCH_SECRET }, + { "calc-dirty-rate", QEMU_CAPS_CALC_DIRTY_RATE }, }; =20 struct virQEMUCapsStringFlags virQEMUCapsMigration[] =3D { diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index 7d42e3a..598cef9 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -636,6 +636,7 @@ typedef enum { /* virQEMUCapsFlags grouping marker for = syntax-check */ =20 /* 420 */ QEMU_CAPS_DEVICE_JSON, /* -device accepts JSON (and works with hot-unp= lug) */ + QEMU_CAPS_CALC_DIRTY_RATE, /* accepts calc-dirty-rate */ =20 QEMU_CAPS_LAST /* this must always be the last item */ } virQEMUCapsFlags; diff --git a/tests/qemucapabilitiesdata/caps_5.2.0.aarch64.xml b/tests/qemu= capabilitiesdata/caps_5.2.0.aarch64.xml index e809b95..9f14d59 100644 --- a/tests/qemucapabilitiesdata/caps_5.2.0.aarch64.xml +++ b/tests/qemucapabilitiesdata/caps_5.2.0.aarch64.xml @@ -183,6 +183,7 @@ + 5002000 0 61700243 diff --git a/tests/qemucapabilitiesdata/caps_5.2.0.ppc64.xml b/tests/qemuca= pabilitiesdata/caps_5.2.0.ppc64.xml index 0cbbffe..e050514 100644 --- a/tests/qemucapabilitiesdata/caps_5.2.0.ppc64.xml +++ b/tests/qemucapabilitiesdata/caps_5.2.0.ppc64.xml @@ -189,6 +189,7 @@ + 5002000 0 42900243 diff --git a/tests/qemucapabilitiesdata/caps_5.2.0.riscv64.xml b/tests/qemu= capabilitiesdata/caps_5.2.0.riscv64.xml index 13a6967..4b123d4 100644 --- a/tests/qemucapabilitiesdata/caps_5.2.0.riscv64.xml +++ b/tests/qemucapabilitiesdata/caps_5.2.0.riscv64.xml @@ -173,6 +173,7 @@ + 5002000 0 0 diff --git a/tests/qemucapabilitiesdata/caps_5.2.0.s390x.xml b/tests/qemuca= pabilitiesdata/caps_5.2.0.s390x.xml index 518bb7a..bc3c3c3 100644 --- a/tests/qemucapabilitiesdata/caps_5.2.0.s390x.xml +++ b/tests/qemucapabilitiesdata/caps_5.2.0.s390x.xml @@ -140,6 +140,7 @@ + 5002000 0 39100243 diff --git a/tests/qemucapabilitiesdata/caps_5.2.0.x86_64.xml b/tests/qemuc= apabilitiesdata/caps_5.2.0.x86_64.xml index 64e7bc2..70ad14f 100644 --- a/tests/qemucapabilitiesdata/caps_5.2.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_5.2.0.x86_64.xml @@ -225,6 +225,7 @@ + 5002000 0 43100243 diff --git a/tests/qemucapabilitiesdata/caps_6.0.0.aarch64.xml b/tests/qemu= capabilitiesdata/caps_6.0.0.aarch64.xml index 743f7d9..9d501f2 100644 --- a/tests/qemucapabilitiesdata/caps_6.0.0.aarch64.xml +++ b/tests/qemucapabilitiesdata/caps_6.0.0.aarch64.xml @@ -191,6 +191,7 @@ + 6000000 0 61700242 diff --git a/tests/qemucapabilitiesdata/caps_6.0.0.s390x.xml b/tests/qemuca= pabilitiesdata/caps_6.0.0.s390x.xml index b034ffd..02b24f5 100644 --- a/tests/qemucapabilitiesdata/caps_6.0.0.s390x.xml +++ b/tests/qemucapabilitiesdata/caps_6.0.0.s390x.xml @@ -148,6 +148,7 @@ + 6000000 0 39100242 diff --git a/tests/qemucapabilitiesdata/caps_6.0.0.x86_64.xml b/tests/qemuc= apabilitiesdata/caps_6.0.0.x86_64.xml index b213abb..8ea688f 100644 --- a/tests/qemucapabilitiesdata/caps_6.0.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_6.0.0.x86_64.xml @@ -234,6 +234,7 @@ + 6000000 0 43100242 diff --git a/tests/qemucapabilitiesdata/caps_6.1.0.x86_64.xml b/tests/qemuc= apabilitiesdata/caps_6.1.0.x86_64.xml index d9bdcf9..ba1aecc 100644 --- a/tests/qemucapabilitiesdata/caps_6.1.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_6.1.0.x86_64.xml @@ -238,6 +238,7 @@ + 6001000 0 43100243 diff --git a/tests/qemucapabilitiesdata/caps_6.2.0.aarch64.xml b/tests/qemu= capabilitiesdata/caps_6.2.0.aarch64.xml index f200a7d..17d563e 100644 --- a/tests/qemucapabilitiesdata/caps_6.2.0.aarch64.xml +++ b/tests/qemucapabilitiesdata/caps_6.2.0.aarch64.xml @@ -202,6 +202,7 @@ + 6001050 0 61700244 diff --git a/tests/qemucapabilitiesdata/caps_6.2.0.ppc64.xml b/tests/qemuca= pabilitiesdata/caps_6.2.0.ppc64.xml index ae5c1d3..eaa0ccc 100644 --- a/tests/qemucapabilitiesdata/caps_6.2.0.ppc64.xml +++ b/tests/qemucapabilitiesdata/caps_6.2.0.ppc64.xml @@ -199,6 +199,7 @@ + 6002000 0 42900244 diff --git a/tests/qemucapabilitiesdata/caps_6.2.0.x86_64.xml b/tests/qemuc= apabilitiesdata/caps_6.2.0.x86_64.xml index 103d00f..f3e86de 100644 --- a/tests/qemucapabilitiesdata/caps_6.2.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_6.2.0.x86_64.xml @@ -239,6 +239,7 @@ + 6002000 0 43100244 diff --git a/tests/qemucapabilitiesdata/caps_7.0.0.ppc64.xml b/tests/qemuca= pabilitiesdata/caps_7.0.0.ppc64.xml index 88eee87..e9e9b43 100644 --- a/tests/qemucapabilitiesdata/caps_7.0.0.ppc64.xml +++ b/tests/qemucapabilitiesdata/caps_7.0.0.ppc64.xml @@ -200,6 +200,7 @@ + 6002050 0 42900243 diff --git a/tests/qemucapabilitiesdata/caps_7.0.0.x86_64.xml b/tests/qemuc= apabilitiesdata/caps_7.0.0.x86_64.xml index 0753ac5..e28b48e 100644 --- a/tests/qemucapabilitiesdata/caps_7.0.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_7.0.0.x86_64.xml @@ -240,6 +240,7 @@ + 6002050 0 43100243 --=20 1.8.3.1 From nobody Mon Apr 29 08:03:13 2024 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; 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 1643254619209845.1057740758918; Wed, 26 Jan 2022 19:36:59 -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-175-QYegHugBMguZJGwCdhphgw-1; Wed, 26 Jan 2022 22:36:54 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 45CD61006AA5; Thu, 27 Jan 2022 03:36:49 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CF6E312E3F; Thu, 27 Jan 2022 03:36:48 +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 4682C1809CBA; Thu, 27 Jan 2022 03:36:47 +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 20R3aibP019902 for ; Wed, 26 Jan 2022 22:36:45 -0500 Received: by smtp.corp.redhat.com (Postfix) id A85EA2026612; Thu, 27 Jan 2022 03:36:44 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast07.extmail.prod.ext.rdu2.redhat.com [10.11.55.23]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A3F9420268FE for ; Thu, 27 Jan 2022 03:36:39 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) (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 AB3E53C11A2E for ; Thu, 27 Jan 2022 03:36:39 +0000 (UTC) Received: from chinatelecom.cn (prt-mail.chinatelecom.cn [42.123.76.222]) by relay.mimecast.com with ESMTP id us-mta-669-yjqhUvTNPn-Ykv4A5P_5BQ-1; Wed, 26 Jan 2022 22:36:37 -0500 Received: from clientip-182.150.57.243 (unknown [172.18.0.218]) by chinatelecom.cn (HERMES) with SMTP id 60A952800EF; Thu, 27 Jan 2022 11:36:34 +0800 (CST) Received: from ([172.18.0.218]) by app0025 with ESMTP id cacc082d93b04438b9975d0f6769e448 for libvir-list@redhat.com; Thu, 27 Jan 2022 11:36:35 CST X-MC-Unique: QYegHugBMguZJGwCdhphgw-1 X-MC-Unique: yjqhUvTNPn-Ykv4A5P_5BQ-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: cacc082d93b04438b9975d0f6769e448 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 2/6] qemu_driver: Probe capability before calculating dirty page rate Date: Thu, 27 Jan 2022 11:36:18 +0800 Message-Id: <5d52a8aeb848e3279b7a095ce9570f5c31af4171.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-Mimecast-Spam-Signature: yes 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 20R3aibP019902 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.79 on 10.5.11.15 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: 1643254622572100003 From: Hyman Huang(=E9=BB=84=E5=8B=87) Probing QEMU_CAPS_CALC_DIRTY_RATE capability in advance in case of failure when calculating dirty page rate. Signed-off-by: Hyman Huang(=E9=BB=84=E5=8B=87) --- src/qemu/qemu_driver.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 0a1ba74..0e8e9b1 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -20647,10 +20647,22 @@ qemuDomainStartDirtyRateCalc(virDomainPtr dom, virQEMUDriver *driver =3D dom->conn->privateData; virDomainObj *vm =3D NULL; qemuDomainObjPrivate *priv; + g_autoptr(virQEMUCaps) qemucaps =3D NULL; int ret =3D -1; =20 virCheckFlags(0, -1); =20 + if (!(qemucaps =3D virQEMUCapsCacheLookupDefault(driver->qemuCapsCache, + NULL, NULL, NULL, NULL, + NULL, NULL, NULL))) + return -1; + + if (!virQEMUCapsGet(qemucaps, QEMU_CAPS_CALC_DIRTY_RATE)) { + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", + _("QEMU does not support calculating dirty page rat= e")); + return -1; + } + if (seconds < MIN_DIRTYRATE_CALC_PERIOD || seconds > MAX_DIRTYRATE_CALC_PERIOD) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, --=20 1.8.3.1 From nobody Mon Apr 29 08:03:13 2024 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; 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 1643254639892193.46526882979038; 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-103-ZkDg9dj_MNmj5W9rXnKu2w-1; Wed, 26 Jan 2022 22:37:09 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B16DB8144E1; Thu, 27 Jan 2022 03:37:04 +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 918CD4DC00; Thu, 27 Jan 2022 03:37:04 +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 5B1C74A700; Thu, 27 Jan 2022 03:37:04 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20R3ajae019905 for ; Wed, 26 Jan 2022 22:36:45 -0500 Received: by smtp.corp.redhat.com (Postfix) id 1A8FA1457F07; Thu, 27 Jan 2022 03:36:45 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast02.extmail.prod.ext.rdu2.redhat.com [10.11.55.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 169B71457F06 for ; Thu, 27 Jan 2022 03:36:45 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) (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 F210F800B29 for ; Thu, 27 Jan 2022 03:36:44 +0000 (UTC) Received: from chinatelecom.cn (prt-mail.chinatelecom.cn [42.123.76.222]) by relay.mimecast.com with ESMTP id us-mta-468-5MKhqZvXNJWvFa7e9hWCcg-1; Wed, 26 Jan 2022 22:36:41 -0500 Received: from clientip-182.150.57.243 (unknown [172.18.0.218]) by chinatelecom.cn (HERMES) with SMTP id 30C72280109; Thu, 27 Jan 2022 11:36:35 +0800 (CST) Received: from ([172.18.0.218]) by app0025 with ESMTP id 649413fcd5e44ac8861d243b217d4a79 for libvir-list@redhat.com; Thu, 27 Jan 2022 11:36:38 CST X-MC-Unique: ZkDg9dj_MNmj5W9rXnKu2w-1 X-MC-Unique: 5MKhqZvXNJWvFa7e9hWCcg-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: 649413fcd5e44ac8861d243b217d4a79 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 3/6] qemu_capabilities: Introduce QEMU_CAPS_DIRTYRATE_MODE capability Date: Thu, 27 Jan 2022 11:36:19 +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.85 on 10.11.54.7 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 20R3ajae019905 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.79 on 10.5.11.15 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: 1643254641875100002 From: Hyman Huang(=E9=BB=84=E5=8B=87) mode option of calc-dirty-rate command since qemu >=3D6.2.0. Introduce QEMU_CAPS_DIRTYRATE_MODE capability definition. Signed-off-by: Hyman Huang(=E9=BB=84=E5=8B=87) --- src/qemu/qemu_capabilities.c | 2 ++ src/qemu/qemu_capabilities.h | 1 + tests/qemucapabilitiesdata/caps_6.2.0.ppc64.xml | 1 + tests/qemucapabilitiesdata/caps_6.2.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_7.0.0.ppc64.xml | 1 + tests/qemucapabilitiesdata/caps_7.0.0.x86_64.xml | 1 + 6 files changed, 7 insertions(+) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index de08e81..367c286 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -658,6 +658,7 @@ VIR_ENUM_IMPL(virQEMUCaps, /* 420 */ "device.json+hotplug", /* QEMU_CAPS_DEVICE_JSON */ "calc-dirty-rate", /* QEMU_CAPS_CALC_DIRTY_RATE */ + "dirtyrate-param.mode", /* QEMU_CAPS_DIRTYRATE_MODE */ ); =20 =20 @@ -1576,6 +1577,7 @@ static struct virQEMUCapsStringFlags virQEMUCapsQMPSc= hemaQueries[] =3D { { "screendump/arg-type/device", QEMU_CAPS_SCREENDUMP_DEVICE }, { "set-numa-node/arg-type/+hmat-lb", QEMU_CAPS_NUMA_HMAT }, { "object-add/arg-type/+sev-guest/kernel-hashes", QEMU_CAPS_SEV_GUEST_= KERNEL_HASHES }, + { "calc-dirty-rate/arg-type/mode", QEMU_CAPS_DIRTYRATE_MODE }, }; =20 typedef struct _virQEMUCapsObjectTypeProps virQEMUCapsObjectTypeProps; diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index 598cef9..329701c 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -637,6 +637,7 @@ typedef enum { /* virQEMUCapsFlags grouping marker for = syntax-check */ /* 420 */ QEMU_CAPS_DEVICE_JSON, /* -device accepts JSON (and works with hot-unp= lug) */ QEMU_CAPS_CALC_DIRTY_RATE, /* accepts calc-dirty-rate */ + QEMU_CAPS_DIRTYRATE_MODE , /* calc-dirty-rate accepts mode parameter */ =20 QEMU_CAPS_LAST /* this must always be the last item */ } virQEMUCapsFlags; diff --git a/tests/qemucapabilitiesdata/caps_6.2.0.ppc64.xml b/tests/qemuca= pabilitiesdata/caps_6.2.0.ppc64.xml index eaa0ccc..9fe9c27 100644 --- a/tests/qemucapabilitiesdata/caps_6.2.0.ppc64.xml +++ b/tests/qemucapabilitiesdata/caps_6.2.0.ppc64.xml @@ -200,6 +200,7 @@ + 6002000 0 42900244 diff --git a/tests/qemucapabilitiesdata/caps_6.2.0.x86_64.xml b/tests/qemuc= apabilitiesdata/caps_6.2.0.x86_64.xml index f3e86de..d77907a 100644 --- a/tests/qemucapabilitiesdata/caps_6.2.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_6.2.0.x86_64.xml @@ -240,6 +240,7 @@ + 6002000 0 43100244 diff --git a/tests/qemucapabilitiesdata/caps_7.0.0.ppc64.xml b/tests/qemuca= pabilitiesdata/caps_7.0.0.ppc64.xml index e9e9b43..5d7f283 100644 --- a/tests/qemucapabilitiesdata/caps_7.0.0.ppc64.xml +++ b/tests/qemucapabilitiesdata/caps_7.0.0.ppc64.xml @@ -201,6 +201,7 @@ + 6002050 0 42900243 diff --git a/tests/qemucapabilitiesdata/caps_7.0.0.x86_64.xml b/tests/qemuc= apabilitiesdata/caps_7.0.0.x86_64.xml index e28b48e..6bc6e7f 100644 --- a/tests/qemucapabilitiesdata/caps_7.0.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_7.0.0.x86_64.xml @@ -241,6 +241,7 @@ + 6002050 0 43100243 --=20 1.8.3.1 From nobody Mon Apr 29 08:03:13 2024 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 1643254624323741.6862894528113; Wed, 26 Jan 2022 19:37:04 -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-104-o9IqceXsOAW9RY-pT731Rg-1; Wed, 26 Jan 2022 22:37:00 -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 C7DD88144E1; Thu, 27 Jan 2022 03:36:54 +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 76D671037F52; Thu, 27 Jan 2022 03:36:54 +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 305C84BB7C; Thu, 27 Jan 2022 03:36:54 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20R3apxo019930 for ; Wed, 26 Jan 2022 22:36:52 -0500 Received: by smtp.corp.redhat.com (Postfix) id B6C7D417E47; Thu, 27 Jan 2022 03:36:51 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B2F77401E9D for ; Thu, 27 Jan 2022 03:36:51 +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 98A3385A5AA for ; Thu, 27 Jan 2022 03:36:51 +0000 (UTC) Received: from chinatelecom.cn (prt-mail.chinatelecom.cn [42.123.76.222]) by relay.mimecast.com with ESMTP id us-mta-479-LqAHuM6KNTSwBWdhljq2HA-1; Wed, 26 Jan 2022 22:36:48 -0500 Received: from clientip-182.150.57.243 (unknown [172.18.0.218]) by chinatelecom.cn (HERMES) with SMTP id 428392800B8; Thu, 27 Jan 2022 11:36:38 +0800 (CST) Received: from ([172.18.0.218]) by app0025 with ESMTP id d0bf2a61ae2548368d715c6d7a64c0dc for libvir-list@redhat.com; Thu, 27 Jan 2022 11:36:39 CST X-MC-Unique: o9IqceXsOAW9RY-pT731Rg-1 X-MC-Unique: LqAHuM6KNTSwBWdhljq2HA-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: d0bf2a61ae2548368d715c6d7a64c0dc 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 4/6] qemu_driver: Add mode option for qemuDomainStartDirtyRateCalc Date: Thu, 27 Jan 2022 11:36:20 +0800 Message-Id: <876ce5a1ad905021e90ae4cdd7f8b00af4c993f2.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.85 on 10.11.54.10 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 20R3apxo019930 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: 1643254625288100001 From: Hyman Huang(=E9=BB=84=E5=8B=87) Add mode option to extend qemuDomainStartDirtyRateCalc API, which is introduced since qemu >=3D 6.2. Signed-off-by: Hyman Huang(=E9=BB=84=E5=8B=87) --- include/libvirt/libvirt-domain.h | 13 +++++++++++++ src/qemu/qemu_driver.c | 33 +++++++++++++++++++++++++++++++-- src/qemu/qemu_monitor.c | 5 +++-- src/qemu/qemu_monitor.h | 10 +++++++++- src/qemu/qemu_monitor_json.c | 26 +++++++++++++++++++++----- src/qemu/qemu_monitor_json.h | 3 ++- 6 files changed, 79 insertions(+), 11 deletions(-) diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-dom= ain.h index 4da1a63..54bb23b 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -5257,6 +5257,19 @@ typedef enum { # endif } virDomainDirtyRateStatus; =20 +/** + * virDomainDirtyRateCalcFlags: + * + * Flags OR'ed together to provide specific behaviour when calculating dir= ty page + * rate for a Domain + * + */ +typedef enum { + VIR_DOMAIN_DIRTYRATE_MODE_PAGE_SAMPLING =3D 0, /* default mode = - page-sampling */ + VIR_DOMAIN_DIRTYRATE_MODE_DIRTY_BITMAP =3D 1 << 0, /* dirty-bitmap = mode */ + VIR_DOMAIN_DIRTYRATE_MODE_DIRTY_RING =3D 1 << 1, /* dirty-ring mo= de */ +} virDomainDirtyRateCalcFlags; + int virDomainStartDirtyRateCalc(virDomainPtr domain, int seconds, unsigned int flags); diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 0e8e9b1..feebfc4 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -20648,9 +20648,13 @@ qemuDomainStartDirtyRateCalc(virDomainPtr dom, virDomainObj *vm =3D NULL; qemuDomainObjPrivate *priv; g_autoptr(virQEMUCaps) qemucaps =3D NULL; + qemuMonitorDirtyRateCalcMode calcmode =3D VIR_DOMAIN_DIRTYRATE_CALC_MO= DE_PAGE_SAMPLING; + bool mode =3D false; int ret =3D -1; =20 - virCheckFlags(0, -1); + virCheckFlags(VIR_DOMAIN_DIRTYRATE_MODE_PAGE_SAMPLING | + VIR_DOMAIN_DIRTYRATE_MODE_DIRTY_BITMAP | + VIR_DOMAIN_DIRTYRATE_MODE_DIRTY_RING, -1); =20 if (!(qemucaps =3D virQEMUCapsCacheLookupDefault(driver->qemuCapsCache, NULL, NULL, NULL, NULL, @@ -20663,6 +20667,15 @@ qemuDomainStartDirtyRateCalc(virDomainPtr dom, return -1; } =20 + mode =3D virQEMUCapsGet(qemucaps, QEMU_CAPS_DIRTYRATE_MODE); + + if (!mode && (flags & VIR_DOMAIN_DIRTYRATE_MODE_DIRTY_BITMAP || + (flags & VIR_DOMAIN_DIRTYRATE_MODE_DIRTY_RING))) { + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", + _("QEMU does not support calculating dirty page rat= e" + "with specified mode")); + } + if (seconds < MIN_DIRTYRATE_CALC_PERIOD || seconds > MAX_DIRTYRATE_CALC_PERIOD) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, @@ -20676,6 +20689,22 @@ qemuDomainStartDirtyRateCalc(virDomainPtr dom, if (!(vm =3D qemuDomainObjFromDomain(dom))) return -1; =20 + if (mode) { + /* libvirt-domain.c already guaranteed these two flags are exclusi= ve. */ + if (flags & VIR_DOMAIN_DIRTYRATE_MODE_DIRTY_BITMAP) { + calcmode =3D VIR_DOMAIN_DIRTYRATE_CALC_MODE_DIRTY_BITMAP; + } else if (flags & VIR_DOMAIN_DIRTYRATE_MODE_DIRTY_RING) { + if (vm->def->features[VIR_DOMAIN_FEATURE_KVM] !=3D VIR_TRISTAT= E_SWITCH_ON || + vm->def->kvm_features->features[VIR_DOMAIN_KVM_DIRTY_RING]= !=3D VIR_TRISTATE_SWITCH_ON) { + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", + _("Calculating dirty page rate with dirty-r= ing requires" + "dirty-ring feature enabled.")); + goto cleanup; + } + calcmode =3D VIR_DOMAIN_DIRTYRATE_CALC_MODE_DIRTY_RING; + } + } + if (virDomainStartDirtyRateCalcEnsureACL(dom->conn, vm->def) < 0) goto cleanup; =20 @@ -20692,7 +20721,7 @@ qemuDomainStartDirtyRateCalc(virDomainPtr dom, =20 priv =3D vm->privateData; qemuDomainObjEnterMonitor(driver, vm); - ret =3D qemuMonitorStartDirtyRateCalc(priv->mon, seconds); + ret =3D qemuMonitorStartDirtyRateCalc(priv->mon, seconds, calcmode); =20 qemuDomainObjExitMonitor(driver, vm); =20 diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index babf9e6..b82a1a3 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -4532,13 +4532,14 @@ qemuMonitorTransactionBackup(virJSONValue *actions, =20 int qemuMonitorStartDirtyRateCalc(qemuMonitor *mon, - int seconds) + int seconds, + qemuMonitorDirtyRateCalcMode mode) { VIR_DEBUG("seconds=3D%d", seconds); =20 QEMU_CHECK_MONITOR(mon); =20 - return qemuMonitorJSONStartDirtyRateCalc(mon, seconds); + return qemuMonitorJSONStartDirtyRateCalc(mon, seconds, mode); } =20 =20 diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 9b2e4e1..08e14c0 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -1551,9 +1551,17 @@ qemuMonitorTransactionBackup(virJSONValue *actions, const char *bitmap, qemuMonitorTransactionBackupSyncMode syncmode= ); =20 +typedef enum { + VIR_DOMAIN_DIRTYRATE_CALC_MODE_PAGE_SAMPLING =3D 0, + VIR_DOMAIN_DIRTYRATE_CALC_MODE_DIRTY_BITMAP, + VIR_DOMAIN_DIRTYRATE_CALC_MODE_DIRTY_RING, + VIR_DOMAIN_DIRTYRATE_CALC_MODE_LAST, +} qemuMonitorDirtyRateCalcMode; + int qemuMonitorStartDirtyRateCalc(qemuMonitor *mon, - int seconds); + int seconds, + qemuMonitorDirtyRateCalcMode mode); =20 typedef struct _qemuMonitorDirtyRateInfo qemuMonitorDirtyRateInfo; struct _qemuMonitorDirtyRateInfo { diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index b0b5136..afbd721 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -8695,18 +8695,34 @@ qemuMonitorJSONGetCPUMigratable(qemuMonitor *mon, migratable); } =20 +VIR_ENUM_DECL(qemuMonitorDirtyRateCalcMode); +VIR_ENUM_IMPL(qemuMonitorDirtyRateCalcMode, + VIR_DOMAIN_DIRTYRATE_CALC_MODE_LAST, + "page-sampling", + "dirty-bitmap", + "dirty-ring"); =20 int qemuMonitorJSONStartDirtyRateCalc(qemuMonitor *mon, - int seconds) + int seconds, + qemuMonitorDirtyRateCalcMode mode) { g_autoptr(virJSONValue) cmd =3D NULL; g_autoptr(virJSONValue) reply =3D NULL; =20 - if (!(cmd =3D qemuMonitorJSONMakeCommand("calc-dirty-rate", - "i:calc-time", seconds, - NULL))) - return -1; + if (mode =3D=3D VIR_DOMAIN_DIRTYRATE_CALC_MODE_PAGE_SAMPLING) { + if (!(cmd =3D qemuMonitorJSONMakeCommand("calc-dirty-rate", + "i:calc-time", seconds, + NULL))) + return -1; + } else { + const char *modestr =3D qemuMonitorDirtyRateCalcModeTypeToString(m= ode); + if (!(cmd =3D qemuMonitorJSONMakeCommand("calc-dirty-rate", + "i:calc-time", seconds, + "s:mode", modestr, + NULL))) + return -1; + } =20 if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) return -1; diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h index 64d9ebd..51f78f1 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -855,7 +855,8 @@ qemuMonitorJSONGetCPUMigratable(qemuMonitor *mon, =20 int qemuMonitorJSONStartDirtyRateCalc(qemuMonitor *mon, - int seconds); + int seconds, + qemuMonitorDirtyRateCalcMode mode); =20 int qemuMonitorJSONQueryDirtyRate(qemuMonitor *mon, --=20 1.8.3.1 From nobody Mon Apr 29 08:03:13 2024 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 From nobody Mon Apr 29 08:03:13 2024 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; 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 1643254636899430.07248289817164; Wed, 26 Jan 2022 19:37:16 -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-1-pNqA0_WLMMK_Y0SxH_HdCA-1; Wed, 26 Jan 2022 22:37:12 -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 CB2871083F79; Thu, 27 Jan 2022 03:37:07 +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 A87211037F55; Thu, 27 Jan 2022 03:37:07 +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 777094A708; Thu, 27 Jan 2022 03:37:07 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20R3b1Bg019970 for ; Wed, 26 Jan 2022 22:37:01 -0500 Received: by smtp.corp.redhat.com (Postfix) id 746801457F07; Thu, 27 Jan 2022 03:37:01 +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 706D31457F06 for ; Thu, 27 Jan 2022 03:37:01 +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 5646F2A8E476 for ; Thu, 27 Jan 2022 03:37:01 +0000 (UTC) Received: from chinatelecom.cn (prt-mail.chinatelecom.cn [42.123.76.222]) by relay.mimecast.com with ESMTP id us-mta-18-qenfUS6wO4e-BrZR0eJROA-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 7C5A228010D; Thu, 27 Jan 2022 11:36:40 +0800 (CST) Received: from ([172.18.0.218]) by app0025 with ESMTP id 5fe17a33e0f34fdca54fd078b475ebe9 for libvir-list@redhat.com; Thu, 27 Jan 2022 11:36:43 CST X-MC-Unique: pNqA0_WLMMK_Y0SxH_HdCA-1 X-MC-Unique: qenfUS6wO4e-BrZR0eJROA-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: 5fe17a33e0f34fdca54fd078b475ebe9 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 6/6] qemu_driver: Add calc_mode for dirtyrate statistics Date: Thu, 27 Jan 2022 11:36:22 +0800 Message-Id: <4f47f69641bd52a9eeaa1153da3dcb0e12e62eca.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.85 on 10.11.54.7 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 20R3b1Bg019970 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: 1643254644184100001 From: Hyman Huang(=E9=BB=84=E5=8B=87) Add calc_mode for dirtyrate statistics retured by virsh domstats --dirtyrate api, also add vcpu dirtyrate if dirty-ring mode was used in last measurement. Signed-off-by: Hyman Huang(=E9=BB=84=E5=8B=87) --- src/libvirt-domain.c | 5 +++++ src/qemu/qemu_driver.c | 14 ++++++++++++ src/qemu/qemu_monitor.h | 10 +++++++++ src/qemu/qemu_monitor_json.c | 52 ++++++++++++++++++++++++++++++++++++++++= ++++ 4 files changed, 81 insertions(+) diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index 4caa740..b1b6707 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -11941,6 +11941,11 @@ virConnectGetDomainCapabilities(virConnectPtr conn, * "dirtyrate.megabytes_per_second" - the calculated memory dirty rate= in * MiB/s as long long. It is produc= ed * only if the calc_status is measu= red. + * "dirtyrate.calc_mode" - the calculation mode used last measurement = as int, + * which is one of qemuMonitorDirtyRateCalcMod= e enum. + * "dirtyrate.vcpu..megabytes_per_second" - the calculated memory= dirty + * rate for a virtual cp= u as + * long long. * * Note that entire stats groups or individual stat fields may be missing = from * the output in case they are not supported by the given hypervisor, are = not diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index feebfc4..09eda6b 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -18537,6 +18537,20 @@ qemuDomainGetStatsDirtyRate(virQEMUDriver *driver, "dirtyrate.megabytes_per_second") < 0) return -1; =20 + if (virTypedParamListAddInt(params, info.mode, + "dirtyrate.calc_mode") < 0) + return -1; + + if (info.mode =3D=3D VIR_DOMAIN_DIRTYRATE_CALC_MODE_DIRTY_RING) { + int i; + for (i =3D 0; i < info.nvcpus; i++) { + if (virTypedParamListAddLLong(params, info.rates[i].value, + "dirtyrate.vcpu.%d.megabytes_per_second", + info.rates[i].index) < 0) + return -1; + } + } + return 0; } =20 diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 08e14c0..465feef 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -1563,6 +1563,12 @@ qemuMonitorStartDirtyRateCalc(qemuMonitor *mon, int seconds, qemuMonitorDirtyRateCalcMode mode); =20 +typedef struct _qemuMonitorDirtyRateVcpu qemuMonitorDirtyRateVcpu; +struct _qemuMonitorDirtyRateVcpu { + int index; /* virtual cpu index */ + long long value; /* virtual cpu dirty page rate in MB/s */ +}; + typedef struct _qemuMonitorDirtyRateInfo qemuMonitorDirtyRateInfo; struct _qemuMonitorDirtyRateInfo { int status; /* the status of last dirtyrate calculation, @@ -1570,6 +1576,10 @@ struct _qemuMonitorDirtyRateInfo { int calcTime; /* the period of dirtyrate calculation */ long long startTime; /* the start time of dirtyrate calculation */ long long dirtyRate; /* the dirtyrate in MiB/s */ + qemuMonitorDirtyRateCalcMode mode; /* calculation mode used in + last measurement */ + size_t nvcpus; /* number of virtual cpu */ + qemuMonitorDirtyRateVcpu *rates; /* array of dirty page rate */ }; =20 int diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index afbd721..391f685 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -8741,11 +8741,45 @@ VIR_ENUM_IMPL(qemuMonitorDirtyRateStatus, "measured"); =20 static int +qemuMonitorJSONExtractVcpuDirtyRate(virJSONValue *data, + qemuMonitorDirtyRateInfo *info) +{ + size_t nvcpus; + int i; + + nvcpus =3D virJSONValueArraySize(data); + info->nvcpus =3D nvcpus; + info->rates =3D g_new0(qemuMonitorDirtyRateVcpu, nvcpus); + + for (i =3D 0; i < nvcpus; i++) { + virJSONValue *entry =3D virJSONValueArrayGet(data, i); + if (virJSONValueObjectGetNumberInt(entry, "id", + &info->rates[i].index) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("query-dirty-rate reply was missing 'id' data= ")); + return -1; + } + + if (virJSONValueObjectGetNumberLong(entry, "dirty-rate", + &info->rates[i].value) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("query-dirty-rate reply was missing 'dirty-ra= te' data")); + return -1; + } + } + + return 0; +} + +static int qemuMonitorJSONExtractDirtyRateInfo(virJSONValue *data, qemuMonitorDirtyRateInfo *info) { const char *statusstr; + const char *modestr; int status; + int mode; + virJSONValue *rates =3D NULL; =20 if (!(statusstr =3D virJSONValueObjectGetString(data, "status"))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -8782,6 +8816,24 @@ qemuMonitorJSONExtractDirtyRateInfo(virJSONValue *da= ta, return -1; } =20 + info->mode =3D VIR_DOMAIN_DIRTYRATE_CALC_MODE_PAGE_SAMPLING; + if ((modestr =3D virJSONValueObjectGetString(data, "mode"))) { + if ((mode =3D qemuMonitorDirtyRateCalcModeTypeFromString(modestr))= < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unknown dirtyrate calculation mode: %s"), modest= r); + return -1; + } + info->mode =3D mode; + } + + if ((rates =3D virJSONValueObjectGetArray(data, "vcpu-dirty-rate"))) { + if (qemuMonitorJSONExtractVcpuDirtyRate(rates, info) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("query-dirty-rate parsing 'vcpu-dirty-rate' in fa= ilure")); + return -1; + } + } + return 0; } =20 --=20 1.8.3.1