Just straight-forward patch.
Use reference counting for privdom as stats internally could drop domain lock.
Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy(a)virtuozzo.com>
---
src/vz/vz_driver.c | 19 ++++++++++++++++---
1 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c
index 6f1cbfb..0a968b9 100644
--- a/src/vz/vz_driver.c
+++ b/src/vz/vz_driver.c
@@ -554,7 +554,7 @@ vzDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info)
virDomainObjPtr privdom;
int ret = -1;
- if (!(privdom = vzDomObjFromDomain(domain)))
+ if (!(privdom = vzDomObjFromDomainRef(domain)))
goto cleanup;
info->state = virDomainObjGetState(privdom, NULL);
@@ -562,11 +562,24 @@ vzDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info)
info->maxMem = virDomainDefGetMemoryActual(privdom->def);
info->nrVirtCpu = privdom->def->vcpus;
info->cpuTime = 0;
+
+ if (virDomainObjIsActive(privdom)) {
+ unsigned long long vtime;
+ size_t i;
+
+ for (i = 0; i < privdom->def->vcpus; ++i) {
+ if (prlsdkGetVcpuStats(privdom, i, &vtime) < 0) {
+ virReportError(VIR_ERR_OPERATION_FAILED, "%s",
+ _("cannot read cputime for domain"));
+ goto cleanup;
+ }
+ info->cpuTime += vtime;
+ }
+ }
ret = 0;
cleanup:
- if (privdom)
- virObjectUnlock(privdom);
+ virDomainObjEndAPI(&privdom);
return ret;
}
--
1.7.1