From: Nikolay Shirokovskiy <nshirokovskiy(a)parallels.com>
Comments.
Replace vzDomObjFromDomain/virObjectUnlock pair
to vzDomObjFromDomainRef/virDomainObjEndAPI as we
use prlsdkGetStatsParam. See previous statistics
comments.
Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy(a)virtuozzo.com>
---
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;
}
--
1.7.1