From nobody Mon Feb 9 19:05:35 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1614328552; cv=none; d=zohomail.com; s=zohoarc; b=hJwfoUzC+KQc6eIKjQtjaQxT0RPy2rsCeTJt7vUiauWXM0HKNrbdjtERGu0Gdxp4hdzEV2jPrnJSosLV7lCsrhF4KDGnueH7zjkl757WRn6x3dQNRyfSy6c+NezZDViyAkAriVw8ilfGedGLNAIVpXo0CuaaM00gm2z8XJpWQSc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614328552; 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=2zgI3xKaoIBs7r15VVBZwnB6X8ftpQBE639tYbnEVGU=; b=G/wUYrfpFRKzfDy+pI131LBElSyNN1FUoqu24NnZMsEMtlwB/mQPrzHIk5dJhTn2GoaEDcxI2KVkVl+VVoLOR2m8JHs/73FQdUejTEX5q0Tndr61gqKIOXoEJdeIqzi7uyhKhDj/+YiZooFK0QLNFjzeC7uoRew4I71uJPY11hc= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.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 [63.128.21.124]) by mx.zohomail.com with SMTPS id 1614328552583957.1559244914891; Fri, 26 Feb 2021 00:35:52 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-292-W7mNVuc_O_qScQb3HdTR2g-1; Fri, 26 Feb 2021 03:35:48 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7033C803F4C; Fri, 26 Feb 2021 08:35:43 +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 81A857086C; Fri, 26 Feb 2021 08:35:42 +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 8EAAC18095CD; Fri, 26 Feb 2021 08:35:41 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 11Q8ZUj1002112 for ; Fri, 26 Feb 2021 03:35:31 -0500 Received: by smtp.corp.redhat.com (Postfix) id BBD35141953; Fri, 26 Feb 2021 08:35:30 +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 B35909D47B for ; Fri, 26 Feb 2021 08:35:28 +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-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8135A8007D9 for ; Fri, 26 Feb 2021 08:35:28 +0000 (UTC) Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-586-WbNuRendPryTkshEfoHhIQ-1; Fri, 26 Feb 2021 03:35:25 -0500 Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4Dn2xL4xc7zjSbZ; Fri, 26 Feb 2021 16:33:42 +0800 (CST) Received: from huawei.com (10.175.104.175) by DGGEMS403-HUB.china.huawei.com (10.3.19.203) with Microsoft SMTP Server id 14.3.498.0; Fri, 26 Feb 2021 16:35:12 +0800 X-MC-Unique: W7mNVuc_O_qScQb3HdTR2g-1 X-MC-Unique: WbNuRendPryTkshEfoHhIQ-1 From: Hao Wang To: Subject: [PATCH v6 1/5] migration/dirtyrate: Introduce virDomainStartDirtyRateCalc API Date: Fri, 26 Feb 2021 16:35:06 +0800 Message-ID: <20210226083510.1506318-2-wanghao232@huawei.com> In-Reply-To: <20210226083510.1506318-1-wanghao232@huawei.com> References: <20210226083510.1506318-1-wanghao232@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.104.175] X-CFilter-Loop: Reflected 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.79 on 10.11.54.5 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 11Q8ZUj1002112 X-loop: libvir-list@redhat.com Cc: yubihong@huawei.com, zhengchuan@huawei.com, pkrempa@redhat.com, zhang.zhanghailiang@huawei.com, mprivozn@redhat.com, danielhb413@gmail.com, xiexiangyou@huawei.com, alex.chen@huawei.com, wanghao232@huawei.com 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.13 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-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Introduce virDomainStartDirtyRateCalc API for start calculation of a domain's memory dirty rate with a specified time. Signed-off-by: Hao Wang --- include/libvirt/libvirt-domain.h | 4 +++ src/driver-hypervisor.h | 6 +++++ src/libvirt-domain.c | 44 ++++++++++++++++++++++++++++++++ src/libvirt_public.syms | 5 ++++ src/remote/remote_driver.c | 1 + src/remote/remote_protocol.x | 14 +++++++++- src/remote_protocol-structs | 6 +++++ 7 files changed, 79 insertions(+), 1 deletion(-) diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-dom= ain.h index 8011cf9fe1..7aa5ef4543 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -5128,4 +5128,8 @@ int virDomainGetMessages(virDomainPtr domain, char ***msgs, unsigned int flags); =20 +int virDomainStartDirtyRateCalc(virDomainPtr domain, + int seconds, + unsigned int flags); + #endif /* LIBVIRT_DOMAIN_H */ diff --git a/src/driver-hypervisor.h b/src/driver-hypervisor.h index 05d7dfb5c7..2ec7b8b24a 100644 --- a/src/driver-hypervisor.h +++ b/src/driver-hypervisor.h @@ -1405,6 +1405,11 @@ typedef int char ***msgs, unsigned int flags); =20 +typedef int +(*virDrvDomainStartDirtyRateCalc)(virDomainPtr domain, + int seconds, + unsigned int flags); + typedef struct _virHypervisorDriver virHypervisorDriver; typedef virHypervisorDriver *virHypervisorDriverPtr; =20 @@ -1671,4 +1676,5 @@ struct _virHypervisorDriver { virDrvDomainAuthorizedSSHKeysGet domainAuthorizedSSHKeysGet; virDrvDomainAuthorizedSSHKeysSet domainAuthorizedSSHKeysSet; virDrvDomainGetMessages domainGetMessages; + virDrvDomainStartDirtyRateCalc domainStartDirtyRateCalc; }; diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index 4af0166872..b1cc2ebbf3 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -13154,3 +13154,47 @@ virDomainGetMessages(virDomainPtr domain, virDispatchError(conn); return -1; } + + +/** + * virDomainStartDirtyRateCalc: + * @domain: a domain object + * @seconds: specified calculating time in seconds + * @flags: extra flags; not used yet, so callers should always pass 0 + * + * Calculate the current domain's memory dirty rate in next @seconds. + * The calculated dirty rate infomation is available by calling + * virConnectGetAllDomainStats. + * + * Returns 0 in case of success, -1 otherwise. + */ +int +virDomainStartDirtyRateCalc(virDomainPtr domain, + int seconds, + unsigned int flags) +{ + virConnectPtr conn; + + VIR_DOMAIN_DEBUG(domain, "seconds=3D%d, flags=3D0x%x", seconds, flags); + + virResetLastError(); + + virCheckDomainReturn(domain, -1); + conn =3D domain->conn; + + virCheckReadOnlyGoto(conn->flags, error); + + if (conn->driver->domainStartDirtyRateCalc) { + int ret; + ret =3D conn->driver->domainStartDirtyRateCalc(domain, seconds, fl= ags); + if (ret < 0) + goto error; + return ret; + } + + virReportUnsupportedError(); + + error: + virDispatchError(conn); + return -1; +} diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms index d851333eb0..51a3d7265a 100644 --- a/src/libvirt_public.syms +++ b/src/libvirt_public.syms @@ -884,4 +884,9 @@ LIBVIRT_7.1.0 { virDomainGetMessages; } LIBVIRT_6.10.0; =20 +LIBVIRT_7.2.0 { + global: + virDomainStartDirtyRateCalc; +} LIBVIRT_7.1.0; + # .... define new API here using predicted next version number .... diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index a83cd866e7..3968472931 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -8575,6 +8575,7 @@ static virHypervisorDriver hypervisor_driver =3D { .domainAuthorizedSSHKeysGet =3D remoteDomainAuthorizedSSHKeysGet, /* 6= .10.0 */ .domainAuthorizedSSHKeysSet =3D remoteDomainAuthorizedSSHKeysSet, /* 6= .10.0 */ .domainGetMessages =3D remoteDomainGetMessages, /* 7.1.0 */ + .domainStartDirtyRateCalc =3D remoteDomainStartDirtyRateCalc, /* 7.2.0= */ }; =20 static virNetworkDriver network_driver =3D { diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x index d3724bc305..7fdc65f029 100644 --- a/src/remote/remote_protocol.x +++ b/src/remote/remote_protocol.x @@ -3811,6 +3811,12 @@ struct remote_domain_get_messages_ret { remote_nonnull_string msgs; }; =20 +struct remote_domain_start_dirty_rate_calc_args { + remote_nonnull_domain dom; + int seconds; + unsigned int flags; +}; + =20 /*----- Protocol. -----*/ =20 @@ -6733,5 +6739,11 @@ enum remote_procedure { * @generate: none * @acl: domain:read */ - REMOTE_PROC_DOMAIN_GET_MESSAGES =3D 426 + REMOTE_PROC_DOMAIN_GET_MESSAGES =3D 426, + + /** + * @generate: both + * @acl: domain:read + */ + REMOTE_PROC_DOMAIN_START_DIRTY_RATE_CALC =3D 427 }; diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs index c0c034ac6a..d13dc81a82 100644 --- a/src/remote_protocol-structs +++ b/src/remote_protocol-structs @@ -3172,6 +3172,11 @@ struct remote_domain_get_messages_ret { remote_nonnull_string * msgs_val; } msgs; }; +struct remote_domain_start_dirty_rate_calc_args { + remote_nonnull_domain dom; + int seconds; + u_int flags; +}; enum remote_procedure { REMOTE_PROC_CONNECT_OPEN =3D 1, REMOTE_PROC_CONNECT_CLOSE =3D 2, @@ -3599,4 +3604,5 @@ enum remote_procedure { REMOTE_PROC_DOMAIN_AUTHORIZED_SSH_KEYS_GET =3D 424, REMOTE_PROC_DOMAIN_AUTHORIZED_SSH_KEYS_SET =3D 425, REMOTE_PROC_DOMAIN_GET_MESSAGES =3D 426, + REMOTE_PROC_DOMAIN_START_DIRTY_RATE_CALC =3D 427, }; --=20 2.23.0