提交 2a41a230 编写于 作者: N Nikolay Shirokovskiy 提交者: Maxim Nestratov

vz: add balloon group to all domain stats

上级 e15e94c2
...@@ -3688,6 +3688,57 @@ vzDomainGetVCPUStats(virDomainObjPtr dom, ...@@ -3688,6 +3688,57 @@ vzDomainGetVCPUStats(virDomainObjPtr dom,
return 0; return 0;
} }
static int
vzDomainGetBalloonStats(virDomainObjPtr dom,
virDomainStatsRecordPtr record,
int *maxparams)
{
vzDomObjPtr privdom = dom->privateData;
virDomainMemoryStatStruct stats[VIR_DOMAIN_MEMORY_STAT_NR];
size_t i;
int n;
if (virTypedParamsAddULLong(&record->params,
&record->nparams,
maxparams,
"balloon.maximum",
virDomainDefGetMemoryTotal(dom->def)) < 0)
return -1;
if (virTypedParamsAddULLong(&record->params,
&record->nparams,
maxparams,
"balloon.current",
virDomainDefGetMemoryTotal(dom->def)) < 0)
return -1;
n = prlsdkGetMemoryStats(privdom->stats, stats, VIR_DOMAIN_MEMORY_STAT_NR);
if (n < 0)
return -1;
#define STORE_MEM_RECORD(TAG, NAME) \
if (stats[i].tag == VIR_DOMAIN_MEMORY_STAT_ ##TAG) \
if (virTypedParamsAddULLong(&record->params, \
&record->nparams, \
maxparams, \
"balloon." NAME, \
stats[i].val) < 0) \
return -1;
for (i = 0; i < n; i++) {
STORE_MEM_RECORD(SWAP_IN, "swap_in")
STORE_MEM_RECORD(SWAP_OUT, "swap_out")
STORE_MEM_RECORD(MAJOR_FAULT, "major_fault")
STORE_MEM_RECORD(MINOR_FAULT, "minor_fault")
STORE_MEM_RECORD(AVAILABLE, "available")
STORE_MEM_RECORD(UNUSED, "unused")
}
#undef STORE_MEM_RECORD
return 0;
}
static virDomainStatsRecordPtr static virDomainStatsRecordPtr
vzDomainGetAllStats(virConnectPtr conn, vzDomainGetAllStats(virConnectPtr conn,
virDomainObjPtr dom) virDomainObjPtr dom)
...@@ -3707,6 +3758,9 @@ vzDomainGetAllStats(virConnectPtr conn, ...@@ -3707,6 +3758,9 @@ vzDomainGetAllStats(virConnectPtr conn,
if (vzDomainGetVCPUStats(dom, stat, &maxparams) < 0) if (vzDomainGetVCPUStats(dom, stat, &maxparams) < 0)
goto error; goto error;
if (vzDomainGetBalloonStats(dom, stat, &maxparams) < 0)
goto error;
if (!(stat->dom = virGetDomain(conn, dom->def->name, dom->def->uuid))) if (!(stat->dom = virGetDomain(conn, dom->def->name, dom->def->uuid)))
goto error; goto error;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册