1
0

vz: add vcpu statistics

Comments.

Replace vzDomObjFromDomain/virObjectUnlock pair
to vzDomObjFromDomainRef/virDomainObjEndAPI as we
use prlsdkGetStatsParam. See previous statistics
comments.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
This commit is contained in:
Nikolay Shirokovskiy 2015-06-26 14:24:00 +03:00 committed by Dmitry Guryanov
parent b6c11c3910
commit b2f73ee22e
3 changed files with 25 additions and 2 deletions

View File

@ -826,7 +826,7 @@ vzDomainGetVcpus(virDomainPtr domain,
int v, maxcpu, hostcpus; int v, maxcpu, hostcpus;
int ret = -1; int ret = -1;
if (!(privdom = vzDomObjFromDomain(domain))) if (!(privdom = vzDomObjFromDomainRef(domain)))
goto cleanup; goto cleanup;
if (!virDomainObjIsActive(privdom)) { if (!virDomainObjIsActive(privdom)) {
@ -849,6 +849,8 @@ vzDomainGetVcpus(virDomainPtr domain,
for (i = 0; i < maxinfo; i++) { for (i = 0; i < maxinfo; i++) {
info[i].number = i; info[i].number = i;
info[i].state = VIR_VCPU_RUNNING; info[i].state = VIR_VCPU_RUNNING;
if (prlsdkGetVcpuStats(privdom, i, &info[i].cpuTime) < 0)
goto cleanup;
} }
} }
if (cpumaps != NULL) { if (cpumaps != NULL) {
@ -871,7 +873,7 @@ vzDomainGetVcpus(virDomainPtr domain,
cleanup: cleanup:
if (privdom) if (privdom)
virObjectUnlock(privdom); virDomainObjEndAPI(&privdom);
return ret; return ret;
} }

View File

@ -3862,3 +3862,22 @@ prlsdkGetNetStats(virDomainObjPtr dom, const char *path,
return ret; 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;
}

View File

@ -72,3 +72,5 @@ int
prlsdkDetachNet(virDomainObjPtr dom, vzConnPtr privconn, virDomainNetDefPtr net); prlsdkDetachNet(virDomainObjPtr dom, vzConnPtr privconn, virDomainNetDefPtr net);
int int
prlsdkGetNetStats(virDomainObjPtr dom, const char *path, virDomainInterfaceStatsPtr stats); prlsdkGetNetStats(virDomainObjPtr dom, const char *path, virDomainInterfaceStatsPtr stats);
int
prlsdkGetVcpuStats(virDomainObjPtr dom, int idx, unsigned long long *time);