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