]> git.proxmox.com Git - pve-qemu-kvm.git/blame - debian/patches/virtio-balloon-fix-query.patch
minor fixes for info balloon
[pve-qemu-kvm.git] / debian / patches / virtio-balloon-fix-query.patch
CommitLineData
efc05ce5
DM
1Index: new/hw/virtio-balloon.c
2===================================================================
53ba79ec
DM
3--- new.orig/hw/virtio-balloon.c 2012-12-18 11:40:34.000000000 +0100
4+++ new/hw/virtio-balloon.c 2012-12-18 11:50:57.000000000 +0100
efc05ce5
DM
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",
53ba79ec
DM
14@@ -73,7 +73,7 @@
15 *
16 * This function needs to be called at device intialization and before
17 * before updating to a set of newly-generated stats. This will ensure that no
18- * stale values stick around in case the guest reports a subset of the supported
19+ * stale values stick around in case The guest reports a subset of the supported
20 * statistics.
21 */
22 static inline void reset_stats(VirtIOBalloon *dev)
23@@ -314,6 +314,34 @@
efc05ce5
DM
24 VirtIOBalloon *dev = opaque;
25 info->actual = ram_size - ((uint64_t) dev->actual <<
26 VIRTIO_BALLOON_PFN_SHIFT);
27+
53ba79ec 28+ info->max_mem = ram_size;
efc05ce5 29+
53ba79ec
DM
30+ if (!(balloon_stats_enabled(dev) && balloon_stats_supported(dev) &&
31+ dev->stats_last_update)) {
efc05ce5
DM
32+ return;
33+ }
34+
35+ info->last_update = dev->stats_last_update;
36+ info->has_last_update = true;
37+
38+ info->mem_swapped_in = dev->stats[VIRTIO_BALLOON_S_SWAP_IN];
39+ info->has_mem_swapped_in = info->mem_swapped_in >= 0 ? true : false;
40+
41+ info->mem_swapped_out = dev->stats[VIRTIO_BALLOON_S_SWAP_OUT];
42+ info->has_mem_swapped_out = info->mem_swapped_out >= 0 ? true : false;
43+
44+ info->major_page_faults = dev->stats[VIRTIO_BALLOON_S_MAJFLT];
45+ info->has_major_page_faults = info->major_page_faults >= 0 ? true : false;
46+
47+ info->minor_page_faults = dev->stats[VIRTIO_BALLOON_S_MINFLT];
48+ info->has_minor_page_faults = info->minor_page_faults >= 0 ? true : false;
49+
50+ info->free_mem = dev->stats[VIRTIO_BALLOON_S_MEMFREE];
51+ info->has_free_mem = info->free_mem >= 0 ? true : false;
53ba79ec
DM
52+
53+ info->total_mem = dev->stats[VIRTIO_BALLOON_S_MEMTOT];
54+ info->has_total_mem = info->total_mem >= 0 ? true : false;
efc05ce5
DM
55 }
56
57 static void virtio_balloon_to_target(void *opaque, ram_addr_t target)
58Index: new/qapi-schema.json
59===================================================================
53ba79ec
DM
60--- new.orig/qapi-schema.json 2012-12-18 11:40:34.000000000 +0100
61+++ new/qapi-schema.json 2012-12-18 11:42:06.000000000 +0100
efc05ce5
DM
62@@ -1044,6 +1044,8 @@
63 #
64 # @actual: the number of bytes the balloon currently contains
65 #
66+# @last_update: #optional time when stats got updated from guest
67+#
68 # @mem_swapped_in: #optional number of pages swapped in within the guest
69 #
70 # @mem_swapped_out: #optional number of pages swapped out within the guest
53ba79ec 71@@ -1056,16 +1058,15 @@
efc05ce5 72 #
53ba79ec 73 # @total_mem: #optional amount of memory (in bytes) visible to the guest
efc05ce5 74 #
53ba79ec
DM
75-# Since: 0.14.0
76+# @max_mem: amount of memory (in bytes) assigned to the guest
efc05ce5 77 #
efc05ce5
DM
78-# Notes: all current versions of QEMU do not fill out optional information in
79-# this structure.
53ba79ec 80+# Since: 0.14.0
efc05ce5
DM
81 ##
82 { 'type': 'BalloonInfo',
83- 'data': {'actual': 'int', '*mem_swapped_in': 'int',
84+ 'data': {'actual': 'int', '*last_update': 'int', '*mem_swapped_in': 'int',
85 '*mem_swapped_out': 'int', '*major_page_faults': 'int',
86 '*minor_page_faults': 'int', '*free_mem': 'int',
87- '*total_mem': 'int'} }
53ba79ec 88+ '*total_mem': 'int', 'max_mem': 'int', } }
efc05ce5
DM
89
90 ##
91 # @query-balloon:
92Index: new/hmp.c
93===================================================================
53ba79ec
DM
94--- new.orig/hmp.c 2012-12-18 11:40:34.000000000 +0100
95+++ new/hmp.c 2012-12-18 11:50:32.000000000 +0100
96@@ -497,6 +497,14 @@
efc05ce5
DM
97 }
98
99 monitor_printf(mon, "balloon: actual=%" PRId64, info->actual >> 20);
53ba79ec
DM
100+ monitor_printf(mon, " max_mem=%" PRId64, info->max_mem >> 20);
101+ if (info->has_total_mem) {
102+ monitor_printf(mon, " total_mem=%" PRId64, info->total_mem >> 20);
103+ }
efc05ce5
DM
104+ if (info->has_free_mem) {
105+ monitor_printf(mon, " free_mem=%" PRId64, info->free_mem >> 20);
106+ }
107+
108 if (info->has_mem_swapped_in) {
109 monitor_printf(mon, " mem_swapped_in=%" PRId64, info->mem_swapped_in);
110 }
53ba79ec 111@@ -511,11 +519,9 @@
efc05ce5
DM
112 monitor_printf(mon, " minor_page_faults=%" PRId64,
113 info->minor_page_faults);
114 }
115- if (info->has_free_mem) {
116- monitor_printf(mon, " free_mem=%" PRId64, info->free_mem);
117- }
118- if (info->has_total_mem) {
119- monitor_printf(mon, " total_mem=%" PRId64, info->total_mem);
120+ if (info->has_last_update) {
121+ monitor_printf(mon, " last_update=%" PRId64,
122+ info->last_update);
123 }
124
125 monitor_printf(mon, "\n");