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 | 3 ++- src/qemu/qemu_monitor.c | 5 +++-- src/qemu/qemu_monitor.h | 17 ++++++++++++++++- src/qemu/qemu_monitor_json.c | 16 ++++++++++++++-- src/qemu/qemu_monitor_json.h | 3 ++- 5 files changed, 37 insertions(+), 7 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 9b50f5f..db4efcd 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -20673,6 +20673,7 @@ qemuDomainStartDirtyRateCalc(virDomainPtr dom, virQEMUDriver *driver = dom->conn->privateData; virDomainObj *vm = NULL; qemuDomainObjPrivate *priv; + qemuMonitorDirtyRateCalcMode mode = QEMU_MONITOR_DIRTYRATE_CALC_MODE_PAGE_SAMPLING; int ret = -1; virCheckFlags(0, -1); @@ -20712,7 +20713,7 @@ qemuDomainStartDirtyRateCalc(virDomainPtr dom, VIR_DEBUG("Calculate dirty rate in next %d seconds", seconds); 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 dc81e41..0ff938a 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -4475,13 +4475,14 @@ qemuMonitorTransactionBackup(virJSONValue *actions, int qemuMonitorStartDirtyRateCalc(qemuMonitor *mon, - int seconds) + int seconds, + qemuMonitorDirtyRateCalcMode 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 1d21183..053479b 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -1534,9 +1534,24 @@ qemuMonitorTransactionBackup(virJSONValue *actions, const char *bitmap, qemuMonitorTransactionBackupSyncMode syncmode); +/** + * qemuMonitorDirtyRateCalcMode: + * + * Dirty page rate calculation mode used during measurement. + */ +typedef enum { + QEMU_MONITOR_DIRTYRATE_CALC_MODE_PAGE_SAMPLING = 0, + QEMU_MONITOR_DIRTYRATE_CALC_MODE_DIRTY_BITMAP, + QEMU_MONITOR_DIRTYRATE_CALC_MODE_DIRTY_RING, + QEMU_MONITOR_DIRTYRATE_CALC_MODE_LAST, +} qemuMonitorDirtyRateCalcMode; + +VIR_ENUM_DECL(qemuMonitorDirtyRateCalcMode); + int qemuMonitorStartDirtyRateCalc(qemuMonitor *mon, - int seconds); + int seconds, + qemuMonitorDirtyRateCalcMode mode); typedef struct _qemuMonitorDirtyRateInfo qemuMonitorDirtyRateInfo; struct _qemuMonitorDirtyRateInfo { diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 1de932f..da9a4d9 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -8740,18 +8740,30 @@ qemuMonitorJSONGetCPUMigratable(qemuMonitor *mon, migratable); } +VIR_ENUM_IMPL(qemuMonitorDirtyRateCalcMode, + QEMU_MONITOR_DIRTYRATE_CALC_MODE_LAST, + "page-sampling", + "dirty-bitmap", + "dirty-ring"); int qemuMonitorJSONStartDirtyRateCalc(qemuMonitor *mon, - int seconds) + int seconds, + qemuMonitorDirtyRateCalcMode mode) { g_autoptr(virJSONValue) cmd = NULL; g_autoptr(virJSONValue) reply = NULL; + const char *modestr = NULL; + + if (mode != QEMU_MONITOR_DIRTYRATE_CALC_MODE_PAGE_SAMPLING) + modestr = qemuMonitorDirtyRateCalcModeTypeToString(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 eea3478..8e34f3b 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -853,7 +853,8 @@ qemuMonitorJSONGetCPUMigratable(qemuMonitor *mon, int qemuMonitorJSONStartDirtyRateCalc(qemuMonitor *mon, - int seconds); + int seconds, + qemuMonitorDirtyRateCalcMode mode); int qemuMonitorJSONQueryDirtyRate(qemuMonitor *mon, -- 1.8.3.1