1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-01-14 23:24:23 +03:00

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

View File

@ -3862,3 +3862,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;
}

View File

@ -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);