]> Git Repo - qemu.git/blame - docs/interop/virtio-balloon-stats.rst
works with less than base ISA qemu-system-riscv32 -M virt -bios none -kernel output...
[qemu.git] / docs / interop / virtio-balloon-stats.rst
CommitLineData
14dc58e3 1Virtio balloon memory statistics
045a7085
LC
2================================
3
4The virtio balloon driver supports guest memory statistics reporting. These
5statistics are available to QEMU users as QOM (QEMU Object Model) device
6properties via a polling mechanism.
7
8Before querying the available stats, clients first have to enable polling.
9This is done by writing a time interval value (in seconds) to the
10guest-stats-polling-interval property. This value can be:
11
14dc58e3
TH
12 > 0
13 enables polling in the specified interval. If polling is already
045a7085
LC
14 enabled, the polling time interval is changed to the new value
15
14dc58e3
TH
16 0
17 disables polling. Previous polled statistics are still valid and
045a7085
LC
18 can be queried.
19
20Once polling is enabled, the virtio-balloon device in QEMU will start
21polling the guest's balloon driver for new stats in the specified time
22interval.
23
24To retrieve those stats, clients have to query the guest-stats property,
25which will return a dictionary containing:
26
14dc58e3 27 * A key named 'stats', containing all available stats. If the guest
045a7085
LC
28 doesn't support a particular stat, or if it couldn't be retrieved,
29 its value will be -1. Currently, the following stats are supported:
30
31 - stat-swap-in
32 - stat-swap-out
33 - stat-major-faults
34 - stat-minor-faults
35 - stat-free-memory
36 - stat-total-memory
c5e93164
TG
37 - stat-available-memory
38 - stat-disk-caches
b7b12644
JH
39 - stat-htlb-pgalloc
40 - stat-htlb-pgfail
045a7085 41
14dc58e3 42 * A key named last-update, which contains the last stats update
045a7085 43 timestamp in seconds. Since this timestamp is generated by the host,
38dbd48b
JT
44 a buggy guest can't influence its value. The value is 0 if the guest
45 has not updated the stats (yet).
045a7085
LC
46
47It's also important to note the following:
48
49 - Previously polled statistics remain available even if the polling is
50 later disabled
51
52 - As noted above, if a guest doesn't support a particular stat its value
53 will always be -1. However, it's also possible that a guest temporarily
54 couldn't update one or even all stats. If this happens, just wait for
55 the next update
56
57 - Polling can be enabled even if the guest doesn't have stats support
58 or the balloon driver wasn't loaded in the guest. If this is the case
38dbd48b 59 and stats are queried, last-update will be 0.
045a7085
LC
60
61 - The polling timer is only re-armed when the guest responds to the
62 statistics request. This means that if a (buggy) guest doesn't ever
63 respond to the request the timer will never be re-armed, which has
64 the same effect as disabling polling
65
14dc58e3
TH
66Here are a few examples. QEMU is started with ``-device virtio-balloon``,
67which generates ``/machine/peripheral-anon/device[1]`` as the QOM path for
1d9cb42c 68the balloon device.
045a7085 69
14dc58e3 70Enable polling with 2 seconds interval::
045a7085 71
14dc58e3
TH
72 { "execute": "qom-set",
73 "arguments": { "path": "/machine/peripheral-anon/device[1]",
74 "property": "guest-stats-polling-interval", "value": 2 } }
045a7085 75
14dc58e3 76 { "return": {} }
045a7085 77
14dc58e3 78Change polling to 10 seconds::
045a7085 79
14dc58e3
TH
80 { "execute": "qom-set",
81 "arguments": { "path": "/machine/peripheral-anon/device[1]",
82 "property": "guest-stats-polling-interval", "value": 10 } }
045a7085 83
14dc58e3 84 { "return": {} }
045a7085 85
14dc58e3 86Get stats::
045a7085 87
14dc58e3
TH
88 { "execute": "qom-get",
89 "arguments": { "path": "/machine/peripheral-anon/device[1]",
90 "property": "guest-stats" } }
91 {
045a7085
LC
92 "return": {
93 "stats": {
94 "stat-swap-out": 0,
95 "stat-free-memory": 844943360,
96 "stat-minor-faults": 219028,
97 "stat-major-faults": 235,
98 "stat-total-memory": 1044406272,
99 "stat-swap-in": 0
100 },
101 "last-update": 1358529861
102 }
14dc58e3 103 }
045a7085 104
14dc58e3 105Disable polling::
045a7085 106
14dc58e3
TH
107 { "execute": "qom-set",
108 "arguments": { "path": "/machine/peripheral-anon/device[1]",
109 "property": "stats-polling-interval", "value": 0 } }
045a7085 110
14dc58e3 111 { "return": {} }
This page took 0.421749 seconds and 4 git commands to generate.