From: Hyman Huang(黄勇) <yong.huang@xxxxxxxxxx> Introduce the virDomainCancelVcpuDirtyLimit API to cancel the upper limit of dirty page rate. Signed-off-by: Hyman Huang(黄勇) <yong.huang@xxxxxxxxxx> --- include/libvirt/libvirt-domain.h | 4 +++ src/driver-hypervisor.h | 6 ++++ src/libvirt-domain.c | 52 ++++++++++++++++++++++++++++++++ src/libvirt_public.syms | 1 + src/remote/remote_driver.c | 1 + src/remote/remote_protocol.x | 13 +++++++- src/remote_protocol-structs | 6 ++++ 7 files changed, 82 insertions(+), 1 deletion(-) diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h index 4c63d0be7c..ddc4339c7e 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -6524,4 +6524,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 e61b9efca5..4cfd9d1cdc 100644 --- a/src/driver-hypervisor.h +++ b/src/driver-hypervisor.h @@ -1454,6 +1454,11 @@ typedef int unsigned long long rate, unsigned int flags); +typedef int +(*virDrvDomainCancelVcpuDirtyLimit)(virDomainPtr domain, + int vcpu, + unsigned int flags); + typedef struct _virHypervisorDriver virHypervisorDriver; /** @@ -1727,4 +1732,5 @@ struct _virHypervisorDriver { virDrvDomainStartDirtyRateCalc domainStartDirtyRateCalc; virDrvDomainFDAssociate domainFDAssociate; virDrvDomainSetVcpuDirtyLimit domainSetVcpuDirtyLimit; + virDrvDomainCancelVcpuDirtyLimit domainCancelVcpuDirtyLimit; }; diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index 878d2a6d8c..f122775248 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -14113,3 +14113,55 @@ virDomainSetVcpuDirtyLimit(virDomainPtr domain, virDispatchError(domain->conn); return -1; } + +/** + * virDomainCancelVcpuDirtyLimit: + * + * @domain: pointer to domain object + * @vcpu: mandatory parameter only if the specified index of the + * virtual CPU is cancelled; ignored otherwise. + * @flags: bitwise-OR of supported virDomainDirtyLimitFlags + * + * Dynamically cancel the dirty page rate upper limit of the virtual CPUs. + * + * Returns 0 in case of success, -1 in case of failure. + * + * Since: 9.6.0 + */ +int +virDomainCancelVcpuDirtyLimit(virDomainPtr domain, + int vcpu, + unsigned int flags) +{ + virConnectPtr conn; + + VIR_DOMAIN_DEBUG(domain, "cancel vcpu[%d] dirty page rate limit", vcpu); + + virCheckFlags(VIR_DOMAIN_DIRTYLIMIT_VCPU | + VIR_DOMAIN_DIRTYLIMIT_ALL, -1); + + virResetLastError(); + + virCheckDomainReturn(domain, -1); + conn = domain->conn; + + virCheckReadOnlyGoto(conn->flags, error); + + VIR_EXCLUSIVE_FLAGS_GOTO(VIR_DOMAIN_DIRTYLIMIT_VCPU, + VIR_DOMAIN_DIRTYLIMIT_ALL, + 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 6fc01b518f..a6a7980cbc 100644 --- a/src/libvirt_public.syms +++ b/src/libvirt_public.syms @@ -935,6 +935,7 @@ LIBVIRT_9.0.0 { LIBVIRT_9.6.0 { global: virDomainSetVcpuDirtyLimit; + virDomainCancelVcpuDirtyLimit; } LIBVIRT_9.0.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 c03e9e862b..4782de395f 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -8129,6 +8129,7 @@ static virHypervisorDriver hypervisor_driver = { .domainSetLaunchSecurityState = remoteDomainSetLaunchSecurityState, /* 8.0.0 */ .domainFDAssociate = remoteDomainFDAssociate, /* 9.0.0 */ .domainSetVcpuDirtyLimit = remoteDomainSetVcpuDirtyLimit, /* 9.6.0 */ + .domainCancelVcpuDirtyLimit = remoteDomainCancelVcpuDirtyLimit, /* 9.6.0 */ }; static virNetworkDriver network_driver = { diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x index 633b9af74e..49f0b44e34 100644 --- a/src/remote/remote_protocol.x +++ b/src/remote/remote_protocol.x @@ -3945,6 +3945,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. */ @@ -6989,5 +6995,10 @@ enum remote_procedure { * @generate: both * @acl: domain:write */ - REMOTE_PROC_DOMAIN_SET_VCPU_DIRTY_LIMIT = 444 + REMOTE_PROC_DOMAIN_SET_VCPU_DIRTY_LIMIT = 444, + /** + * @generate: both + * @acl: domain:write + */ + REMOTE_PROC_DOMAIN_CANCEL_VCPU_DIRTY_LIMIT = 445 }; diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs index f7543ec667..29963a8ab5 100644 --- a/src/remote_protocol-structs +++ b/src/remote_protocol-structs @@ -3279,6 +3279,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, @@ -3724,4 +3729,5 @@ enum remote_procedure { REMOTE_PROC_DOMAIN_ABORT_JOB_FLAGS = 442, REMOTE_PROC_DOMAIN_FD_ASSOCIATE = 443, REMOTE_PROC_DOMAIN_SET_VCPU_DIRTY_LIMIT = 444, + REMOTE_PROC_DOMAIN_CANCEL_VCPU_DIRTY_LIMIT = 445, }; -- 2.38.5