|
|
9119d9 |
From 570e9ebae2d7f64e43f7ec2b95c3a3679c3688b2 Mon Sep 17 00:00:00 2001
|
|
|
9119d9 |
Message-Id: <570e9ebae2d7f64e43f7ec2b95c3a3679c3688b2@dist-git>
|
|
|
9119d9 |
From: Francesco Romani <fromani@redhat.com>
|
|
|
9119d9 |
Date: Wed, 1 Oct 2014 11:20:13 +0200
|
|
|
9119d9 |
Subject: [PATCH] qemu: bulk stats: implement balloon group
|
|
|
9119d9 |
|
|
|
9119d9 |
https://bugzilla.redhat.com/show_bug.cgi?id=1113116
|
|
|
9119d9 |
|
|
|
9119d9 |
This patch implements the VIR_DOMAIN_STATS_BALLOON group of statistics.
|
|
|
9119d9 |
|
|
|
9119d9 |
Signed-off-by: Francesco Romani <fromani@redhat.com>
|
|
|
9119d9 |
(cherry picked from commit 2a9bd4a8736fcb90e231b9f7109aa66d9108b286)
|
|
|
9119d9 |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
9119d9 |
---
|
|
|
9119d9 |
include/libvirt/libvirt.h.in | 1 +
|
|
|
9119d9 |
src/libvirt.c | 6 ++++++
|
|
|
9119d9 |
src/qemu/qemu_driver.c | 37 +++++++++++++++++++++++++++++++++++++
|
|
|
9119d9 |
3 files changed, 44 insertions(+)
|
|
|
9119d9 |
|
|
|
9119d9 |
diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
|
|
|
9119d9 |
index 349ae93..48ecea8 100644
|
|
|
9119d9 |
--- a/include/libvirt/libvirt.h.in
|
|
|
9119d9 |
+++ b/include/libvirt/libvirt.h.in
|
|
|
9119d9 |
@@ -2515,6 +2515,7 @@ struct _virDomainStatsRecord {
|
|
|
9119d9 |
typedef enum {
|
|
|
9119d9 |
VIR_DOMAIN_STATS_STATE = (1 << 0), /* return domain state */
|
|
|
9119d9 |
VIR_DOMAIN_STATS_CPU_TOTAL = (1 << 1), /* return domain CPU info */
|
|
|
9119d9 |
+ VIR_DOMAIN_STATS_BALLOON = (1 << 2), /* return domain balloon info */
|
|
|
9119d9 |
} virDomainStatsTypes;
|
|
|
9119d9 |
|
|
|
9119d9 |
typedef enum {
|
|
|
9119d9 |
diff --git a/src/libvirt.c b/src/libvirt.c
|
|
|
9119d9 |
index 70644bc..64ef74b 100644
|
|
|
9119d9 |
--- a/src/libvirt.c
|
|
|
9119d9 |
+++ b/src/libvirt.c
|
|
|
9119d9 |
@@ -21562,6 +21562,12 @@ virConnectGetDomainCapabilities(virConnectPtr conn,
|
|
|
9119d9 |
* "cpu.user" - user cpu time spent in nanoseconds as unsigned long long.
|
|
|
9119d9 |
* "cpu.system" - system cpu time spent in nanoseconds as unsigned long long.
|
|
|
9119d9 |
*
|
|
|
9119d9 |
+ * VIR_DOMAIN_STATS_BALLOON: Return memory balloon device information.
|
|
|
9119d9 |
+ * The typed parameter keys are in this format:
|
|
|
9119d9 |
+ * "balloon.current" - the memory in kiB currently used
|
|
|
9119d9 |
+ * as unsigned long long.
|
|
|
9119d9 |
+ * "balloon.maximum" - the maximum memory in kiB allowed
|
|
|
9119d9 |
+ * as unsigned long long.
|
|
|
9119d9 |
*
|
|
|
9119d9 |
* Using 0 for @stats returns all stats groups supported by the given
|
|
|
9119d9 |
* hypervisor.
|
|
|
9119d9 |
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
|
|
|
9119d9 |
index ea06a0d..71a0e0e 100644
|
|
|
9119d9 |
--- a/src/qemu/qemu_driver.c
|
|
|
9119d9 |
+++ b/src/qemu/qemu_driver.c
|
|
|
9119d9 |
@@ -17487,6 +17487,42 @@ qemuDomainGetStatsCpu(virQEMUDriverPtr driver ATTRIBUTE_UNUSED,
|
|
|
9119d9 |
return 0;
|
|
|
9119d9 |
}
|
|
|
9119d9 |
|
|
|
9119d9 |
+static int
|
|
|
9119d9 |
+qemuDomainGetStatsBalloon(virQEMUDriverPtr driver ATTRIBUTE_UNUSED,
|
|
|
9119d9 |
+ virDomainObjPtr dom,
|
|
|
9119d9 |
+ virDomainStatsRecordPtr record,
|
|
|
9119d9 |
+ int *maxparams,
|
|
|
9119d9 |
+ unsigned int privflags ATTRIBUTE_UNUSED)
|
|
|
9119d9 |
+{
|
|
|
9119d9 |
+ qemuDomainObjPrivatePtr priv = dom->privateData;
|
|
|
9119d9 |
+ unsigned long long cur_balloon = 0;
|
|
|
9119d9 |
+ int err = 0;
|
|
|
9119d9 |
+
|
|
|
9119d9 |
+ if (dom->def->memballoon &&
|
|
|
9119d9 |
+ dom->def->memballoon->model == VIR_DOMAIN_MEMBALLOON_MODEL_NONE) {
|
|
|
9119d9 |
+ cur_balloon = dom->def->mem.max_balloon;
|
|
|
9119d9 |
+ } else if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BALLOON_EVENT)) {
|
|
|
9119d9 |
+ cur_balloon = dom->def->mem.cur_balloon;
|
|
|
9119d9 |
+ } else {
|
|
|
9119d9 |
+ err = -1;
|
|
|
9119d9 |
+ }
|
|
|
9119d9 |
+
|
|
|
9119d9 |
+ if (!err && virTypedParamsAddULLong(&record->params,
|
|
|
9119d9 |
+ &record->nparams,
|
|
|
9119d9 |
+ maxparams,
|
|
|
9119d9 |
+ "balloon.current",
|
|
|
9119d9 |
+ cur_balloon) < 0)
|
|
|
9119d9 |
+ return -1;
|
|
|
9119d9 |
+
|
|
|
9119d9 |
+ if (virTypedParamsAddULLong(&record->params,
|
|
|
9119d9 |
+ &record->nparams,
|
|
|
9119d9 |
+ maxparams,
|
|
|
9119d9 |
+ "balloon.maximum",
|
|
|
9119d9 |
+ dom->def->mem.max_balloon) < 0)
|
|
|
9119d9 |
+ return -1;
|
|
|
9119d9 |
+
|
|
|
9119d9 |
+ return 0;
|
|
|
9119d9 |
+}
|
|
|
9119d9 |
|
|
|
9119d9 |
typedef int
|
|
|
9119d9 |
(*qemuDomainGetStatsFunc)(virQEMUDriverPtr driver,
|
|
|
9119d9 |
@@ -17504,6 +17540,7 @@ struct qemuDomainGetStatsWorker {
|
|
|
9119d9 |
static struct qemuDomainGetStatsWorker qemuDomainGetStatsWorkers[] = {
|
|
|
9119d9 |
{ qemuDomainGetStatsState, VIR_DOMAIN_STATS_STATE, false },
|
|
|
9119d9 |
{ qemuDomainGetStatsCpu, VIR_DOMAIN_STATS_CPU_TOTAL, false },
|
|
|
9119d9 |
+ { qemuDomainGetStatsBalloon, VIR_DOMAIN_STATS_BALLOON, true },
|
|
|
9119d9 |
{ NULL, 0, false }
|
|
|
9119d9 |
};
|
|
|
9119d9 |
|
|
|
9119d9 |
--
|
|
|
9119d9 |
2.1.2
|
|
|
9119d9 |
|