Re: [PATCH v2 2/3] vz: add vcpu statistics

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

 



On 06/18/2015 12:28 PM, Nikolay Shirokovskiy wrote:
From: Nikolay Shirokovskiy <nshirokovskiy@xxxxxxxxxxxxx>

Comments.

Replace vzDomObjFromDomain/virObjectUnlock pair
to vzDomObjFromDomainRef/virDomainObjEndAPI as we
use prlsdkGetStatsParam. See previous statistics
comments.
Looks good to me, ACK.


Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@xxxxxxxxxxxxx>
---
  src/vz/vz_driver.c |   16 ++++++++++++++--
  1 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c
index deac572..4197569 100644
--- a/src/vz/vz_driver.c
+++ b/src/vz/vz_driver.c
@@ -825,8 +825,9 @@ vzDomainGetVcpus(virDomainPtr domain,
      size_t i;
      int v, maxcpu, hostcpus;
      int ret = -1;
+    char *name = NULL;
- if (!(privdom = vzDomObjFromDomain(domain)))
+    if (!(privdom = vzDomObjFromDomainRef(domain)))
          goto cleanup;
if (!virDomainObjIsActive(privdom)) {
@@ -847,8 +848,18 @@ vzDomainGetVcpus(virDomainPtr domain,
          if (info != NULL) {
              memset(info, 0, sizeof(*info) * maxinfo);
              for (i = 0; i < maxinfo; i++) {
+                long long vcpuTime = 0;
+
                  info[i].number = i;
                  info[i].state = VIR_VCPU_RUNNING;
+
+                if (virAsprintf(&name, "guest.vcpu%u.time", (unsigned int)i) < 0)
+                    goto cleanup;
+                if (prlsdkGetStatsParam(privdom, name, &vcpuTime) < 0)
+                    goto cleanup;
+                if (vcpuTime != -1)
+                    info[i].cpuTime = vcpuTime;
+                VIR_FREE(name);
              }
          }
          if (cpumaps != NULL) {
@@ -871,7 +882,8 @@ vzDomainGetVcpus(virDomainPtr domain,
cleanup:
      if (privdom)
-        virObjectUnlock(privdom);
+        virDomainObjEndAPI(&privdom);
+    VIR_FREE(name);
      return ret;
  }


--
Dmitry Guryanov

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