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