qemu: bulk stats: implement balloon group

This patch implements the VIR_DOMAIN_STATS_BALLOON group of statistics.

Signed-off-by: Francesco Romani <fromani@redhat.com>
This commit is contained in:
Francesco Romani 2014-09-15 10:48:06 +02:00 committed by Peter Krempa
parent 9ebbb8699e
commit 2a9bd4a873
3 changed files with 44 additions and 0 deletions

View File

@ -2514,6 +2514,7 @@ struct _virDomainStatsRecord {
typedef enum {
VIR_DOMAIN_STATS_STATE = (1 << 0), /* return domain state */
VIR_DOMAIN_STATS_CPU_TOTAL = (1 << 1), /* return domain CPU info */
VIR_DOMAIN_STATS_BALLOON = (1 << 2), /* return domain balloon info */
} virDomainStatsTypes;
typedef enum {

View File

@ -21603,6 +21603,12 @@ virConnectGetDomainCapabilities(virConnectPtr conn,
* "cpu.user" - user cpu time spent in nanoseconds as unsigned long long.
* "cpu.system" - system cpu time spent in nanoseconds as unsigned long long.
*
* VIR_DOMAIN_STATS_BALLOON: Return memory balloon device information.
* The typed parameter keys are in this format:
* "balloon.current" - the memory in kiB currently used
* as unsigned long long.
* "balloon.maximum" - the maximum memory in kiB allowed
* as unsigned long long.
*
* Using 0 for @stats returns all stats groups supported by the given
* hypervisor.

View File

@ -17448,6 +17448,42 @@ qemuDomainGetStatsCpu(virQEMUDriverPtr driver ATTRIBUTE_UNUSED,
return 0;
}
static int
qemuDomainGetStatsBalloon(virQEMUDriverPtr driver ATTRIBUTE_UNUSED,
virDomainObjPtr dom,
virDomainStatsRecordPtr record,
int *maxparams,
unsigned int privflags ATTRIBUTE_UNUSED)
{
qemuDomainObjPrivatePtr priv = dom->privateData;
unsigned long long cur_balloon = 0;
int err = 0;
if (dom->def->memballoon &&
dom->def->memballoon->model == VIR_DOMAIN_MEMBALLOON_MODEL_NONE) {
cur_balloon = dom->def->mem.max_balloon;
} else if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BALLOON_EVENT)) {
cur_balloon = dom->def->mem.cur_balloon;
} else {
err = -1;
}
if (!err && virTypedParamsAddULLong(&record->params,
&record->nparams,
maxparams,
"balloon.current",
cur_balloon) < 0)
return -1;
if (virTypedParamsAddULLong(&record->params,
&record->nparams,
maxparams,
"balloon.maximum",
dom->def->mem.max_balloon) < 0)
return -1;
return 0;
}
typedef int
(*qemuDomainGetStatsFunc)(virQEMUDriverPtr driver,
@ -17465,6 +17501,7 @@ struct qemuDomainGetStatsWorker {
static struct qemuDomainGetStatsWorker qemuDomainGetStatsWorkers[] = {
{ qemuDomainGetStatsState, VIR_DOMAIN_STATS_STATE, false },
{ qemuDomainGetStatsCpu, VIR_DOMAIN_STATS_CPU_TOTAL, false },
{ qemuDomainGetStatsBalloon, VIR_DOMAIN_STATS_BALLOON, true },
{ NULL, 0, false }
};