From: Hyman Huang(黄勇) <huangy81(a)chinatelecom.cn>
For any virTypedParameter API normal practice is to use a string
to expose the data, not the rather enum integer value.
So let's drop the virDomainDirtyRateStatus in public header file
and introduce internal enum def qemuMonitorDirtyRateStatus to
describe the dirty page rate calculation status.
Signed-off-by: Hyman Huang(黄勇) <huangy81(a)chinatelecom.cn>
---
include/libvirt/libvirt-domain.h | 18 ------------------
src/libvirt-domain.c | 4 ++--
src/qemu/qemu_driver.c | 9 ++++++---
src/qemu/qemu_monitor.h | 18 ++++++++++++++++--
src/qemu/qemu_monitor_json.c | 4 ++--
5 files changed, 26 insertions(+), 27 deletions(-)
diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h
index 8c16598..bf4746a 100644
--- a/include/libvirt/libvirt-domain.h
+++ b/include/libvirt/libvirt-domain.h
@@ -5241,24 +5241,6 @@ int virDomainGetMessages(virDomainPtr domain,
char ***msgs,
unsigned int flags);
-/**
- * virDomainDirtyRateStatus:
- *
- * Details on the cause of a dirty rate calculation status.
- */
-typedef enum {
- VIR_DOMAIN_DIRTYRATE_UNSTARTED = 0, /* the dirtyrate calculation has
- not been started */
- VIR_DOMAIN_DIRTYRATE_MEASURING = 1, /* the dirtyrate calculation is
- measuring */
- VIR_DOMAIN_DIRTYRATE_MEASURED = 2, /* the dirtyrate calculation is
- completed */
-
-# ifdef VIR_ENUM_SENTINELS
- VIR_DOMAIN_DIRTYRATE_LAST
-# endif
-} virDomainDirtyRateStatus;
-
int virDomainStartDirtyRateCalc(virDomainPtr domain,
int seconds,
unsigned int flags);
diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c
index b8a6f10..f24d072 100644
--- a/src/libvirt-domain.c
+++ b/src/libvirt-domain.c
@@ -11947,8 +11947,8 @@ virConnectGetDomainCapabilities(virConnectPtr conn,
* this format:
*
* "dirtyrate.calc_status" - the status of last memory dirty rate
calculation,
- * returned as int from virDomainDirtyRateStatus
- * enum.
+ * either of these 3
'unstarted,measuring,measured'
+ * values returned.
* "dirtyrate.calc_start_time" - the start time of last memory dirty rate
* calculation as long long.
* "dirtyrate.calc_period" - the period of last memory dirty rate
calculation
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index f262020..a22646c 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -18525,6 +18525,8 @@ qemuDomainGetStatsDirtyRateMon(virQEMUDriver *driver,
return ret;
}
+VIR_ENUM_DECL(qemuMonitorDirtyRateStatus);
+
static int
qemuDomainGetStatsDirtyRate(virQEMUDriver *driver,
virDomainObj *dom,
@@ -18539,8 +18541,9 @@ qemuDomainGetStatsDirtyRate(virQEMUDriver *driver,
if (qemuDomainGetStatsDirtyRateMon(driver, dom, &info) < 0)
return -1;
- if (virTypedParamListAddInt(params, info.status,
- "dirtyrate.calc_status") < 0)
+ if (virTypedParamListAddString(params,
+ qemuMonitorDirtyRateStatusTypeToString(info.status),
+ "dirtyrate.calc_status") < 0)
return -1;
if (virTypedParamListAddLLong(params, info.startTime,
@@ -18551,7 +18554,7 @@ qemuDomainGetStatsDirtyRate(virQEMUDriver *driver,
"dirtyrate.calc_period") < 0)
return -1;
- if ((info.status == VIR_DOMAIN_DIRTYRATE_MEASURED) &&
+ if ((info.status == QEMU_MONITOR_DIRTYRATE_STATUS_MEASURED) &&
virTypedParamListAddLLong(params, info.dirtyRate,
"dirtyrate.megabytes_per_second") < 0)
return -1;
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index 1d21183..817391c 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -1538,10 +1538,24 @@ int
qemuMonitorStartDirtyRateCalc(qemuMonitor *mon,
int seconds);
+/**
+ * qemuMonitorDirtyRateStatus:
+ *
+ * Details on the cause of a dirty page rate calculation status.
+ */
+typedef enum {
+ QEMU_MONITOR_DIRTYRATE_STATUS_UNSTARTED = 0, /* the dirtyrate calculation has
+ not been started */
+ QEMU_MONITOR_DIRTYRATE_STATUS_MEASURING, /* the dirtyrate calculation is
+ measuring */
+ QEMU_MONITOR_DIRTYRATE_STATUS_MEASURED, /* the dirtyrate calculation is
+ completed */
+ QEMU_MONITOR_DIRTYRATE_STATUS_LAST,
+} qemuMonitorDirtyRateStatus;
+
typedef struct _qemuMonitorDirtyRateInfo qemuMonitorDirtyRateInfo;
struct _qemuMonitorDirtyRateInfo {
- int status; /* the status of last dirtyrate calculation,
- one of virDomainDirtyRateStatus */
+ qemuMonitorDirtyRateStatus status; /* the status of last dirtyrate calculation */
int calcTime; /* the period of dirtyrate calculation */
long long startTime; /* the start time of dirtyrate calculation */
long long dirtyRate; /* the dirtyrate in MiB/s */
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 1de932f..b09ef12 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -8764,7 +8764,7 @@ qemuMonitorJSONStartDirtyRateCalc(qemuMonitor *mon,
VIR_ENUM_DECL(qemuMonitorDirtyRateStatus);
VIR_ENUM_IMPL(qemuMonitorDirtyRateStatus,
- VIR_DOMAIN_DIRTYRATE_LAST,
+ QEMU_MONITOR_DIRTYRATE_STATUS_LAST,
"unstarted",
"measuring",
"measured");
@@ -8792,7 +8792,7 @@ qemuMonitorJSONExtractDirtyRateInfo(virJSONValue *data,
/* `query-dirty-rate` replies `dirty-rate` data only if the status of the latest
* calculation is `measured`.
*/
- if ((info->status == VIR_DOMAIN_DIRTYRATE_MEASURED) &&
+ if ((info->status == QEMU_MONITOR_DIRTYRATE_STATUS_MEASURED) &&
(virJSONValueObjectGetNumberLong(data, "dirty-rate",
&info->dirtyRate) < 0)) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("query-dirty-rate reply was missing 'dirty-rate'
data"));
--
1.8.3.1