From c4c665b4654280560eafe5782359b71e8ef2b1b5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Hyman=20Huang=28=E9=BB=84=E5=8B=87=29?=
 <huangy81@chinatelecom.cn>
Date: Sun, 20 Feb 2022 21:28:11 +0800
Subject: [PATCH 6/7] include: Introduce virDomainDirtyRateCalcFlags
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Introduce virDomainDirtyRateCalcFlags to get ready for
adding mode parameter to qemuDomainStartDirtyRateCalc.

Signed-off-by: Hyman Huang(黄勇) <huangy81@chinatelecom.cn>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
---
 include/libvirt/libvirt-domain.h | 13 +++++++++++++
 src/libvirt-domain.c             | 12 +++++++++++-
 2 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h
index e1954ae663..c7956c81d6 100644
--- a/include/libvirt/libvirt-domain.h
+++ b/include/libvirt/libvirt-domain.h
@@ -5030,6 +5030,19 @@ typedef enum {
 # endif
 } virDomainDirtyRateStatus;
 
+/**
+ * virDomainDirtyRateCalcFlags:
+ *
+ * Flags OR'ed together to provide specific behaviour when calculating dirty page
+ * rate for a Domain
+ *
+ */
+typedef enum {
+    VIR_DOMAIN_DIRTYRATE_MODE_PAGE_SAMPLING = 0,        /* default mode - page-sampling */
+    VIR_DOMAIN_DIRTYRATE_MODE_DIRTY_BITMAP = 1 << 0,    /* dirty-bitmap mode */
+    VIR_DOMAIN_DIRTYRATE_MODE_DIRTY_RING = 1 << 1,      /* dirty-ring mode */
+} virDomainDirtyRateCalcFlags;
+
 int virDomainStartDirtyRateCalc(virDomainPtr domain,
                                 int seconds,
                                 unsigned int flags);
diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c
index 6a37ea85b7..0ff99c94b6 100644
--- a/src/libvirt-domain.c
+++ b/src/libvirt-domain.c
@@ -12821,7 +12821,7 @@ virDomainHotpatchManage(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
@@ -12845,6 +12845,16 @@ virDomainStartDirtyRateCalc(virDomainPtr domain,
 
     virCheckReadOnlyGoto(conn->flags, error);
 
+    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 = conn->driver->domainStartDirtyRateCalc(domain, seconds, flags);
-- 
2.27.0

