Introduce virDomainStartDirtyRateCalc API for start calculation of
a domain's memory dirty rate with a specified time.
Signed-off-by: Hao Wang <wanghao232(a)huawei.com>
---
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-domain.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);
+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);
+typedef int
+(*virDrvDomainStartDirtyRateCalc)(virDomainPtr domain,
+ int seconds,
+ unsigned int flags);
+
typedef struct _virHypervisorDriver virHypervisorDriver;
typedef virHypervisorDriver *virHypervisorDriverPtr;
@@ -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 e54d11e513..91001fc4ed 100644
--- a/src/libvirt-domain.c
+++ b/src/libvirt-domain.c
@@ -13158,3 +13158,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 information 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=%d, flags=0x%x", seconds, flags);
+
+ virResetLastError();
+
+ virCheckDomainReturn(domain, -1);
+ conn = domain->conn;
+
+ virCheckReadOnlyGoto(conn->flags, error);
+
+ if (conn->driver->domainStartDirtyRateCalc) {
+ int ret;
+ ret = conn->driver->domainStartDirtyRateCalc(domain, seconds, flags);
+ 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;
+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 31868269b1..494f4b6dc5 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -8571,6 +8571,7 @@ static virHypervisorDriver hypervisor_driver = {
.domainAuthorizedSSHKeysGet = remoteDomainAuthorizedSSHKeysGet, /* 6.10.0 */
.domainAuthorizedSSHKeysSet = remoteDomainAuthorizedSSHKeysSet, /* 6.10.0 */
.domainGetMessages = remoteDomainGetMessages, /* 7.1.0 */
+ .domainStartDirtyRateCalc = remoteDomainStartDirtyRateCalc, /* 7.2.0 */
};
static virNetworkDriver network_driver = {
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<REMOTE_DOMAIN_MESSAGES_MAX>;
};
+struct remote_domain_start_dirty_rate_calc_args {
+ remote_nonnull_domain dom;
+ int seconds;
+ unsigned int flags;
+};
+
/*----- Protocol. -----*/
@@ -6733,5 +6739,11 @@ enum remote_procedure {
* @generate: none
* @acl: domain:read
*/
- REMOTE_PROC_DOMAIN_GET_MESSAGES = 426
+ REMOTE_PROC_DOMAIN_GET_MESSAGES = 426,
+
+ /**
+ * @generate: both
+ * @acl: domain:read
+ */
+ REMOTE_PROC_DOMAIN_START_DIRTY_RATE_CALC = 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 = 1,
REMOTE_PROC_CONNECT_CLOSE = 2,
@@ -3599,4 +3604,5 @@ enum remote_procedure {
REMOTE_PROC_DOMAIN_AUTHORIZED_SSH_KEYS_GET = 424,
REMOTE_PROC_DOMAIN_AUTHORIZED_SSH_KEYS_SET = 425,
REMOTE_PROC_DOMAIN_GET_MESSAGES = 426,
+ REMOTE_PROC_DOMAIN_START_DIRTY_RATE_CALC = 427,
};
--
2.23.0