]> git.proxmox.com Git - pve-qemu-kvm.git/blame - debian/patches/virtio-balloon-fix-query.patch
Two more fixes
[pve-qemu-kvm.git] / debian / patches / virtio-balloon-fix-query.patch
CommitLineData
34baf3f7
DM
1Index: new/hmp.c
2===================================================================
24bb7da3
DM
3--- new.orig/hmp.c 2014-11-20 06:45:05.000000000 +0100
4+++ new/hmp.c 2014-11-20 07:26:23.000000000 +0100
58117ea6 5@@ -635,7 +635,35 @@
1c66df30
AD
6 return;
7 }
efc05ce5 8
1c66df30
AD
9- monitor_printf(mon, "balloon: actual=%" PRId64 "\n", info->actual >> 20);
10+ monitor_printf(mon, "balloon: actual=%" PRId64, info->actual >> 20);
11+ monitor_printf(mon, " max_mem=%" PRId64, info->max_mem >> 20);
12+ if (info->has_total_mem) {
13+ monitor_printf(mon, " total_mem=%" PRId64, info->total_mem >> 20);
14+ }
15+ if (info->has_free_mem) {
16+ monitor_printf(mon, " free_mem=%" PRId64, info->free_mem >> 20);
17+ }
18+
19+ if (info->has_mem_swapped_in) {
20+ monitor_printf(mon, " mem_swapped_in=%" PRId64, info->mem_swapped_in);
21+ }
22+ if (info->has_mem_swapped_out) {
23+ monitor_printf(mon, " mem_swapped_out=%" PRId64, info->mem_swapped_out);
24+ }
25+ if (info->has_major_page_faults) {
26+ monitor_printf(mon, " major_page_faults=%" PRId64,
27+ info->major_page_faults);
28+ }
29+ if (info->has_minor_page_faults) {
30+ monitor_printf(mon, " minor_page_faults=%" PRId64,
31+ info->minor_page_faults);
32+ }
33+ if (info->has_last_update) {
34+ monitor_printf(mon, " last_update=%" PRId64,
35+ info->last_update);
36+ }
37+
38+ monitor_printf(mon, "\n");
39
40 qapi_free_BalloonInfo(info);
41 }
34baf3f7
DM
42Index: new/hw/virtio/virtio-balloon.c
43===================================================================
24bb7da3
DM
44--- new.orig/hw/virtio/virtio-balloon.c 2014-11-20 06:45:06.000000000 +0100
45+++ new/hw/virtio/virtio-balloon.c 2014-11-20 07:26:23.000000000 +0100
58117ea6
WB
46@@ -319,8 +319,37 @@
47 static void virtio_balloon_stat(void *opaque, BalloonInfo *info)
48 {
efc05ce5 49 VirtIOBalloon *dev = opaque;
58117ea6
WB
50- info->actual = get_current_ram_size() - ((uint64_t) dev->actual <<
51- VIRTIO_BALLOON_PFN_SHIFT);
52+ ram_addr_t ram_size = get_current_ram_size();
53+ info->actual = ram_size - ((uint64_t) dev->actual <<
54+ VIRTIO_BALLOON_PFN_SHIFT);
efc05ce5 55+
53ba79ec 56+ info->max_mem = ram_size;
efc05ce5 57+
53ba79ec 58+ if (!(balloon_stats_enabled(dev) && balloon_stats_supported(dev) &&
58117ea6
WB
59+ dev->stats_last_update)) {
60+ return;
efc05ce5
DM
61+ }
62+
63+ info->last_update = dev->stats_last_update;
64+ info->has_last_update = true;
65+
66+ info->mem_swapped_in = dev->stats[VIRTIO_BALLOON_S_SWAP_IN];
67+ info->has_mem_swapped_in = info->mem_swapped_in >= 0 ? true : false;
68+
69+ info->mem_swapped_out = dev->stats[VIRTIO_BALLOON_S_SWAP_OUT];
70+ info->has_mem_swapped_out = info->mem_swapped_out >= 0 ? true : false;
71+
72+ info->major_page_faults = dev->stats[VIRTIO_BALLOON_S_MAJFLT];
73+ info->has_major_page_faults = info->major_page_faults >= 0 ? true : false;
74+
75+ info->minor_page_faults = dev->stats[VIRTIO_BALLOON_S_MINFLT];
76+ info->has_minor_page_faults = info->minor_page_faults >= 0 ? true : false;
77+
78+ info->free_mem = dev->stats[VIRTIO_BALLOON_S_MEMFREE];
79+ info->has_free_mem = info->free_mem >= 0 ? true : false;
53ba79ec
DM
80+
81+ info->total_mem = dev->stats[VIRTIO_BALLOON_S_MEMTOT];
82+ info->has_total_mem = info->total_mem >= 0 ? true : false;
efc05ce5
DM
83 }
84
85 static void virtio_balloon_to_target(void *opaque, ram_addr_t target)
34baf3f7
DM
86Index: new/qapi-schema.json
87===================================================================
24bb7da3
DM
88--- new.orig/qapi-schema.json 2014-11-20 06:45:06.000000000 +0100
89+++ new/qapi-schema.json 2014-11-20 07:26:23.000000000 +0100
432a6eb5 90@@ -983,10 +983,29 @@
efc05ce5
DM
91 #
92 # @actual: the number of bytes the balloon currently contains
93 #
1c66df30 94-# Since: 0.14.0
efc05ce5
DM
95+# @last_update: #optional time when stats got updated from guest
96+#
1c66df30
AD
97+# @mem_swapped_in: #optional number of pages swapped in within the guest
98+#
99+# @mem_swapped_out: #optional number of pages swapped out within the guest
100+#
101+# @major_page_faults: #optional number of major page faults within the guest
efc05ce5 102 #
1c66df30
AD
103+# @minor_page_faults: #optional number of minor page faults within the guest
104+#
105+# @free_mem: #optional amount of memory (in bytes) free in the guest
106+#
107+# @total_mem: #optional amount of memory (in bytes) visible to the guest
108+#
53ba79ec 109+# @max_mem: amount of memory (in bytes) assigned to the guest
1c66df30 110+#
53ba79ec 111+# Since: 0.14.0
efc05ce5 112 ##
432a6eb5
WB
113-{ 'struct': 'BalloonInfo', 'data': {'actual': 'int' } }
114+{ 'struct': 'BalloonInfo',
efc05ce5 115+ 'data': {'actual': 'int', '*last_update': 'int', '*mem_swapped_in': 'int',
1c66df30
AD
116+ '*mem_swapped_out': 'int', '*major_page_faults': 'int',
117+ '*minor_page_faults': 'int', '*free_mem': 'int',
34baf3f7 118+ '*total_mem': 'int', 'max_mem': 'int' } }
efc05ce5
DM
119
120 ##
121 # @query-balloon:
34baf3f7
DM
122Index: new/qmp-commands.hx
123===================================================================
24bb7da3
DM
124--- new.orig/qmp-commands.hx 2014-11-20 06:45:06.000000000 +0100
125+++ new/qmp-commands.hx 2014-11-20 07:26:23.000000000 +0100
58117ea6 126@@ -3329,6 +3329,13 @@
1c66df30 127 json-object will be returned containing the following data:
efc05ce5 128
1c66df30
AD
129 - "actual": current balloon value in bytes (json-int)
130+- "mem_swapped_in": Amount of memory swapped in bytes (json-int, optional)
131+- "mem_swapped_out": Amount of memory swapped out in bytes (json-int, optional)
132+- "major_page_faults": Number of major faults (json-int, optional)
133+- "minor_page_faults": Number of minor faults (json-int, optional)
134+- "free_mem": Total amount of free and unused memory in
135+ bytes (json-int, optional)
136+- "total_mem": Total amount of available memory in bytes (json-int, optional)
137
138 Example:
139
58117ea6 140@@ -3336,6 +3344,12 @@
1c66df30
AD
141 <- {
142 "return":{
143 "actual":1073741824,
144+ "mem_swapped_in":0,
145+ "mem_swapped_out":0,
146+ "major_page_faults":142,
147+ "minor_page_faults":239245,
148+ "free_mem":1014185984,
149+ "total_mem":1044668416
150 }
151 }
efc05ce5 152