On Sat, Nov 7, 2020 at 5:54 PM Hao Wang <wanghao232@huawei.com> wrote:
V3 -> V4:
define flags to unsigned int
fix some compile warnings

V2 -> V3:
reorganize patchset to fix compile warning

V1 -> V2:
replace QEMU_JOB_ASYNC with QEMU_JOB_QUERY


Sometimes domain's memory dirty rate is expected by user in order to
decide whether it's proper to be migrated out or not.

We have already completed the QEMU part of the capability:
https://patchew.org/QEMU/1600237327-33618-1-git-send-email-zhengchuan@huawei.com/
And this serial of patches introduce the corresponding LIBVIRT part --
DomainGetDirtyRateInfo API and corresponding virsh api -- "getdirtyrate".


instructions:
bash# virsh getdirtyrate --help
  NAME
    getdirtyrate - Get a vm's memory dirty rate
I think it is better to name the virsh cmd as 'domgetdirtyrate' or 'domdirtyrate' because
the most of virsh cmds for getting the info of VM have the prefix dom.

  SYNOPSIS
    getdirtyrate <domain> [--seconds <number>] [--calculate] [--query]

  DESCRIPTION
    Get memory dirty rate of a domain in order to decide whether it's proper to be migrated out or not.

  OPTIONS
    [--domain] <string>  domain name, id or uuid
    --seconds <number>  calculate memory dirty rate within specified seconds, a valid range of values is [1, 60], and would default to 1s.
    --calculate      calculate dirty rate only, can be used together with --query, either or both is expected, otherwise would default to both.
    --query          query dirty rate only, can be used together with --calculate, either or both is expected, otherwise would default to both.


example:
bash# virsh getdirtyrate --calculate --query --domain vm0 --seconds 1
status:        measured
startTime:     820148
calcTime:      1 s
dirtyRate:     6 MB/s


*** BLURB HERE ***

Hao Wang (7):
  migration/dirtyrate: Introduce virDomainDirtyRateInfo structure
  migration/dirtyrate: set up framwork of domainGetDirtyRateInfo API
  migration/dirtyrate: Implement qemuDomainCalculateDirtyRate
  migration/dirtyrate: Implement qemuDomainQueryDirtyRate
  migration/dirtyrate: Implement qemuMonitorJSONExtractDirtyRateInfo
  migration/dirtyrate: Implement qemuDomainGetDirtyRateInfo
  migration/dirtyrate: Introduce getdirtyrate virsh api

 include/libvirt/libvirt-domain.h |  57 ++++++++++++++++
 src/driver-hypervisor.h          |   7 ++
 src/libvirt-domain.c             |  46 +++++++++++++
 src/libvirt_public.syms          |   5 ++
 src/qemu/qemu_driver.c           |  68 +++++++++++++++++++
 src/qemu/qemu_migration.c        |  59 ++++++++++++++++
 src/qemu/qemu_migration.h        |  10 +++
 src/qemu/qemu_monitor.c          |  24 +++++++
 src/qemu/qemu_monitor.h          |   8 +++
 src/qemu/qemu_monitor_json.c     |  97 ++++++++++++++++++++++++++
 src/qemu/qemu_monitor_json.h     |   8 +++
 src/remote/remote_driver.c       |   1 +
 src/remote/remote_protocol.x     |  21 +++++-
 tools/virsh-domain.c             | 112 +++++++++++++++++++++++++++++++
 14 files changed, 522 insertions(+), 1 deletion(-)

--
2.23.0