]>
Commit | Line | Data |
---|---|---|
23102ed6 | 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 |
95259824 | 2 | From: Wolfgang Bumiller <w.bumiller@proxmox.com> |
83faa3fe TL |
3 | Date: Mon, 6 Apr 2020 12:16:43 +0200 |
4 | Subject: [PATCH] PVE: virtio-balloon: improve query-balloon | |
95259824 WB |
5 | |
6 | Actually provide memory information via the query-balloon | |
7 | command. | |
b855dce7 TL |
8 | |
9 | Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com> | |
bf251437 FE |
10 | [FE: add BalloonInfo to member name exceptions list |
11 | rebase for 8.0 - moved to hw/core/machine-hmp-cmds.c] | |
271ac0a8 | 12 | Signed-off-by: Fiona Ebner <f.ebner@proxmox.com> |
95259824 | 13 | --- |
bf251437 | 14 | hw/core/machine-hmp-cmds.c | 30 +++++++++++++++++++++++++++++- |
95259824 | 15 | hw/virtio/virtio-balloon.c | 33 +++++++++++++++++++++++++++++++-- |
817b7667 | 16 | qapi/machine.json | 22 +++++++++++++++++++++- |
271ac0a8 FE |
17 | qapi/pragma.json | 1 + |
18 | 4 files changed, 82 insertions(+), 4 deletions(-) | |
95259824 | 19 | |
bf251437 FE |
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 | } | |
95259824 | 61 | diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c |
bf251437 | 62 | index 746f07c4d2..a41854b902 100644 |
95259824 WB |
63 | --- a/hw/virtio/virtio-balloon.c |
64 | +++ b/hw/virtio/virtio-balloon.c | |
bf251437 | 65 | @@ -804,8 +804,37 @@ static uint64_t virtio_balloon_get_features(VirtIODevice *vdev, uint64_t f, |
95259824 WB |
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) | |
817b7667 | 105 | diff --git a/qapi/machine.json b/qapi/machine.json |
bf251437 | 106 | index 604b686e59..15f5f86683 100644 |
817b7667 SR |
107 | --- a/qapi/machine.json |
108 | +++ b/qapi/machine.json | |
bf251437 | 109 | @@ -1056,9 +1056,29 @@ |
817b7667 SR |
110 | # @actual: the logical size of the VM in bytes |
111 | # Formula used: logical_vm_size = vm_ram_size - balloon_size | |
95259824 | 112 | # |
a544966d | 113 | +# @last_update: time when stats got updated from guest |
95259824 | 114 | +# |
a544966d | 115 | +# @mem_swapped_in: number of pages swapped in within the guest |
95259824 | 116 | +# |
a544966d | 117 | +# @mem_swapped_out: number of pages swapped out within the guest |
95259824 | 118 | +# |
a544966d | 119 | +# @major_page_faults: number of major page faults within the guest |
6838f038 | 120 | +# |
a544966d | 121 | +# @minor_page_faults: number of minor page faults within the guest |
95259824 | 122 | +# |
a544966d | 123 | +# @free_mem: amount of memory (in bytes) free in the guest |
95259824 | 124 | +# |
a544966d | 125 | +# @total_mem: amount of memory (in bytes) visible to the guest |
95259824 WB |
126 | +# |
127 | +# @max_mem: amount of memory (in bytes) assigned to the guest | |
6838f038 | 128 | +# |
8dca018b | 129 | # Since: 0.14 |
95259824 WB |
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: | |
271ac0a8 FE |
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 |