As a preparation to get statistics without domain lock. Let's
take all we want from domain cache first. After this point
domain lock can be dropped.
Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy(a)virtuozzo.com>
---
src/vz/vz_driver.c | 24 +++++++++++++++---------
1 file changed, 15 insertions(+), 9 deletions(-)
diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c
index 62d5047..810017c 100644
--- a/src/vz/vz_driver.c
+++ b/src/vz/vz_driver.c
@@ -601,6 +601,8 @@ vzDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info)
{
virDomainObjPtr privdom;
int ret = -1;
+ size_t i;
+ unsigned int nvcpus;
if (!(privdom = vzDomObjFromDomainRef(domain)))
goto cleanup;
@@ -611,18 +613,22 @@ vzDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info)
info->nrVirtCpu = virDomainDefGetVcpus(privdom->def);
info->cpuTime = 0;
- if (virDomainObjIsActive(privdom)) {
+ if (!virDomainObjIsActive(privdom)) {
+ ret = 0;
+ goto cleanup;
+ }
+
+ nvcpus = virDomainDefGetVcpus(privdom->def);
+
+ for (i = 0; i < nvcpus; ++i) {
unsigned long long vtime;
- size_t i;
- for (i = 0; i < virDomainDefGetVcpus(privdom->def); ++i) {
- if (prlsdkGetVcpuStats(privdom, i, &vtime) < 0) {
- virReportError(VIR_ERR_OPERATION_FAILED, "%s",
- _("cannot read cputime for domain"));
- goto cleanup;
- }
- info->cpuTime += vtime;
+ if (prlsdkGetVcpuStats(privdom, i, &vtime) < 0) {
+ virReportError(VIR_ERR_OPERATION_FAILED, "%s",
+ _("cannot read cputime for domain"));
+ goto cleanup;
}
+ info->cpuTime += vtime;
}
ret = 0;
--
1.8.3.1