]> git.proxmox.com Git - pve-qemu-kvm.git/blob - debian/patches/pve/0006-virtio-balloon-fix-query.patch
bump version to 2.9.0-1~rc2+5
[pve-qemu-kvm.git] / debian / patches / pve / 0006-virtio-balloon-fix-query.patch
1 From 5921bc0360f6964a5bb5355c2707c806425f4734 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 06/48] virtio-balloon: fix query
5
6 Actually provide memory information via the query-balloon
7 command.
8 ---
9 hmp.c | 30 +++++++++++++++++++++++++++++-
10 hw/virtio/virtio-balloon.c | 33 +++++++++++++++++++++++++++++++--
11 qapi-schema.json | 23 +++++++++++++++++++++--
12 3 files changed, 81 insertions(+), 5 deletions(-)
13
14 diff --git a/hmp.c b/hmp.c
15 index edb8970..904542d 100644
16 --- a/hmp.c
17 +++ b/hmp.c
18 @@ -723,7 +723,35 @@ void hmp_info_balloon(Monitor *mon, const QDict *qdict)
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 }
55 diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c
56 index a705e0e..158e13e 100644
57 --- a/hw/virtio/virtio-balloon.c
58 +++ b/hw/virtio/virtio-balloon.c
59 @@ -379,8 +379,37 @@ static uint64_t virtio_balloon_get_features(VirtIODevice *vdev, uint64_t f,
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)
99 diff --git a/qapi-schema.json b/qapi-schema.json
100 index b921994..e7a8117 100644
101 --- a/qapi-schema.json
102 +++ b/qapi-schema.json
103 @@ -1900,10 +1900,29 @@
104 #
105 # @actual: the number of bytes the balloon currently contains
106 #
107 -# Since: 0.14.0
108 +# @last_update: time when stats got updated from guest
109 +#
110 +# @mem_swapped_in: number of pages swapped in within the guest
111 +#
112 +# @mem_swapped_out: number of pages swapped out within the guest
113 +#
114 +# @major_page_faults: number of major page faults within the guest
115 #
116 +# @minor_page_faults: number of minor page faults within the guest
117 +#
118 +# @free_mem: amount of memory (in bytes) free in the guest
119 +#
120 +# @total_mem: amount of memory (in bytes) visible to the guest
121 +#
122 +# @max_mem: amount of memory (in bytes) assigned to the guest
123 +#
124 +# Since: 0.14.0
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:
135 --
136 2.1.4
137