From: Hyman Huang <yong.huang@xxxxxxxxxx> Introduce virDomainSetVcpuTuneParameters API to support tunables of virtual CPUs. Signed-off-by: Hyman Huang <yong.huang@xxxxxxxxxx> --- include/libvirt/libvirt-domain.h | 13 ++++++++ src/driver-hypervisor.h | 8 +++++ src/libvirt-domain.c | 56 ++++++++++++++++++++++++++++++++ src/libvirt_public.syms | 5 +++ src/remote/remote_driver.c | 1 + src/remote/remote_protocol.x | 20 +++++++++++- 6 files changed, 102 insertions(+), 1 deletion(-) diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h index f5420bca6e..ae1e07b7b6 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -6612,4 +6612,17 @@ virDomainGraphicsReload(virDomainPtr domain, unsigned int type, unsigned int flags); +/** + * virDomainSetVcpuTuneParameters: + * + * Set virtual CPU tunables for the domain + * + * Since: 11.1.0 + */ +int +virDomainSetVcpuTuneParameters(virDomainPtr domain, + const char *vcpumap, + virTypedParameterPtr params, + int nparams, + unsigned int flags); #endif /* LIBVIRT_DOMAIN_H */ diff --git a/src/driver-hypervisor.h b/src/driver-hypervisor.h index 4ce8da078d..b8b8d53311 100644 --- a/src/driver-hypervisor.h +++ b/src/driver-hypervisor.h @@ -1453,6 +1453,13 @@ typedef int unsigned int type, unsigned int flags); +typedef int +(*virDrvDomainSetVcpuTuneParameters)(virDomainPtr domain, + const char *vcpumap, + virTypedParameterPtr params, + int nparams, + unsigned int flags); + typedef struct _virHypervisorDriver virHypervisorDriver; /** @@ -1726,4 +1733,5 @@ struct _virHypervisorDriver { virDrvDomainStartDirtyRateCalc domainStartDirtyRateCalc; virDrvDomainFDAssociate domainFDAssociate; virDrvDomainGraphicsReload domainGraphicsReload; + virDrvDomainSetVcpuTuneParameters domainSetVcpuTuneParameters; }; diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index 072cc32255..90d02a2f06 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -14162,3 +14162,59 @@ virDomainGraphicsReload(virDomainPtr domain, virDispatchError(domain->conn); return -1; } + + +/** + * virDomainSetVcpuTuneParameters: + * @domain: pointer to domain object + * @vcpumap: text representation of a bitmap of vcpus to set + * @params: pointer to virtual CPU parameter objects + * @nparams: number of virtual CPU tunable parameter + * @flags: bitwise-OR of virDomainModificationImpact + * + * Change all or a subset of the virtual CPU tunables. + * + * Returns 0 in case of success, -1 in case of failure. + * + * Since: 11.1.0 + */ +int +virDomainSetVcpuTuneParameters(virDomainPtr domain, + const char *vcpumap, + virTypedParameterPtr params, + int nparams, + unsigned int flags) +{ + virConnectPtr conn; + + VIR_DOMAIN_DEBUG(domain, "vcpumap='%s', params=%p, nparams=%d, flags=0x%x", + vcpumap, params, nparams, flags); + + virResetLastError(); + + virCheckDomainReturn(domain, -1); + conn = domain->conn; + + virCheckReadOnlyGoto(conn->flags, error); + virCheckNonNullArgGoto(vcpumap, error); + virCheckNonNullArgGoto(params, error); + virCheckPositiveArgGoto(nparams, error); + + if (virTypedParameterValidateSet(conn, params, nparams) < 0) + goto error; + + if (conn->driver->domainSetVcpuTuneParameters) { + int ret; + ret = conn->driver->domainSetVcpuTuneParameters(domain, vcpumap, params, + nparams, 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 7a3492d9d7..65d684b58b 100644 --- a/src/libvirt_public.syms +++ b/src/libvirt_public.syms @@ -948,4 +948,9 @@ LIBVIRT_10.2.0 { virDomainGraphicsReload; } LIBVIRT_10.1.0; +LIBVIRT_11.1.0 { + global: + virDomainSetVcpuTuneParameters; +} LIBVIRT_10.2.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 307f9ca945..eb3a47ef75 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -7835,6 +7835,7 @@ static virHypervisorDriver hypervisor_driver = { .domainSetLaunchSecurityState = remoteDomainSetLaunchSecurityState, /* 8.0.0 */ .domainFDAssociate = remoteDomainFDAssociate, /* 9.0.0 */ .domainGraphicsReload = remoteDomainGraphicsReload, /* 10.2.0 */ + .domainSetVcpuTuneParameters = remoteDomainSetVcpuTuneParameters, /* 11.1.0 */ }; static virNetworkDriver network_driver = { diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x index 41c045ff78..f99f44c9b5 100644 --- a/src/remote/remote_protocol.x +++ b/src/remote/remote_protocol.x @@ -292,6 +292,9 @@ const REMOTE_DOMAIN_AUTHORIZED_SSH_KEYS_MAX = 2048; /* Upper limit on number of messages */ const REMOTE_DOMAIN_MESSAGES_MAX = 2048; +/* Upper limit on VCPU tunable parameters. */ +const REMOTE_DOMAIN_SET_VCPU_TUNE_PARAMETERS_MAX = 16; + /* UUID. VIR_UUID_BUFLEN definition comes from libvirt.h */ typedef opaque remote_uuid[VIR_UUID_BUFLEN]; @@ -3973,6 +3976,13 @@ struct remote_domain_fd_associate_args { remote_nonnull_string name; unsigned int flags; }; + +struct remote_domain_set_vcpu_tune_parameters_args { + remote_nonnull_domain dom; + remote_nonnull_string cpumap; + remote_typed_param params<REMOTE_DOMAIN_SET_VCPU_TUNE_PARAMETERS_MAX>; + unsigned int flags; +}; /*----- Protocol. -----*/ /* Define the program number, protocol version and procedure numbers here. */ @@ -7048,5 +7058,13 @@ enum remote_procedure { * @generate: both * @acl: domain:write */ - REMOTE_PROC_DOMAIN_GRAPHICS_RELOAD = 448 + REMOTE_PROC_DOMAIN_GRAPHICS_RELOAD = 448, + + /** + * @generate: both + * @acl: domain:write + * @acl: domain:save:!VIR_DOMAIN_AFFECT_CONFIG|VIR_DOMAIN_AFFECT_LIVE + * @acl: domain:save:VIR_DOMAIN_AFFECT_CONFIG + */ + REMOTE_PROC_DOMAIN_SET_VCPU_TUNE_PARAMETERS = 449 }; -- 2.27.0