]>
Commit | Line | Data |
---|---|---|
1c66df30 AD |
1 | diff --git a/hmp.c b/hmp.c |
2 | index c16af53..8847c8f 100644 | |
3 | --- a/hmp.c | |
4 | +++ b/hmp.c | |
5 | @@ -497,7 +497,35 @@ void hmp_info_balloon(Monitor *mon, const QDict *qdict) | |
6 | return; | |
7 | } | |
efc05ce5 | 8 | |
1c66df30 AD |
9 | - monitor_printf(mon, "balloon: actual=%" PRId64 "\n", info->actual >> 20); |
10 | + monitor_printf(mon, "balloon: actual=%" PRId64, info->actual >> 20); | |
11 | + monitor_printf(mon, " max_mem=%" PRId64, info->max_mem >> 20); | |
12 | + if (info->has_total_mem) { | |
13 | + monitor_printf(mon, " total_mem=%" PRId64, info->total_mem >> 20); | |
14 | + } | |
15 | + if (info->has_free_mem) { | |
16 | + monitor_printf(mon, " free_mem=%" PRId64, info->free_mem >> 20); | |
17 | + } | |
18 | + | |
19 | + if (info->has_mem_swapped_in) { | |
20 | + monitor_printf(mon, " mem_swapped_in=%" PRId64, info->mem_swapped_in); | |
21 | + } | |
22 | + if (info->has_mem_swapped_out) { | |
23 | + monitor_printf(mon, " mem_swapped_out=%" PRId64, info->mem_swapped_out); | |
24 | + } | |
25 | + if (info->has_major_page_faults) { | |
26 | + monitor_printf(mon, " major_page_faults=%" PRId64, | |
27 | + info->major_page_faults); | |
28 | + } | |
29 | + if (info->has_minor_page_faults) { | |
30 | + monitor_printf(mon, " minor_page_faults=%" PRId64, | |
31 | + info->minor_page_faults); | |
32 | + } | |
33 | + if (info->has_last_update) { | |
34 | + monitor_printf(mon, " last_update=%" PRId64, | |
35 | + info->last_update); | |
36 | + } | |
37 | + | |
38 | + monitor_printf(mon, "\n"); | |
39 | ||
40 | qapi_free_BalloonInfo(info); | |
41 | } | |
42 | diff --git a/hw/virtio-balloon.c b/hw/virtio-balloon.c | |
43 | index c0a7902..ba89a27 100644 | |
44 | --- a/hw/virtio-balloon.c | |
45 | +++ b/hw/virtio-balloon.c | |
46 | @@ -306,6 +306,35 @@ static void virtio_balloon_stat(void *opaque, BalloonInfo *info) | |
efc05ce5 DM |
47 | VirtIOBalloon *dev = opaque; |
48 | info->actual = ram_size - ((uint64_t) dev->actual << | |
49 | VIRTIO_BALLOON_PFN_SHIFT); | |
50 | + | |
53ba79ec | 51 | + info->max_mem = ram_size; |
efc05ce5 | 52 | + |
53ba79ec | 53 | + if (!(balloon_stats_enabled(dev) && balloon_stats_supported(dev) && |
1c66df30 AD |
54 | + dev->stats_last_update)) { |
55 | + return; | |
efc05ce5 DM |
56 | + } |
57 | + | |
58 | + info->last_update = dev->stats_last_update; | |
59 | + info->has_last_update = true; | |
60 | + | |
61 | + info->mem_swapped_in = dev->stats[VIRTIO_BALLOON_S_SWAP_IN]; | |
62 | + info->has_mem_swapped_in = info->mem_swapped_in >= 0 ? true : false; | |
63 | + | |
64 | + info->mem_swapped_out = dev->stats[VIRTIO_BALLOON_S_SWAP_OUT]; | |
65 | + info->has_mem_swapped_out = info->mem_swapped_out >= 0 ? true : false; | |
66 | + | |
67 | + info->major_page_faults = dev->stats[VIRTIO_BALLOON_S_MAJFLT]; | |
68 | + info->has_major_page_faults = info->major_page_faults >= 0 ? true : false; | |
69 | + | |
70 | + info->minor_page_faults = dev->stats[VIRTIO_BALLOON_S_MINFLT]; | |
71 | + info->has_minor_page_faults = info->minor_page_faults >= 0 ? true : false; | |
72 | + | |
73 | + info->free_mem = dev->stats[VIRTIO_BALLOON_S_MEMFREE]; | |
74 | + info->has_free_mem = info->free_mem >= 0 ? true : false; | |
53ba79ec DM |
75 | + |
76 | + info->total_mem = dev->stats[VIRTIO_BALLOON_S_MEMTOT]; | |
77 | + info->has_total_mem = info->total_mem >= 0 ? true : false; | |
1c66df30 | 78 | + |
efc05ce5 DM |
79 | } |
80 | ||
81 | static void virtio_balloon_to_target(void *opaque, ram_addr_t target) | |
1c66df30 AD |
82 | diff --git a/qapi-schema.json b/qapi-schema.json |
83 | index eb5704b..6f76e62 100644 | |
84 | --- a/qapi-schema.json | |
85 | +++ b/qapi-schema.json | |
86 | @@ -1108,15 +1108,34 @@ | |
87 | ||
88 | ## | |
89 | # @BalloonInfo: | |
90 | -# | |
91 | +# | |
92 | # Information about the guest balloon device. | |
efc05ce5 DM |
93 | # |
94 | # @actual: the number of bytes the balloon currently contains | |
95 | # | |
1c66df30 | 96 | -# Since: 0.14.0 |
efc05ce5 DM |
97 | +# @last_update: #optional time when stats got updated from guest |
98 | +# | |
1c66df30 AD |
99 | +# @mem_swapped_in: #optional number of pages swapped in within the guest |
100 | +# | |
101 | +# @mem_swapped_out: #optional number of pages swapped out within the guest | |
102 | +# | |
103 | +# @major_page_faults: #optional number of major page faults within the guest | |
efc05ce5 | 104 | # |
1c66df30 AD |
105 | +# @minor_page_faults: #optional number of minor page faults within the guest |
106 | +# | |
107 | +# @free_mem: #optional amount of memory (in bytes) free in the guest | |
108 | +# | |
109 | +# @total_mem: #optional amount of memory (in bytes) visible to the guest | |
110 | +# | |
53ba79ec | 111 | +# @max_mem: amount of memory (in bytes) assigned to the guest |
1c66df30 | 112 | +# |
53ba79ec | 113 | +# Since: 0.14.0 |
efc05ce5 | 114 | ## |
1c66df30 AD |
115 | -{ 'type': 'BalloonInfo', 'data': {'actual': 'int' } } |
116 | +{ 'type': 'BalloonInfo', | |
efc05ce5 | 117 | + 'data': {'actual': 'int', '*last_update': 'int', '*mem_swapped_in': 'int', |
1c66df30 AD |
118 | + '*mem_swapped_out': 'int', '*major_page_faults': 'int', |
119 | + '*minor_page_faults': 'int', '*free_mem': 'int', | |
53ba79ec | 120 | + '*total_mem': 'int', 'max_mem': 'int', } } |
efc05ce5 DM |
121 | |
122 | ## | |
123 | # @query-balloon: | |
1c66df30 AD |
124 | diff --git a/qmp-commands.hx b/qmp-commands.hx |
125 | index f937db7..71c9070 100644 | |
126 | --- a/qmp-commands.hx | |
127 | +++ b/qmp-commands.hx | |
128 | @@ -2649,6 +2649,13 @@ Make an asynchronous request for balloon info. When the request completes a | |
129 | json-object will be returned containing the following data: | |
efc05ce5 | 130 | |
1c66df30 AD |
131 | - "actual": current balloon value in bytes (json-int) |
132 | +- "mem_swapped_in": Amount of memory swapped in bytes (json-int, optional) | |
133 | +- "mem_swapped_out": Amount of memory swapped out in bytes (json-int, optional) | |
134 | +- "major_page_faults": Number of major faults (json-int, optional) | |
135 | +- "minor_page_faults": Number of minor faults (json-int, optional) | |
136 | +- "free_mem": Total amount of free and unused memory in | |
137 | + bytes (json-int, optional) | |
138 | +- "total_mem": Total amount of available memory in bytes (json-int, optional) | |
139 | ||
140 | Example: | |
141 | ||
142 | @@ -2656,6 +2663,12 @@ Example: | |
143 | <- { | |
144 | "return":{ | |
145 | "actual":1073741824, | |
146 | + "mem_swapped_in":0, | |
147 | + "mem_swapped_out":0, | |
148 | + "major_page_faults":142, | |
149 | + "minor_page_faults":239245, | |
150 | + "free_mem":1014185984, | |
151 | + "total_mem":1044668416 | |
152 | } | |
153 | } | |
efc05ce5 | 154 |