[PATCH v3 3/4] vz: add vcpu statistics

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

 



From: Nikolay Shirokovskiy <nshirokovskiy@xxxxxxxxxxxxx>

Comments.

Replace vzDomObjFromDomain/virObjectUnlock pair
to vzDomObjFromDomainRef/virDomainObjEndAPI as we
use prlsdkGetStatsParam. See previous statistics
comments.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@xxxxxxxxxxxxx>
---
 src/vz/vz_driver.c |    6 ++++--
 src/vz/vz_sdk.c    |   19 +++++++++++++++++++
 src/vz/vz_sdk.h    |    2 ++
 3 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c
index 5c503c6..d11ce18 100644
--- a/src/vz/vz_driver.c
+++ b/src/vz/vz_driver.c
@@ -826,7 +826,7 @@ vzDomainGetVcpus(virDomainPtr domain,
     int v, maxcpu, hostcpus;
     int ret = -1;
 
-    if (!(privdom = vzDomObjFromDomain(domain)))
+    if (!(privdom = vzDomObjFromDomainRef(domain)))
         goto cleanup;
 
     if (!virDomainObjIsActive(privdom)) {
@@ -849,6 +849,8 @@ vzDomainGetVcpus(virDomainPtr domain,
             for (i = 0; i < maxinfo; i++) {
                 info[i].number = i;
                 info[i].state = VIR_VCPU_RUNNING;
+                if (prlsdkGetVcpuStats(privdom, i, &info[i].cpuTime) < 0)
+                    goto cleanup;
             }
         }
         if (cpumaps != NULL) {
@@ -871,7 +873,7 @@ vzDomainGetVcpus(virDomainPtr domain,
 
  cleanup:
     if (privdom)
-        virObjectUnlock(privdom);
+        virDomainObjEndAPI(&privdom);
     return ret;
 }
 
diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c
index 26f000f..aeeada3 100644
--- a/src/vz/vz_sdk.c
+++ b/src/vz/vz_sdk.c
@@ -3863,3 +3863,22 @@ prlsdkGetNetStats(virDomainObjPtr dom, const char *path,
 
     return ret;
 }
+
+int
+prlsdkGetVcpuStats(virDomainObjPtr dom, int idx, unsigned long long *vtime)
+{
+    char *name = NULL;
+    long long ptime = 0;
+    int ret = -1;
+
+    if (virAsprintf(&name, "guest.vcpu%u.time", (unsigned int)idx) < 0)
+        goto cleanup;
+    if (prlsdkGetStatsParam(dom, name, &ptime) < 0)
+        goto cleanup;
+    *vtime = ptime == -1 ? 0 : ptime;
+    ret = 0;
+
+ cleanup:
+    VIR_FREE(name);
+    return ret;
+}
diff --git a/src/vz/vz_sdk.h b/src/vz/vz_sdk.h
index 53fe21f..ca38c59 100644
--- a/src/vz/vz_sdk.h
+++ b/src/vz/vz_sdk.h
@@ -72,3 +72,5 @@ int
 prlsdkDetachNet(virDomainObjPtr dom, vzConnPtr privconn, virDomainNetDefPtr net);
 int
 prlsdkGetNetStats(virDomainObjPtr dom, const char *path, virDomainInterfaceStatsPtr stats);
+int
+prlsdkGetVcpuStats(virDomainObjPtr dom, int idx, unsigned long long *time);
-- 
1.7.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[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]