From: Chun Feng Wu <danielwuwy(a)163.com>
Defined new public APIs:
* virDomainSetThrottleGroup to add or update throttlegroup within specific domain,
it will be referenced by throttlefilter later in disk to do limits
* virDomainGetThrottleGroup to get throttlegroup info, old-style is discarded
(APIs to query first for the number of parameters and then give it a
reasonably-sized pointer), instead, the new approach is adopted that
API returns allocated array of fields and number of fileds that are in it.
* virDomainDelThrottleGroup to delete throttlegroup, it fails if this throttlegroup
is still referenced by some throttlefilter
Signed-off-by: Chun Feng Wu <danielwuwy(a)163.com>
* Reimplement getter API to fetch data from XML.
* Apply suggested coding style changes.
* Update of code documentation comments.
* Update the version to 11.2.0.
Signed-off-by: Harikumar Rajkumar <harirajkumar230(a)gmail.com>
Reviewed-by: Peter Krempa <pkrempa(a)redhat.com>
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
include/libvirt/libvirt-domain.h | 14 ++++
src/driver-hypervisor.h | 14 ++++
src/libvirt-domain.c | 122 +++++++++++++++++++++++++++++++
src/libvirt_public.syms | 6 ++
src/remote/remote_driver.c | 2 +
src/remote/remote_protocol.x | 31 +++++++-
src/remote_protocol-structs | 16 ++++
7 files changed, 204 insertions(+), 1 deletion(-)
diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h
index 8c86bd8f94..933daf21cc 100644
--- a/include/libvirt/libvirt-domain.h
+++ b/include/libvirt/libvirt-domain.h
@@ -8277,4 +8277,18 @@ virDomainGraphicsReload(virDomainPtr domain,
unsigned int type,
unsigned int flags);
+
+int
+virDomainSetThrottleGroup(virDomainPtr dom,
+ const char *group,
+ virTypedParameterPtr params,
+ int nparams,
+ unsigned int flags);
+
+int
+virDomainDelThrottleGroup(virDomainPtr dom,
+ const char *group,
+ unsigned int flags);
+
+
#endif /* LIBVIRT_DOMAIN_H */
diff --git a/src/driver-hypervisor.h b/src/driver-hypervisor.h
index 4ce8da078d..124b1a12e3 100644
--- a/src/driver-hypervisor.h
+++ b/src/driver-hypervisor.h
@@ -1453,6 +1453,18 @@ typedef int
unsigned int type,
unsigned int flags);
+typedef int
+(*virDrvDomainSetThrottleGroup)(virDomainPtr dom,
+ const char *groupname,
+ virTypedParameterPtr params,
+ int nparams,
+ unsigned int flags);
+
+typedef int
+(*virDrvDomainDelThrottleGroup)(virDomainPtr dom,
+ const char *groupname,
+ unsigned int flags);
+
typedef struct _virHypervisorDriver virHypervisorDriver;
/**
@@ -1726,4 +1738,6 @@ struct _virHypervisorDriver {
virDrvDomainStartDirtyRateCalc domainStartDirtyRateCalc;
virDrvDomainFDAssociate domainFDAssociate;
virDrvDomainGraphicsReload domainGraphicsReload;
+ virDrvDomainSetThrottleGroup domainSetThrottleGroup;
+ virDrvDomainDelThrottleGroup domainDelThrottleGroup;
};
diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c
index b23a3489c5..9fe8cf1d4d 100644
--- a/src/libvirt-domain.c
+++ b/src/libvirt-domain.c
@@ -13985,3 +13985,125 @@ virDomainGraphicsReload(virDomainPtr domain,
virDispatchError(domain->conn);
return -1;
}
+
+
+/**
+ * virDomainSetThrottleGroup:
+ * @dom: pointer to domain object
+ * @group: throttle group name
+ * @params: Pointer to blkio parameter objects
+ * @nparams: Number of blkio parameters (this value can be the same or
+ * less than the number of parameters supported)
+ * @flags: bitwise-OR of virDomainModificationImpact
+ *
+ * Add throttlegroup or change all of the throttlegroup options
+ * within specific domain
+ *
+ * The @group parameter is the name for new or existing throttlegroup,
+ * it cannot be NULL, detailed throttlegroup info is included in @params,
+ * it either creates new throttlegroup with @params or updates existing
+ * throttlegroup with @params, throttlegroup can be referenced by throttle
+ * filter in attached disk to do limits, the difference from iotune is that
+ * multiple throttlegroups can be referenced within attached disk
+ *
+ * Returns -1 in case of error, 0 in case of success.
+ *
+ * Since: 11.2.0
+ */
+int
+virDomainSetThrottleGroup(virDomainPtr dom,
+ const char *group,
+ virTypedParameterPtr params,
+ int nparams,
+ unsigned int flags)
+{
+ virConnectPtr conn;
+
+ VIR_DOMAIN_DEBUG(dom, "params=%p, group='%s', nparams=%d,
flags=0x%x",
+ params, group, nparams, flags);
+ VIR_TYPED_PARAMS_DEBUG(params, nparams);
+
+ virResetLastError();
+
+ virCheckDomainReturn(dom, -1);
+ conn = dom->conn;
+
+ virCheckReadOnlyGoto(conn->flags, error);
+ virCheckNonNullArgGoto(group, error);
+ virCheckPositiveArgGoto(nparams, error);
+ virCheckNonNullArgGoto(params, error);
+
+ if (virTypedParameterValidateSet(dom->conn, params, nparams) < 0)
+ goto error;
+
+ if (conn->driver->domainSetThrottleGroup) {
+ int ret;
+ ret = conn->driver->domainSetThrottleGroup(dom, group, params, nparams,
flags);
+ if (ret < 0)
+ goto error;
+ return ret;
+ }
+
+ virReportUnsupportedError();
+
+ error:
+ virDispatchError(dom->conn);
+ return -1;
+}
+
+
+/**
+ * virDomainDelThrottleGroup:
+ * @dom: pointer to domain object
+ * @group: throttle group name
+ * @flags: bitwise-OR of virDomainModificationImpact
+ *
+ * Delete an throttlegroup from the domain. @group cannot be NULL,
+ * and the @group to be deleted must not have a throttlefilter associated with
+ * it and can be any of the current valid group.
+ *
+ * @flags may include VIR_DOMAIN_AFFECT_LIVE or VIR_DOMAIN_AFFECT_CONFIG.
+ * Both flags may be set.
+ * If VIR_DOMAIN_AFFECT_LIVE is set, the change affects a running domain
+ * and may fail if domain is not alive.
+ * If VIR_DOMAIN_AFFECT_CONFIG is set, the change affects persistent state,
+ * and will fail for transient domains. If neither flag is specified (that is,
+ * @flags is VIR_DOMAIN_AFFECT_CURRENT), then an inactive domain modifies
+ * persistent setup, while an active domain is hypervisor-dependent on whether
+ * just live or both live and persistent state is changed.
+ *
+ * Returns -1 in case of error, 0 in case of success.
+ *
+ * Since: 11.2.0
+ */
+int
+virDomainDelThrottleGroup(virDomainPtr dom,
+ const char *group,
+ unsigned int flags)
+{
+ virConnectPtr conn;
+
+ VIR_DOMAIN_DEBUG(dom, "group='%s', flags=0x%x",
+ group, flags);
+
+ virResetLastError();
+
+ virCheckDomainReturn(dom, -1);
+ virCheckNonNullArgGoto(group, error);
+
+ conn = dom->conn;
+
+ if (conn->driver->domainDelThrottleGroup) {
+ int ret;
+ ret = conn->driver->domainDelThrottleGroup(dom, group, flags);
+ if (ret < 0)
+ goto error;
+ return ret;
+ }
+
+ virReportUnsupportedError();
+
+ error:
+ virDispatchError(dom->conn);
+ return -1;
+}
diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms
index 7a3492d9d7..67e0c61758 100644
--- a/src/libvirt_public.syms
+++ b/src/libvirt_public.syms
@@ -948,4 +948,10 @@ LIBVIRT_10.2.0 {
virDomainGraphicsReload;
} LIBVIRT_10.1.0;
+LIBVIRT_11.2.0 {
+ global:
+ virDomainSetThrottleGroup;
+ virDomainDelThrottleGroup;
+} 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..d35259351c 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -7835,6 +7835,8 @@ static virHypervisorDriver hypervisor_driver = {
.domainSetLaunchSecurityState = remoteDomainSetLaunchSecurityState, /* 8.0.0 */
.domainFDAssociate = remoteDomainFDAssociate, /* 9.0.0 */
.domainGraphicsReload = remoteDomainGraphicsReload, /* 10.2.0 */
+ .domainSetThrottleGroup = remoteDomainSetThrottleGroup, /* 11.2.0 */
+ .domainDelThrottleGroup = remoteDomainDelThrottleGroup, /* 11.2.0 */
};
static virNetworkDriver network_driver = {
diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
index 41c045ff78..49ead23dc3 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -1475,6 +1475,19 @@ struct remote_domain_get_block_io_tune_ret {
int nparams;
};
+struct remote_domain_set_throttle_group_args {
+ remote_nonnull_domain dom;
+ remote_nonnull_string group;
+ remote_typed_param params<REMOTE_DOMAIN_BLOCK_IO_TUNE_PARAMETERS_MAX>;
+ unsigned int flags;
+};
+
+struct remote_domain_del_throttle_group_args {
+ remote_nonnull_domain dom;
+ remote_string group;
+ unsigned int flags;
+};
+
struct remote_domain_get_cpu_stats_args {
remote_nonnull_domain dom;
unsigned int nparams;
@@ -7048,5 +7061,21 @@ 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_THROTTLE_GROUP = 449,
+
+ /**
+ * @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_DEL_THROTTLE_GROUP = 450
};
diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs
index ed7e2fbcb0..6084f0cb12 100644
--- a/src/remote_protocol-structs
+++ b/src/remote_protocol-structs
@@ -1050,6 +1050,20 @@ struct remote_domain_get_block_io_tune_ret {
} params;
int nparams;
};
+struct remote_domain_set_throttle_group_args {
+ remote_nonnull_domain dom;
+ remote_nonnull_string group;
+ struct {
+ u_int params_len;
+ remote_typed_param * params_val;
+ } params;
+ u_int flags;
+};
+struct remote_domain_del_throttle_group_args {
+ remote_nonnull_domain dom;
+ remote_string group;
+ u_int flags;
+};
struct remote_domain_get_cpu_stats_args {
remote_nonnull_domain dom;
u_int nparams;
@@ -3755,4 +3769,6 @@ enum remote_procedure {
REMOTE_PROC_NETWORK_EVENT_CALLBACK_METADATA_CHANGE = 446,
REMOTE_PROC_NODE_DEVICE_UPDATE = 447,
REMOTE_PROC_DOMAIN_GRAPHICS_RELOAD = 448,
+ REMOTE_PROC_DOMAIN_SET_THROTTLE_GROUP = 449,
+ REMOTE_PROC_DOMAIN_DEL_THROTTLE_GROUP = 450,
};
--
2.48.1