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