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:
parent
b6c11c3910
commit
b2f73ee22e
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user