mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-23 13:05:27 +00:00
vz: add memory statistics
Implemented counters: VIR_DOMAIN_MEMORY_STAT_SWAP_IN VIR_DOMAIN_MEMORY_STAT_SWAP_OUT VIR_DOMAIN_MEMORY_STAT_MINOR_FAULT VIR_DOMAIN_MEMORY_STAT_MAJOR_FAULT VIR_DOMAIN_MEMORY_STAT_AVAILABLE VIR_DOMAIN_MEMORY_STAT_ACTUAL_BALLOON VIR_DOMAIN_MEMORY_STAT_UNUSED Comments. 1. Use vzDomObjFromDomainRef/virDomainObjEndAPI pair to get domain object as we use prlsdkGetStatsParam. See previous statistics comments. 2. Balloon statistics is not applicable to containers. Fault statistics for containers not provided in PCS6 yet. Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
This commit is contained in:
parent
b2f73ee22e
commit
bb7d275d15
@ -1356,6 +1356,25 @@ vzDomainInterfaceStats(virDomainPtr domain,
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
vzDomainMemoryStats(virDomainPtr domain,
|
||||
virDomainMemoryStatPtr stats,
|
||||
unsigned int nr_stats,
|
||||
unsigned int flags)
|
||||
{
|
||||
virDomainObjPtr dom = NULL;
|
||||
int ret = -1;
|
||||
|
||||
virCheckFlags(0, -1);
|
||||
if (!(dom = vzDomObjFromDomainRef(domain)))
|
||||
return -1;
|
||||
|
||||
ret = prlsdkGetMemoryStats(dom, stats, nr_stats);
|
||||
virDomainObjEndAPI(&dom);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static virHypervisorDriver vzDriver = {
|
||||
.name = "vz",
|
||||
.connectOpen = vzConnectOpen, /* 0.10.0 */
|
||||
@ -1408,6 +1427,7 @@ static virHypervisorDriver vzDriver = {
|
||||
.domainBlockStats = vzDomainBlockStats, /* 1.3.0 */
|
||||
.domainBlockStatsFlags = vzDomainBlockStatsFlags, /* 1.3.0 */
|
||||
.domainInterfaceStats = vzDomainInterfaceStats, /* 1.3.0 */
|
||||
.domainMemoryStats = vzDomainMemoryStats, /* 1.3.0 */
|
||||
};
|
||||
|
||||
static virConnectDriver vzConnectDriver = {
|
||||
|
@ -3881,3 +3881,64 @@ prlsdkGetVcpuStats(virDomainObjPtr dom, int idx, unsigned long long *vtime)
|
||||
VIR_FREE(name);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
prlsdkGetMemoryStats(virDomainObjPtr dom,
|
||||
virDomainMemoryStatPtr stats,
|
||||
unsigned int nr_stats)
|
||||
{
|
||||
int ret = -1;
|
||||
long long v = 0, t = 0, u = 0;
|
||||
size_t i = 0;
|
||||
|
||||
#define PRLSDK_GET_COUNTER(NAME, VALUE) \
|
||||
if (prlsdkGetStatsParam(dom, NAME, &VALUE) < 0) \
|
||||
goto cleanup; \
|
||||
|
||||
#define PRLSDK_MEMORY_STAT_SET(TAG, VALUE) \
|
||||
if (i < nr_stats) { \
|
||||
stats[i].tag = (TAG); \
|
||||
stats[i].val = (VALUE); \
|
||||
i++; \
|
||||
}
|
||||
|
||||
i = 0;
|
||||
|
||||
// count to kb
|
||||
PRLSDK_GET_COUNTER("guest.ram.swap_in", v)
|
||||
if (v != -1)
|
||||
PRLSDK_MEMORY_STAT_SET(VIR_DOMAIN_MEMORY_STAT_SWAP_IN, v << 12)
|
||||
|
||||
PRLSDK_GET_COUNTER("guest.ram.swap_out", v)
|
||||
if (v != -1)
|
||||
PRLSDK_MEMORY_STAT_SET(VIR_DOMAIN_MEMORY_STAT_SWAP_OUT, v << 12)
|
||||
|
||||
PRLSDK_GET_COUNTER("guest.ram.minor_fault", v)
|
||||
if (v != -1)
|
||||
PRLSDK_MEMORY_STAT_SET(VIR_DOMAIN_MEMORY_STAT_MINOR_FAULT, v)
|
||||
|
||||
PRLSDK_GET_COUNTER("guest.ram.major_fault", v)
|
||||
if (v != -1)
|
||||
PRLSDK_MEMORY_STAT_SET(VIR_DOMAIN_MEMORY_STAT_MAJOR_FAULT, v)
|
||||
|
||||
PRLSDK_GET_COUNTER("guest.ram.total", v)
|
||||
if (v != -1)
|
||||
PRLSDK_MEMORY_STAT_SET(VIR_DOMAIN_MEMORY_STAT_AVAILABLE, v << 10)
|
||||
|
||||
PRLSDK_GET_COUNTER("guest.ram.balloon_actual", v)
|
||||
if (v != -1)
|
||||
PRLSDK_MEMORY_STAT_SET(VIR_DOMAIN_MEMORY_STAT_ACTUAL_BALLOON, v << 10)
|
||||
|
||||
PRLSDK_GET_COUNTER("guest.ram.usage", u)
|
||||
PRLSDK_GET_COUNTER("guest.ram.total", t)
|
||||
if (u != -1 && t != -1)
|
||||
PRLSDK_MEMORY_STAT_SET(VIR_DOMAIN_MEMORY_STAT_UNUSED, (t - u) << 10)
|
||||
|
||||
#undef PRLSDK_GET_COUNTER
|
||||
#undef PRLSDK_MEMORY_STAT_SET
|
||||
|
||||
ret = i;
|
||||
cleanup:
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -74,3 +74,5 @@ int
|
||||
prlsdkGetNetStats(virDomainObjPtr dom, const char *path, virDomainInterfaceStatsPtr stats);
|
||||
int
|
||||
prlsdkGetVcpuStats(virDomainObjPtr dom, int idx, unsigned long long *time);
|
||||
int
|
||||
prlsdkGetMemoryStats(virDomainObjPtr dom, virDomainMemoryStatPtr stats, unsigned int nr_stats);
|
||||
|
Loading…
x
Reference in New Issue
Block a user