]> git.proxmox.com Git - pve-qemu.git/blob - debian/patches/pve/0014-PVE-virtio-balloon-improve-query-balloon.patch
bump version to 8.0.2-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: Mon, 6 Apr 2020 12:16:43 +0200
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 [FE: add BalloonInfo to member name exceptions list
11 rebase for 8.0 - moved to hw/core/machine-hmp-cmds.c]
12 Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
13 ---
14 hw/core/machine-hmp-cmds.c | 30 +++++++++++++++++++++++++++++-
15 hw/virtio/virtio-balloon.c | 33 +++++++++++++++++++++++++++++++--
16 qapi/machine.json | 22 +++++++++++++++++++++-
17 qapi/pragma.json | 1 +
18 4 files changed, 82 insertions(+), 4 deletions(-)
19
20 diff --git a/hw/core/machine-hmp-cmds.c b/hw/core/machine-hmp-cmds.c
21 index c3e55ef9e9..0e32e6201f 100644
22 --- a/hw/core/machine-hmp-cmds.c
23 +++ b/hw/core/machine-hmp-cmds.c
24 @@ -169,7 +169,35 @@ void hmp_info_balloon(Monitor *mon, const QDict *qdict)
25 return;
26 }
27
28 - monitor_printf(mon, "balloon: actual=%" PRId64 "\n", info->actual >> 20);
29 + monitor_printf(mon, "balloon: actual=%" PRId64, info->actual >> 20);
30 + monitor_printf(mon, " max_mem=%" PRId64, info->max_mem >> 20);
31 + if (info->has_total_mem) {
32 + monitor_printf(mon, " total_mem=%" PRId64, info->total_mem >> 20);
33 + }
34 + if (info->has_free_mem) {
35 + monitor_printf(mon, " free_mem=%" PRId64, info->free_mem >> 20);
36 + }
37 +
38 + if (info->has_mem_swapped_in) {
39 + monitor_printf(mon, " mem_swapped_in=%" PRId64, info->mem_swapped_in);
40 + }
41 + if (info->has_mem_swapped_out) {
42 + monitor_printf(mon, " mem_swapped_out=%" PRId64, info->mem_swapped_out);
43 + }
44 + if (info->has_major_page_faults) {
45 + monitor_printf(mon, " major_page_faults=%" PRId64,
46 + info->major_page_faults);
47 + }
48 + if (info->has_minor_page_faults) {
49 + monitor_printf(mon, " minor_page_faults=%" PRId64,
50 + info->minor_page_faults);
51 + }
52 + if (info->has_last_update) {
53 + monitor_printf(mon, " last_update=%" PRId64,
54 + info->last_update);
55 + }
56 +
57 + monitor_printf(mon, "\n");
58
59 qapi_free_BalloonInfo(info);
60 }
61 diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c
62 index 746f07c4d2..a41854b902 100644
63 --- a/hw/virtio/virtio-balloon.c
64 +++ b/hw/virtio/virtio-balloon.c
65 @@ -804,8 +804,37 @@ static uint64_t virtio_balloon_get_features(VirtIODevice *vdev, uint64_t f,
66 static void virtio_balloon_stat(void *opaque, BalloonInfo *info)
67 {
68 VirtIOBalloon *dev = opaque;
69 - info->actual = get_current_ram_size() - ((uint64_t) dev->actual <<
70 - VIRTIO_BALLOON_PFN_SHIFT);
71 + ram_addr_t ram_size = get_current_ram_size();
72 + info->actual = ram_size - ((uint64_t) dev->actual <<
73 + VIRTIO_BALLOON_PFN_SHIFT);
74 +
75 + info->max_mem = ram_size;
76 +
77 + if (!(balloon_stats_enabled(dev) && balloon_stats_supported(dev) &&
78 + dev->stats_last_update)) {
79 + return;
80 + }
81 +
82 + info->last_update = dev->stats_last_update;
83 + info->has_last_update = true;
84 +
85 + info->mem_swapped_in = dev->stats[VIRTIO_BALLOON_S_SWAP_IN];
86 + info->has_mem_swapped_in = info->mem_swapped_in >= 0 ? true : false;
87 +
88 + info->mem_swapped_out = dev->stats[VIRTIO_BALLOON_S_SWAP_OUT];
89 + info->has_mem_swapped_out = info->mem_swapped_out >= 0 ? true : false;
90 +
91 + info->major_page_faults = dev->stats[VIRTIO_BALLOON_S_MAJFLT];
92 + info->has_major_page_faults = info->major_page_faults >= 0 ? true : false;
93 +
94 + info->minor_page_faults = dev->stats[VIRTIO_BALLOON_S_MINFLT];
95 + info->has_minor_page_faults = info->minor_page_faults >= 0 ? true : false;
96 +
97 + info->free_mem = dev->stats[VIRTIO_BALLOON_S_MEMFREE];
98 + info->has_free_mem = info->free_mem >= 0 ? true : false;
99 +
100 + info->total_mem = dev->stats[VIRTIO_BALLOON_S_MEMTOT];
101 + info->has_total_mem = info->total_mem >= 0 ? true : false;
102 }
103
104 static void virtio_balloon_to_target(void *opaque, ram_addr_t target)
105 diff --git a/qapi/machine.json b/qapi/machine.json
106 index 604b686e59..15f5f86683 100644
107 --- a/qapi/machine.json
108 +++ b/qapi/machine.json
109 @@ -1056,9 +1056,29 @@
110 # @actual: the logical size of the VM in bytes
111 # Formula used: logical_vm_size = vm_ram_size - balloon_size
112 #
113 +# @last_update: time when stats got updated from guest
114 +#
115 +# @mem_swapped_in: number of pages swapped in within the guest
116 +#
117 +# @mem_swapped_out: number of pages swapped out within the guest
118 +#
119 +# @major_page_faults: number of major page faults within the guest
120 +#
121 +# @minor_page_faults: number of minor page faults within the guest
122 +#
123 +# @free_mem: amount of memory (in bytes) free in the guest
124 +#
125 +# @total_mem: amount of memory (in bytes) visible to the guest
126 +#
127 +# @max_mem: amount of memory (in bytes) assigned to the guest
128 +#
129 # Since: 0.14
130 ##
131 -{ 'struct': 'BalloonInfo', 'data': {'actual': 'int' } }
132 +{ 'struct': 'BalloonInfo',
133 + 'data': {'actual': 'int', '*last_update': 'int', '*mem_swapped_in': 'int',
134 + '*mem_swapped_out': 'int', '*major_page_faults': 'int',
135 + '*minor_page_faults': 'int', '*free_mem': 'int',
136 + '*total_mem': 'int', 'max_mem': 'int' } }
137
138 ##
139 # @query-balloon:
140 diff --git a/qapi/pragma.json b/qapi/pragma.json
141 index 29233db825..f2097b9020 100644
142 --- a/qapi/pragma.json
143 +++ b/qapi/pragma.json
144 @@ -37,6 +37,7 @@
145 'member-name-exceptions': [ # visible in:
146 'ACPISlotType', # query-acpi-ospm-status
147 'AcpiTableOptions', # -acpitable
148 + 'BalloonInfo', # query-balloon
149 'BlkdebugEvent', # blockdev-add, -blockdev
150 'BlkdebugSetStateOptions', # blockdev-add, -blockdev
151 'BlockDeviceInfo', # query-block