migration/dirtyrate: Introduce command 'virsh domstats --dirtyrate'

Introduce command 'virsh domstats --dirtyrate' for reporting memory
dirty rate information. The info is listed as:

Domain: 'vm0'
  dirtyrate.calc_status=2
  dirtyrate.calc_start_time=1534523
  dirtyrate.calc_period=1
  dirtyrate.megabytes_per_second=5

Signed-off-by: Hao Wang <wanghao232@huawei.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Hao Wang 2021-03-16 20:32:51 +08:00 committed by Michal Privoznik
parent fee42ea120
commit 5be6decbb1
2 changed files with 21 additions and 2 deletions

View File

@ -2219,7 +2219,7 @@ domstats
domstats [--raw] [--enforce] [--backing] [--nowait] [--state] domstats [--raw] [--enforce] [--backing] [--nowait] [--state]
[--cpu-total] [--balloon] [--vcpu] [--interface] [--cpu-total] [--balloon] [--vcpu] [--interface]
[--block] [--perf] [--iothread] [--memory] [--block] [--perf] [--iothread] [--memory] [--dirtyrate]
[[--list-active] [--list-inactive] [[--list-active] [--list-inactive]
[--list-persistent] [--list-transient] [--list-running]y [--list-persistent] [--list-transient] [--list-running]y
[--list-paused] [--list-shutoff] [--list-other]] | [domain ...] [--list-paused] [--list-shutoff] [--list-other]] | [domain ...]
@ -2238,7 +2238,8 @@ behavior use the *--raw* flag.
The individual statistics groups are selectable via specific flags. By The individual statistics groups are selectable via specific flags. By
default all supported statistics groups are returned. Supported default all supported statistics groups are returned. Supported
statistics groups flags are: *--state*, *--cpu-total*, *--balloon*, statistics groups flags are: *--state*, *--cpu-total*, *--balloon*,
*--vcpu*, *--interface*, *--block*, *--perf*, *--iothread*, *--memory*. *--vcpu*, *--interface*, *--block*, *--perf*, *--iothread*, *--memory*,
*--dirtyrate*.
Note that - depending on the hypervisor type and version or the domain state Note that - depending on the hypervisor type and version or the domain state
- not all of the following statistics may be returned. - not all of the following statistics may be returned.
@ -2435,6 +2436,17 @@ not available for statistical purposes.
bytes consumed by @vcpus that passing through all memory controllers, either bytes consumed by @vcpus that passing through all memory controllers, either
local or remote controller. local or remote controller.
*--dirtyrate* returns:
* ``dirtyrate.calc_status`` - the status of last memory dirty rate
calculation, returned as number from virDomainDirtyRateStatus enum.
* ``dirtyrate.calc_start_time`` - the start time of last memory dirty
rate calculation.
* ``dirtyrate.calc_period`` - the period of last memory dirty rate
calculation.
* ``dirtyrate.megabytes_per_second`` - the calculated memory dirty
rate in MiB/s.
Selecting a specific statistics groups doesn't guarantee that the Selecting a specific statistics groups doesn't guarantee that the
daemon supports the selected group of stats. Flag *--enforce* daemon supports the selected group of stats. Flag *--enforce*

View File

@ -2148,6 +2148,10 @@ static const vshCmdOptDef opts_domstats[] = {
.type = VSH_OT_BOOL, .type = VSH_OT_BOOL,
.help = N_("report domain memory usage"), .help = N_("report domain memory usage"),
}, },
{.name = "dirtyrate",
.type = VSH_OT_BOOL,
.help = N_("report domain dirty rate information"),
},
{.name = "list-active", {.name = "list-active",
.type = VSH_OT_BOOL, .type = VSH_OT_BOOL,
.help = N_("list only active domains"), .help = N_("list only active domains"),
@ -2267,6 +2271,9 @@ cmdDomstats(vshControl *ctl, const vshCmd *cmd)
if (vshCommandOptBool(cmd, "memory")) if (vshCommandOptBool(cmd, "memory"))
stats |= VIR_DOMAIN_STATS_MEMORY; stats |= VIR_DOMAIN_STATS_MEMORY;
if (vshCommandOptBool(cmd, "dirtyrate"))
stats |= VIR_DOMAIN_STATS_DIRTYRATE;
if (vshCommandOptBool(cmd, "list-active")) if (vshCommandOptBool(cmd, "list-active"))
flags |= VIR_CONNECT_GET_ALL_DOMAINS_STATS_ACTIVE; flags |= VIR_CONNECT_GET_ALL_DOMAINS_STATS_ACTIVE;