mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-10 05:17:59 +03:00
vz: support cpu time in driver's domainGetInfo
Just straight-forward patch. Use reference counting for privdom as stats internally could drop domain lock. Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
This commit is contained in:
parent
f8ea21c95d
commit
db92aee2b4
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user