From: Hyman Huang(黄勇) <huangy81@xxxxxxxxxxxxxxx> Introduce virDomainCancelVcpuDirtyLimit API to cancel upper limit of dirty page rate. Signed-off-by: Hyman Huang(黄勇) <huangy81@xxxxxxxxxxxxxxx> --- include/libvirt/libvirt-domain.h | 4 ++++ src/driver-hypervisor.h | 6 ++++++ src/libvirt-domain.c | 43 ++++++++++++++++++++++++++++++++++++++++ src/libvirt_public.syms | 1 + src/remote/remote_driver.c | 1 + src/remote/remote_protocol.x | 14 ++++++++++++- src/remote_protocol-structs | 6 ++++++ 7 files changed, 74 insertions(+), 1 deletion(-) diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h index 24348d0..cc48615 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -6470,4 +6470,8 @@ int virDomainSetVcpuDirtyLimit(virDomainPtr domain, int vcpu, unsigned long long rate, unsigned int flags); + +int virDomainCancelVcpuDirtyLimit(virDomainPtr domain, + int vcpu, + unsigned int flags); #endif /* LIBVIRT_DOMAIN_H */ diff --git a/src/driver-hypervisor.h b/src/driver-hypervisor.h index ac59da6..2b14d33 100644 --- a/src/driver-hypervisor.h +++ b/src/driver-hypervisor.h @@ -1447,6 +1447,11 @@ typedef int unsigned long long rate, unsigned int flags); +typedef int +(*virDrvDomainCancelVcpuDirtyLimit)(virDomainPtr domain, + int vcpu, + unsigned int flags); + typedef struct _virHypervisorDriver virHypervisorDriver; /** @@ -1719,4 +1724,5 @@ struct _virHypervisorDriver { virDrvDomainGetMessages domainGetMessages; virDrvDomainStartDirtyRateCalc domainStartDirtyRateCalc; virDrvDomainSetVcpuDirtyLimit domainSetVcpuDirtyLimit; + virDrvDomainCancelVcpuDirtyLimit domainCancelVcpuDirtyLimit; }; diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index be9825b..27a8bb6 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -13980,3 +13980,46 @@ virDomainSetVcpuDirtyLimit(virDomainPtr domain, virDispatchError(domain->conn); return -1; } + +/** + * virDomainCancelVcpuDirtyLimit: + * @domain: pointer to domain object, or NULL for Domain0 + * @vcpu: virtual CPU number + * @flags: bitwise-OR of supported virDomainDirtyLimitFlags + * + * Dynamically cancel the upper dirty page rate limit of the virtual CPUs. + * + * Returns 0 in case of success, -1 in case of failure. + * + * Since: 8.7.0 + */ +int +virDomainCancelVcpuDirtyLimit(virDomainPtr domain, + int vcpu, + unsigned int flags) +{ + virConnectPtr conn; + + VIR_DOMAIN_DEBUG(domain, "cancel vcpu[%d] dirty page rate limit", vcpu); + + virResetLastError(); + + virCheckDomainReturn(domain, -1); + conn = domain->conn; + + virCheckReadOnlyGoto(conn->flags, error); + + if (conn->driver->domainCancelVcpuDirtyLimit) { + int ret; + ret = conn->driver->domainCancelVcpuDirtyLimit(domain, vcpu, flags); + if (ret < 0) + goto error; + return ret; + } + + virReportUnsupportedError(); + + error: + virDispatchError(domain->conn); + return -1; +} diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms index 8ebcf50..d7556f7 100644 --- a/src/libvirt_public.syms +++ b/src/libvirt_public.syms @@ -930,6 +930,7 @@ LIBVIRT_8.5.0 { LIBVIRT_8.7.0 { global: virDomainSetVcpuDirtyLimit; + virDomainCancelVcpuDirtyLimit; } LIBVIRT_8.5.0; # .... define new API here using predicted next version number .... diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 5fc1a61..bdda2aa 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -8655,6 +8655,7 @@ static virHypervisorDriver hypervisor_driver = { .domainStartDirtyRateCalc = remoteDomainStartDirtyRateCalc, /* 7.2.0 */ .domainSetLaunchSecurityState = remoteDomainSetLaunchSecurityState, /* 8.0.0 */ .domainSetVcpuDirtyLimit = remoteDomainSetVcpuDirtyLimit, /* 8.7.0 */ + .domainCancelVcpuDirtyLimit = remoteDomainCancelVcpuDirtyLimit, /* 8.7.0 */ }; static virNetworkDriver network_driver = { diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x index 874ce19..3a898d0 100644 --- a/src/remote/remote_protocol.x +++ b/src/remote/remote_protocol.x @@ -3937,6 +3937,12 @@ struct remote_domain_set_vcpu_dirty_limit_args { unsigned int flags; }; +struct remote_domain_cancel_vcpu_dirty_limit_args { + remote_nonnull_domain dom; + int vcpu; + unsigned int flags; +}; + /*----- Protocol. -----*/ /* Define the program number, protocol version and procedure numbers here. */ @@ -6973,5 +6979,11 @@ enum remote_procedure { * @generate: both * @acl: domain:write */ - REMOTE_PROC_DOMAIN_SET_VCPU_DIRTY_LIMIT = 443 + REMOTE_PROC_DOMAIN_SET_VCPU_DIRTY_LIMIT = 443, + + /** + * @generate: both + * @acl: domain:write + */ + REMOTE_PROC_DOMAIN_CANCEL_VCPU_DIRTY_LIMIT = 444 }; diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs index 8ff2a86..c615c87 100644 --- a/src/remote_protocol-structs +++ b/src/remote_protocol-structs @@ -3274,6 +3274,11 @@ struct remote_domain_set_vcpu_dirty_limit_args { uint64_t rate; u_int flags; }; +struct remote_domain_cancel_vcpu_dirty_limit_args { + remote_nonnull_domain dom; + int vcpu; + u_int flags; +}; enum remote_procedure { REMOTE_PROC_CONNECT_OPEN = 1, REMOTE_PROC_CONNECT_CLOSE = 2, @@ -3718,4 +3723,5 @@ enum remote_procedure { REMOTE_PROC_DOMAIN_RESTORE_PARAMS = 441, REMOTE_PROC_DOMAIN_ABORT_JOB_FLAGS = 442, REMOTE_PROC_DOMAIN_SET_VCPU_DIRTY_LIMIT = 443, + REMOTE_PROC_DOMAIN_SET_VCPU_DIRTY_LIMIT = 444, }; -- 1.8.3.1