]> git.proxmox.com Git - pve-qemu.git/blame - debian/patches/pve/0013-PVE-virtio-balloon-improve-query-balloon.patch
update submodule and patches to 7.2.0
[pve-qemu.git] / debian / patches / pve / 0013-PVE-virtio-balloon-improve-query-balloon.patch
CommitLineData
23102ed6 1From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
95259824 2From: Wolfgang Bumiller <w.bumiller@proxmox.com>
83faa3fe
TL
3Date: Mon, 6 Apr 2020 12:16:43 +0200
4Subject: [PATCH] PVE: virtio-balloon: improve query-balloon
95259824
WB
5
6Actually provide memory information via the query-balloon
7command.
b855dce7
TL
8
9Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
95259824 10---
95259824 11 hw/virtio/virtio-balloon.c | 33 +++++++++++++++++++++++++++++++--
be901f66 12 monitor/hmp-cmds.c | 30 +++++++++++++++++++++++++++++-
817b7667 13 qapi/machine.json | 22 +++++++++++++++++++++-
6838f038 14 3 files changed, 81 insertions(+), 4 deletions(-)
95259824 15
95259824 16diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c
5b15e2ec 17index 73ac5eb675..bbfe7eca62 100644
95259824
WB
18--- a/hw/virtio/virtio-balloon.c
19+++ b/hw/virtio/virtio-balloon.c
5b15e2ec 20@@ -806,8 +806,37 @@ static uint64_t virtio_balloon_get_features(VirtIODevice *vdev, uint64_t f,
95259824
WB
21 static void virtio_balloon_stat(void *opaque, BalloonInfo *info)
22 {
23 VirtIOBalloon *dev = opaque;
24- info->actual = get_current_ram_size() - ((uint64_t) dev->actual <<
25- VIRTIO_BALLOON_PFN_SHIFT);
26+ ram_addr_t ram_size = get_current_ram_size();
27+ info->actual = ram_size - ((uint64_t) dev->actual <<
28+ VIRTIO_BALLOON_PFN_SHIFT);
29+
30+ info->max_mem = ram_size;
31+
32+ if (!(balloon_stats_enabled(dev) && balloon_stats_supported(dev) &&
33+ dev->stats_last_update)) {
34+ return;
35+ }
36+
37+ info->last_update = dev->stats_last_update;
38+ info->has_last_update = true;
39+
40+ info->mem_swapped_in = dev->stats[VIRTIO_BALLOON_S_SWAP_IN];
41+ info->has_mem_swapped_in = info->mem_swapped_in >= 0 ? true : false;
42+
43+ info->mem_swapped_out = dev->stats[VIRTIO_BALLOON_S_SWAP_OUT];
44+ info->has_mem_swapped_out = info->mem_swapped_out >= 0 ? true : false;
45+
46+ info->major_page_faults = dev->stats[VIRTIO_BALLOON_S_MAJFLT];
47+ info->has_major_page_faults = info->major_page_faults >= 0 ? true : false;
48+
49+ info->minor_page_faults = dev->stats[VIRTIO_BALLOON_S_MINFLT];
50+ info->has_minor_page_faults = info->minor_page_faults >= 0 ? true : false;
51+
52+ info->free_mem = dev->stats[VIRTIO_BALLOON_S_MEMFREE];
53+ info->has_free_mem = info->free_mem >= 0 ? true : false;
54+
55+ info->total_mem = dev->stats[VIRTIO_BALLOON_S_MEMTOT];
56+ info->has_total_mem = info->total_mem >= 0 ? true : false;
57 }
58
59 static void virtio_balloon_to_target(void *opaque, ram_addr_t target)
be901f66 60diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
d03e1b3c 61index 01b789a79e..480b798963 100644
be901f66
SR
62--- a/monitor/hmp-cmds.c
63+++ b/monitor/hmp-cmds.c
d03e1b3c 64@@ -696,7 +696,35 @@ void hmp_info_balloon(Monitor *mon, const QDict *qdict)
be901f66
SR
65 return;
66 }
67
68- monitor_printf(mon, "balloon: actual=%" PRId64 "\n", info->actual >> 20);
69+ monitor_printf(mon, "balloon: actual=%" PRId64, info->actual >> 20);
70+ monitor_printf(mon, " max_mem=%" PRId64, info->max_mem >> 20);
71+ if (info->has_total_mem) {
72+ monitor_printf(mon, " total_mem=%" PRId64, info->total_mem >> 20);
73+ }
74+ if (info->has_free_mem) {
75+ monitor_printf(mon, " free_mem=%" PRId64, info->free_mem >> 20);
76+ }
77+
78+ if (info->has_mem_swapped_in) {
79+ monitor_printf(mon, " mem_swapped_in=%" PRId64, info->mem_swapped_in);
80+ }
81+ if (info->has_mem_swapped_out) {
82+ monitor_printf(mon, " mem_swapped_out=%" PRId64, info->mem_swapped_out);
83+ }
84+ if (info->has_major_page_faults) {
85+ monitor_printf(mon, " major_page_faults=%" PRId64,
86+ info->major_page_faults);
87+ }
88+ if (info->has_minor_page_faults) {
89+ monitor_printf(mon, " minor_page_faults=%" PRId64,
90+ info->minor_page_faults);
91+ }
92+ if (info->has_last_update) {
93+ monitor_printf(mon, " last_update=%" PRId64,
94+ info->last_update);
95+ }
96+
97+ monitor_printf(mon, "\n");
98
99 qapi_free_BalloonInfo(info);
100 }
817b7667 101diff --git a/qapi/machine.json b/qapi/machine.json
d03e1b3c 102index b9228a5e46..10e77a9af3 100644
817b7667
SR
103--- a/qapi/machine.json
104+++ b/qapi/machine.json
5b15e2ec 105@@ -1054,9 +1054,29 @@
817b7667
SR
106 # @actual: the logical size of the VM in bytes
107 # Formula used: logical_vm_size = vm_ram_size - balloon_size
95259824 108 #
a544966d 109+# @last_update: time when stats got updated from guest
95259824 110+#
a544966d 111+# @mem_swapped_in: number of pages swapped in within the guest
95259824 112+#
a544966d 113+# @mem_swapped_out: number of pages swapped out within the guest
95259824 114+#
a544966d 115+# @major_page_faults: number of major page faults within the guest
6838f038 116+#
a544966d 117+# @minor_page_faults: number of minor page faults within the guest
95259824 118+#
a544966d 119+# @free_mem: amount of memory (in bytes) free in the guest
95259824 120+#
a544966d 121+# @total_mem: amount of memory (in bytes) visible to the guest
95259824
WB
122+#
123+# @max_mem: amount of memory (in bytes) assigned to the guest
6838f038 124+#
8dca018b 125 # Since: 0.14
95259824
WB
126 ##
127-{ 'struct': 'BalloonInfo', 'data': {'actual': 'int' } }
128+{ 'struct': 'BalloonInfo',
129+ 'data': {'actual': 'int', '*last_update': 'int', '*mem_swapped_in': 'int',
130+ '*mem_swapped_out': 'int', '*major_page_faults': 'int',
131+ '*minor_page_faults': 'int', '*free_mem': 'int',
132+ '*total_mem': 'int', 'max_mem': 'int' } }
133
134 ##
135 # @query-balloon: