]> git.proxmox.com Git - pve-qemu-kvm.git/blame - debian/patches/virtio-balloon-fix-query.patch
fix query-balloon
[pve-qemu-kvm.git] / debian / patches / virtio-balloon-fix-query.patch
CommitLineData
efc05ce5
DM
1Index: new/hw/virtio-balloon.c
2===================================================================
3--- new.orig/hw/virtio-balloon.c 2012-12-17 07:55:34.000000000 +0100
4+++ new/hw/virtio-balloon.c 2012-12-17 09:20:32.000000000 +0100
5@@ -59,7 +59,7 @@
6 }
7
8 static const char *balloon_stat_names[] = {
9- [VIRTIO_BALLOON_S_SWAP_IN] = "stat-swap-in",
10+ [VIRTIO_BALLOON_S_SWAP_IN] = "stat-swap-in",
11 [VIRTIO_BALLOON_S_SWAP_OUT] = "stat-swap-out",
12 [VIRTIO_BALLOON_S_MAJFLT] = "stat-major-faults",
13 [VIRTIO_BALLOON_S_MINFLT] = "stat-minor-faults",
14@@ -314,6 +314,30 @@
15 VirtIOBalloon *dev = opaque;
16 info->actual = ram_size - ((uint64_t) dev->actual <<
17 VIRTIO_BALLOON_PFN_SHIFT);
18+
19+ info->total_mem = ram_size;
20+
21+ if (!(balloon_stats_enabled(dev) && dev->stats_last_update)) {
22+ return;
23+ }
24+
25+ info->last_update = dev->stats_last_update;
26+ info->has_last_update = true;
27+
28+ info->mem_swapped_in = dev->stats[VIRTIO_BALLOON_S_SWAP_IN];
29+ info->has_mem_swapped_in = info->mem_swapped_in >= 0 ? true : false;
30+
31+ info->mem_swapped_out = dev->stats[VIRTIO_BALLOON_S_SWAP_OUT];
32+ info->has_mem_swapped_out = info->mem_swapped_out >= 0 ? true : false;
33+
34+ info->major_page_faults = dev->stats[VIRTIO_BALLOON_S_MAJFLT];
35+ info->has_major_page_faults = info->major_page_faults >= 0 ? true : false;
36+
37+ info->minor_page_faults = dev->stats[VIRTIO_BALLOON_S_MINFLT];
38+ info->has_minor_page_faults = info->minor_page_faults >= 0 ? true : false;
39+
40+ info->free_mem = dev->stats[VIRTIO_BALLOON_S_MEMFREE];
41+ info->has_free_mem = info->free_mem >= 0 ? true : false;
42 }
43
44 static void virtio_balloon_to_target(void *opaque, ram_addr_t target)
45Index: new/qapi-schema.json
46===================================================================
47--- new.orig/qapi-schema.json 2012-12-17 08:19:30.000000000 +0100
48+++ new/qapi-schema.json 2012-12-17 08:35:55.000000000 +0100
49@@ -1044,6 +1044,8 @@
50 #
51 # @actual: the number of bytes the balloon currently contains
52 #
53+# @last_update: #optional time when stats got updated from guest
54+#
55 # @mem_swapped_in: #optional number of pages swapped in within the guest
56 #
57 # @mem_swapped_out: #optional number of pages swapped out within the guest
58@@ -1054,18 +1056,15 @@
59 #
60 # @free_mem: #optional amount of memory (in bytes) free in the guest
61 #
62-# @total_mem: #optional amount of memory (in bytes) visible to the guest
63+# @total_mem: amount of memory (in bytes) visible to the guest
64 #
65 # Since: 0.14.0
66-#
67-# Notes: all current versions of QEMU do not fill out optional information in
68-# this structure.
69 ##
70 { 'type': 'BalloonInfo',
71- 'data': {'actual': 'int', '*mem_swapped_in': 'int',
72+ 'data': {'actual': 'int', '*last_update': 'int', '*mem_swapped_in': 'int',
73 '*mem_swapped_out': 'int', '*major_page_faults': 'int',
74 '*minor_page_faults': 'int', '*free_mem': 'int',
75- '*total_mem': 'int'} }
76+ 'total_mem': 'int'} }
77
78 ##
79 # @query-balloon:
80Index: new/hmp.c
81===================================================================
82--- new.orig/hmp.c 2012-12-17 08:36:51.000000000 +0100
83+++ new/hmp.c 2012-12-17 09:06:15.000000000 +0100
84@@ -497,6 +497,11 @@
85 }
86
87 monitor_printf(mon, "balloon: actual=%" PRId64, info->actual >> 20);
88+ monitor_printf(mon, " total_mem=%" PRId64, info->total_mem >> 20);
89+ if (info->has_free_mem) {
90+ monitor_printf(mon, " free_mem=%" PRId64, info->free_mem >> 20);
91+ }
92+
93 if (info->has_mem_swapped_in) {
94 monitor_printf(mon, " mem_swapped_in=%" PRId64, info->mem_swapped_in);
95 }
96@@ -511,11 +516,9 @@
97 monitor_printf(mon, " minor_page_faults=%" PRId64,
98 info->minor_page_faults);
99 }
100- if (info->has_free_mem) {
101- monitor_printf(mon, " free_mem=%" PRId64, info->free_mem);
102- }
103- if (info->has_total_mem) {
104- monitor_printf(mon, " total_mem=%" PRId64, info->total_mem);
105+ if (info->has_last_update) {
106+ monitor_printf(mon, " last_update=%" PRId64,
107+ info->last_update);
108 }
109
110 monitor_printf(mon, "\n");