[PATCH Libvirt v2 09/10] qemu_driver: Extend dirtlimit statistics for domGetStats

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

 



From: Hyman Huang(黄勇) <yong.huang@xxxxxxxxxx>

Extend dirtylimit statistics for domGetStats to display the
information of the upper limit of dirty page rate for
virtual CPUs.

Signed-off-by: Hyman Huang(黄勇) <yong.huang@xxxxxxxxxx>
---
 include/libvirt/libvirt-domain.h |  1 +
 src/libvirt-domain.c             |  9 ++++++
 src/qemu/qemu_driver.c           | 50 ++++++++++++++++++++++++++++++++
 3 files changed, 60 insertions(+)

diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h
index 3d3c7cdcba..14fc5ff82e 100644
--- a/include/libvirt/libvirt-domain.h
+++ b/include/libvirt/libvirt-domain.h
@@ -2739,6 +2739,7 @@ typedef enum {
     VIR_DOMAIN_STATS_MEMORY = (1 << 8), /* return domain memory info (Since: 6.0.0) */
     VIR_DOMAIN_STATS_DIRTYRATE = (1 << 9), /* return domain dirty rate info (Since: 7.2.0) */
     VIR_DOMAIN_STATS_VM = (1 << 10), /* return vm info (Since: 8.9.0) */
+    VIR_DOMAIN_STATS_DIRTYLIMIT = (1 << 11), /* return domain dirty limit info (Since: 9.6.0) */
 } virDomainStatsTypes;
 
 /**
diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c
index 9a60ac7f67..9117881703 100644
--- a/src/libvirt-domain.c
+++ b/src/libvirt-domain.c
@@ -12531,6 +12531,15 @@ virConnectGetDomainCapabilities(virConnectPtr conn,
  *      naming or meaning will stay consistent. Changes to existing fields,
  *      however, are expected to be rare.
  *
+ * VIR_DOMAIN_STATS_DIRTYLIMIT:
+ *     Return virtual CPU dirty limit information. The typed parameter keys are in
+ *     this format:
+ *
+ *     "dirtylimit.vcpu.<num>.limit" - The dirty page rate upper limit for the
+ *                                     virtual CPU, in MB/s.
+ *     "dirtylimit.vcpu.<num>.current" - The dirty page rate for the virtual CPU
+ *                                       currently, in MB/s.
+ *
  * Note that entire stats groups or individual stat fields may be missing from
  * the output in case they are not supported by the given hypervisor, are not
  * applicable for the current state of the guest domain, or their retrieval
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 9779cd0579..cbeab252a4 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -17679,6 +17679,50 @@ qemuDomainGetStatsVm(virQEMUDriver *driver G_GNUC_UNUSED,
     return 0;
 }
 
+
+static int
+qemuDomainGetStatsDirtyLimitMon(virDomainObj *vm,
+                                qemuMonitorVcpuDirtyLimitInfo *info)
+{
+    qemuDomainObjPrivate *priv = vm->privateData;
+    int ret;
+
+    qemuDomainObjEnterMonitor(vm);
+    ret = qemuMonitorQueryVcpuDirtyLimit(priv->mon, info);
+    qemuDomainObjExitMonitor(vm);
+
+    return ret;
+}
+
+
+static int
+qemuDomainGetStatsDirtyLimit(virQEMUDriver *driver G_GNUC_UNUSED,
+                             virDomainObj *dom,
+                             virTypedParamList *params,
+                             unsigned int privflags)
+{
+    qemuMonitorVcpuDirtyLimitInfo info;
+    size_t i;
+
+    if (!HAVE_JOB(privflags) || !virDomainObjIsActive(dom))
+        return 0;
+
+    if (qemuDomainGetStatsDirtyLimitMon(dom, &info) < 0)
+        return -1;
+
+    for (i = 0; i < info.nvcpus; i++) {
+        virTypedParamListAddULLong(params, info.limits[i].limit,
+                                   "dirtylimit.vcpu.%d.limit",
+                                   info.limits[i].idx);
+        virTypedParamListAddULLong(params, info.limits[i].current,
+                                   "dirtylimit.vcpu.%d.current",
+                                   info.limits[i].idx);
+    }
+
+    return 0;
+}
+
+
 typedef int
 (*qemuDomainGetStatsFunc)(virQEMUDriver *driver,
                           virDomainObj *dom,
@@ -17703,6 +17747,11 @@ static virQEMUCapsFlags queryVmRequired[] = {
     QEMU_CAPS_LAST
 };
 
+static virQEMUCapsFlags queryDirtyLimitRequired[] = {
+    QEMU_CAPS_VCPU_DIRTY_LIMIT,
+    QEMU_CAPS_LAST
+};
+
 static struct qemuDomainGetStatsWorker qemuDomainGetStatsWorkers[] = {
     { qemuDomainGetStatsState, VIR_DOMAIN_STATS_STATE, false, NULL },
     { qemuDomainGetStatsCpu, VIR_DOMAIN_STATS_CPU_TOTAL, true, NULL },
@@ -17715,6 +17764,7 @@ static struct qemuDomainGetStatsWorker qemuDomainGetStatsWorkers[] = {
     { qemuDomainGetStatsMemory, VIR_DOMAIN_STATS_MEMORY, false, NULL },
     { qemuDomainGetStatsDirtyRate, VIR_DOMAIN_STATS_DIRTYRATE, true, queryDirtyRateRequired },
     { qemuDomainGetStatsVm, VIR_DOMAIN_STATS_VM, true, queryVmRequired },
+    { qemuDomainGetStatsDirtyLimit, VIR_DOMAIN_STATS_DIRTYLIMIT, true, queryDirtyLimitRequired },
     { NULL, 0, false, NULL }
 };
 
-- 
2.38.5





[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