From 2a41a2301b959abb3928a226286e25e86966926a Mon Sep 17 00:00:00 2001 From: Nikolay Shirokovskiy Date: Mon, 12 Dec 2016 10:56:37 +0300 Subject: [PATCH] vz: add balloon group to all domain stats --- src/vz/vz_driver.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c index 81e93b9608..b518c827d2 100644 --- a/src/vz/vz_driver.c +++ b/src/vz/vz_driver.c @@ -3688,6 +3688,57 @@ vzDomainGetVCPUStats(virDomainObjPtr dom, 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 vzDomainGetAllStats(virConnectPtr conn, virDomainObjPtr dom) @@ -3707,6 +3758,9 @@ vzDomainGetAllStats(virConnectPtr conn, if (vzDomainGetVCPUStats(dom, stat, &maxparams) < 0) goto error; + if (vzDomainGetBalloonStats(dom, stat, &maxparams) < 0) + goto error; + if (!(stat->dom = virGetDomain(conn, dom->def->name, dom->def->uuid))) goto error; -- GitLab