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@xxxxxxxxxx/ 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 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 Hao Wang (8): migration/dirtyrate: Introduce virDomainDirtyRateInfo structure migration/dirtyrate: Implement qemuMonitorJSONExtractDirtyRateInfo migration/dirtyrate: Introduce dirty_rate async job migration/dirtyrate: Implement qemuDomainQueryDirtyRate migration/dirtyrate: Implement qemuDomainCalculateDirtyRate migration/dirtyrate: Introduce virDomainDirtyRateFlags migration/dirtyrate: Introduce DomainGetDirtyRateInfo API migration/dirtyrate: Introduce getdirtyrate virsh api include/libvirt/libvirt-domain.h | 65 ++++++++++++++++++ src/driver-hypervisor.h | 7 ++ src/libvirt-domain.c | 46 +++++++++++++ src/libvirt_public.syms | 5 ++ src/qemu/qemu_domainjob.c | 3 + src/qemu/qemu_domainjob.h | 1 + src/qemu/qemu_driver.c | 76 +++++++++++++++++++++ src/qemu/qemu_migration.c | 63 +++++++++++++++++ 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/qemu/qemu_process.c | 3 + src/remote/remote_driver.c | 1 + src/remote/remote_protocol.x | 21 +++++- tools/virsh-domain.c | 113 +++++++++++++++++++++++++++++++ 17 files changed, 550 insertions(+), 1 deletion(-) -- 2.23.0