2017-04-21 12:08:44 +03:00
|
|
|
From 1cd097140cab2650415b311bd7549036df6e6978 Mon Sep 17 00:00:00 2001
|
2017-04-05 11:49:19 +03:00
|
|
|
From: Wolfgang Bumiller <w.bumiller@proxmox.com>
|
|
|
|
Date: Wed, 9 Dec 2015 14:27:49 +0100
|
2017-04-05 12:51:17 +03:00
|
|
|
Subject: [PATCH 06/49] virtio-balloon: fix query
|
2017-04-05 11:49:19 +03:00
|
|
|
|
|
|
|
Actually provide memory information via the query-balloon
|
|
|
|
command.
|
|
|
|
---
|
|
|
|
hmp.c | 30 +++++++++++++++++++++++++++++-
|
|
|
|
hw/virtio/virtio-balloon.c | 33 +++++++++++++++++++++++++++++++--
|
|
|
|
qapi-schema.json | 23 +++++++++++++++++++++--
|
2017-04-05 12:38:26 +03:00
|
|
|
3 files changed, 81 insertions(+), 5 deletions(-)
|
2017-04-05 11:49:19 +03:00
|
|
|
|
|
|
|
diff --git a/hmp.c b/hmp.c
|
2017-04-05 12:51:17 +03:00
|
|
|
index edb8970461..904542d026 100644
|
2017-04-05 11:49:19 +03:00
|
|
|
--- a/hmp.c
|
|
|
|
+++ b/hmp.c
|
2017-04-05 12:38:26 +03:00
|
|
|
@@ -723,7 +723,35 @@ void hmp_info_balloon(Monitor *mon, const QDict *qdict)
|
2017-04-05 11:49:19 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
- monitor_printf(mon, "balloon: actual=%" PRId64 "\n", info->actual >> 20);
|
|
|
|
+ monitor_printf(mon, "balloon: actual=%" PRId64, info->actual >> 20);
|
|
|
|
+ monitor_printf(mon, " max_mem=%" PRId64, info->max_mem >> 20);
|
|
|
|
+ if (info->has_total_mem) {
|
|
|
|
+ monitor_printf(mon, " total_mem=%" PRId64, info->total_mem >> 20);
|
|
|
|
+ }
|
|
|
|
+ if (info->has_free_mem) {
|
|
|
|
+ monitor_printf(mon, " free_mem=%" PRId64, info->free_mem >> 20);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (info->has_mem_swapped_in) {
|
|
|
|
+ monitor_printf(mon, " mem_swapped_in=%" PRId64, info->mem_swapped_in);
|
|
|
|
+ }
|
|
|
|
+ if (info->has_mem_swapped_out) {
|
|
|
|
+ monitor_printf(mon, " mem_swapped_out=%" PRId64, info->mem_swapped_out);
|
|
|
|
+ }
|
|
|
|
+ if (info->has_major_page_faults) {
|
|
|
|
+ monitor_printf(mon, " major_page_faults=%" PRId64,
|
|
|
|
+ info->major_page_faults);
|
|
|
|
+ }
|
|
|
|
+ if (info->has_minor_page_faults) {
|
|
|
|
+ monitor_printf(mon, " minor_page_faults=%" PRId64,
|
|
|
|
+ info->minor_page_faults);
|
|
|
|
+ }
|
|
|
|
+ if (info->has_last_update) {
|
|
|
|
+ monitor_printf(mon, " last_update=%" PRId64,
|
|
|
|
+ info->last_update);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ monitor_printf(mon, "\n");
|
|
|
|
|
|
|
|
qapi_free_BalloonInfo(info);
|
|
|
|
}
|
|
|
|
diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c
|
2017-04-05 12:51:17 +03:00
|
|
|
index a705e0ec55..158e13e795 100644
|
2017-04-05 11:49:19 +03:00
|
|
|
--- a/hw/virtio/virtio-balloon.c
|
|
|
|
+++ b/hw/virtio/virtio-balloon.c
|
2017-04-05 12:38:26 +03:00
|
|
|
@@ -379,8 +379,37 @@ static uint64_t virtio_balloon_get_features(VirtIODevice *vdev, uint64_t f,
|
2017-04-05 11:49:19 +03:00
|
|
|
static void virtio_balloon_stat(void *opaque, BalloonInfo *info)
|
|
|
|
{
|
|
|
|
VirtIOBalloon *dev = opaque;
|
|
|
|
- info->actual = get_current_ram_size() - ((uint64_t) dev->actual <<
|
|
|
|
- VIRTIO_BALLOON_PFN_SHIFT);
|
|
|
|
+ ram_addr_t ram_size = get_current_ram_size();
|
|
|
|
+ info->actual = ram_size - ((uint64_t) dev->actual <<
|
|
|
|
+ VIRTIO_BALLOON_PFN_SHIFT);
|
|
|
|
+
|
|
|
|
+ info->max_mem = ram_size;
|
|
|
|
+
|
|
|
|
+ if (!(balloon_stats_enabled(dev) && balloon_stats_supported(dev) &&
|
|
|
|
+ dev->stats_last_update)) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ info->last_update = dev->stats_last_update;
|
|
|
|
+ info->has_last_update = true;
|
|
|
|
+
|
|
|
|
+ info->mem_swapped_in = dev->stats[VIRTIO_BALLOON_S_SWAP_IN];
|
|
|
|
+ info->has_mem_swapped_in = info->mem_swapped_in >= 0 ? true : false;
|
|
|
|
+
|
|
|
|
+ info->mem_swapped_out = dev->stats[VIRTIO_BALLOON_S_SWAP_OUT];
|
|
|
|
+ info->has_mem_swapped_out = info->mem_swapped_out >= 0 ? true : false;
|
|
|
|
+
|
|
|
|
+ info->major_page_faults = dev->stats[VIRTIO_BALLOON_S_MAJFLT];
|
|
|
|
+ info->has_major_page_faults = info->major_page_faults >= 0 ? true : false;
|
|
|
|
+
|
|
|
|
+ info->minor_page_faults = dev->stats[VIRTIO_BALLOON_S_MINFLT];
|
|
|
|
+ info->has_minor_page_faults = info->minor_page_faults >= 0 ? true : false;
|
|
|
|
+
|
|
|
|
+ info->free_mem = dev->stats[VIRTIO_BALLOON_S_MEMFREE];
|
|
|
|
+ info->has_free_mem = info->free_mem >= 0 ? true : false;
|
|
|
|
+
|
|
|
|
+ info->total_mem = dev->stats[VIRTIO_BALLOON_S_MEMTOT];
|
|
|
|
+ info->has_total_mem = info->total_mem >= 0 ? true : false;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void virtio_balloon_to_target(void *opaque, ram_addr_t target)
|
|
|
|
diff --git a/qapi-schema.json b/qapi-schema.json
|
2017-04-05 12:51:17 +03:00
|
|
|
index 250e4dc49b..f38b85bf6a 100644
|
2017-04-05 11:49:19 +03:00
|
|
|
--- a/qapi-schema.json
|
|
|
|
+++ b/qapi-schema.json
|
2017-04-05 12:38:26 +03:00
|
|
|
@@ -1900,10 +1900,29 @@
|
2017-04-05 11:49:19 +03:00
|
|
|
#
|
|
|
|
# @actual: the number of bytes the balloon currently contains
|
|
|
|
#
|
|
|
|
-# Since: 0.14.0
|
2017-04-05 12:38:26 +03:00
|
|
|
+# @last_update: time when stats got updated from guest
|
2017-04-05 11:49:19 +03:00
|
|
|
+#
|
2017-04-05 12:38:26 +03:00
|
|
|
+# @mem_swapped_in: number of pages swapped in within the guest
|
2017-04-05 11:49:19 +03:00
|
|
|
+#
|
2017-04-05 12:38:26 +03:00
|
|
|
+# @mem_swapped_out: number of pages swapped out within the guest
|
2017-04-05 11:49:19 +03:00
|
|
|
+#
|
2017-04-05 12:38:26 +03:00
|
|
|
+# @major_page_faults: number of major page faults within the guest
|
2017-04-05 11:49:19 +03:00
|
|
|
#
|
2017-04-05 12:38:26 +03:00
|
|
|
+# @minor_page_faults: number of minor page faults within the guest
|
2017-04-05 11:49:19 +03:00
|
|
|
+#
|
2017-04-05 12:38:26 +03:00
|
|
|
+# @free_mem: amount of memory (in bytes) free in the guest
|
2017-04-05 11:49:19 +03:00
|
|
|
+#
|
2017-04-05 12:38:26 +03:00
|
|
|
+# @total_mem: amount of memory (in bytes) visible to the guest
|
2017-04-05 11:49:19 +03:00
|
|
|
+#
|
|
|
|
+# @max_mem: amount of memory (in bytes) assigned to the guest
|
|
|
|
+#
|
|
|
|
+# Since: 0.14.0
|
|
|
|
##
|
|
|
|
-{ 'struct': 'BalloonInfo', 'data': {'actual': 'int' } }
|
|
|
|
+{ 'struct': 'BalloonInfo',
|
|
|
|
+ 'data': {'actual': 'int', '*last_update': 'int', '*mem_swapped_in': 'int',
|
|
|
|
+ '*mem_swapped_out': 'int', '*major_page_faults': 'int',
|
|
|
|
+ '*minor_page_faults': 'int', '*free_mem': 'int',
|
|
|
|
+ '*total_mem': 'int', 'max_mem': 'int' } }
|
|
|
|
|
|
|
|
##
|
|
|
|
# @query-balloon:
|
|
|
|
--
|
2017-04-05 12:51:17 +03:00
|
|
|
2.11.0
|
2017-04-05 11:49:19 +03:00
|
|
|
|