[PATCH v3 5/7] qemu_driver: Add mode parameter to qemuDomainStartDirtyRateCalc

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Hyman Huang(黄勇) <huangy81@xxxxxxxxxxxxxxx>

Add mode parameter to qemuDomainStartDirtyRateCalc API, 'mode'
option of 'calc-dirty-rate' command was introduced since
qemu >= 6.2.

Signed-off-by: Hyman Huang(黄勇) <huangy81@xxxxxxxxxxxxxxx>
---
 src/qemu/qemu_driver.c       |  4 +++-
 src/qemu/qemu_monitor.c      |  5 +++--
 src/qemu/qemu_monitor.h      |  3 ++-
 src/qemu/qemu_monitor_json.c | 17 +++++++++++++++--
 src/qemu/qemu_monitor_json.h |  3 ++-
 5 files changed, 25 insertions(+), 7 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index c8ee897..cb2af61 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -20647,6 +20647,8 @@ qemuDomainStartDirtyRateCalc(virDomainPtr dom,
     virQEMUDriver *driver = dom->conn->privateData;
     virDomainObj *vm = NULL;
     qemuDomainObjPrivate *priv;
+    virDomainDirtyRateCalcMode mode =
+        VIR_DOMAIN_DIRTYRATE_CALC_MODE_PAGE_SAMPLING;
     int ret = -1;
 
     virCheckFlags(0, -1);
@@ -20686,7 +20688,7 @@ qemuDomainStartDirtyRateCalc(virDomainPtr dom,
     }
 
     qemuDomainObjEnterMonitor(driver, vm);
-    ret = qemuMonitorStartDirtyRateCalc(priv->mon, seconds);
+    ret = qemuMonitorStartDirtyRateCalc(priv->mon, seconds, mode);
 
     qemuDomainObjExitMonitor(driver, vm);
 
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index babf9e6..e97fe4e 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -4532,13 +4532,14 @@ qemuMonitorTransactionBackup(virJSONValue *actions,
 
 int
 qemuMonitorStartDirtyRateCalc(qemuMonitor *mon,
-                              int seconds)
+                              int seconds,
+                              virDomainDirtyRateCalcMode mode)
 {
     VIR_DEBUG("seconds=%d", seconds);
 
     QEMU_CHECK_MONITOR(mon);
 
-    return qemuMonitorJSONStartDirtyRateCalc(mon, seconds);
+    return qemuMonitorJSONStartDirtyRateCalc(mon, seconds, mode);
 }
 
 
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index 9b2e4e1..6d43f23 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -1553,7 +1553,8 @@ qemuMonitorTransactionBackup(virJSONValue *actions,
 
 int
 qemuMonitorStartDirtyRateCalc(qemuMonitor *mon,
-                              int seconds);
+                              int seconds,
+                              virDomainDirtyRateCalcMode mode);
 
 typedef struct _qemuMonitorDirtyRateInfo qemuMonitorDirtyRateInfo;
 struct _qemuMonitorDirtyRateInfo {
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index b0b5136..8d62ca7 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -8695,18 +8695,31 @@ qemuMonitorJSONGetCPUMigratable(qemuMonitor *mon,
                                   migratable);
 }
 
+VIR_ENUM_DECL(virDomainDirtyRateCalcMode);
+VIR_ENUM_IMPL(virDomainDirtyRateCalcMode,
+              VIR_DOMAIN_DIRTYRATE_CALC_MODE_LAST,
+              "page-sampling",
+              "dirty-bitmap",
+              "dirty-ring");
 
 int
 qemuMonitorJSONStartDirtyRateCalc(qemuMonitor *mon,
-                                  int seconds)
+                                  int seconds,
+                                  virDomainDirtyRateCalcMode mode)
 {
     g_autoptr(virJSONValue) cmd = NULL;
     g_autoptr(virJSONValue) reply = NULL;
+    const char *modestr = NULL;
+
+    if (mode != VIR_DOMAIN_DIRTYRATE_CALC_MODE_PAGE_SAMPLING)
+       modestr = virDomainDirtyRateCalcModeTypeToString(mode);
 
     if (!(cmd = qemuMonitorJSONMakeCommand("calc-dirty-rate",
                                            "i:calc-time", seconds,
-                                           NULL)))
+                                           "S:mode", modestr,
+                                           NULL))) {
         return -1;
+    }
 
     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..2056a03 100644
--- a/src/qemu/qemu_monitor_json.h
+++ b/src/qemu/qemu_monitor_json.h
@@ -855,7 +855,8 @@ qemuMonitorJSONGetCPUMigratable(qemuMonitor *mon,
 
 int
 qemuMonitorJSONStartDirtyRateCalc(qemuMonitor *mon,
-                                  int seconds);
+                                  int seconds,
+                                  virDomainDirtyRateCalcMode mode);
 
 int
 qemuMonitorJSONQueryDirtyRate(qemuMonitor *mon,
-- 
1.8.3.1





[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux