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