On Mon, Nov 18, 2024 at 19:24:13 +0530, Harikumar R wrote: > From: Chun Feng Wu <danielwuwy@xxxxxxx> > > This change contains QMP requests for ThrottleGroup > > * ThrottleGroup is updated through "qemuMonitorJSONUpdateThrottleGroup" > * ThrottleGroup is retrieved through "qemuMonitorJSONGetThrottleGroup" > * ThrottleGroup is deleted by reusing "qemuMonitorDelObject" > * ThrottleGroup is added by reusing "qemuMonitorAddObject" > * "qemuMonitorMakeThrottleGroupLimits" will be used by building qemu cmd as well > > Signed-off-by: Chun Feng Wu <danielwuwy@xxxxxxx> > --- > src/qemu/qemu_monitor.c | 34 +++++++++ > src/qemu/qemu_monitor.h | 14 ++++ > src/qemu/qemu_monitor_json.c | 134 +++++++++++++++++++++++++++++++++++ > src/qemu/qemu_monitor_json.h | 14 ++++ > 4 files changed, 196 insertions(+) > diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c > index c594b33106..887ce8e7f5 100644 > --- a/src/qemu/qemu_monitor_json.c > +++ b/src/qemu/qemu_monitor_json.c > @@ -4666,6 +4666,140 @@ int qemuMonitorJSONGetBlockIoThrottle(qemuMonitor *mon, > return qemuMonitorJSONBlockIoThrottleInfo(devices, qdevid, reply); > } > > + > +int > +qemuMonitorMakeThrottleGroupLimits(virJSONValue *limits, > + const virDomainThrottleGroupDef *group) > +{ > + if (virJSONValueObjectAdd(&limits, > + "P:bps-total", group->total_bytes_sec, > + "P:bps-read", group->read_bytes_sec, > + "P:bps-write", group->write_bytes_sec, > + "P:iops-total", group->total_iops_sec, > + "P:iops-read", group->read_iops_sec, > + "P:iops-write", group->write_iops_sec, > + "P:bps-total-max", group->total_bytes_sec_max, > + "P:bps-read-max", group->read_bytes_sec_max, > + "P:bps-write-max", group->write_bytes_sec_max, > + "P:iops-total-max", group->total_iops_sec_max, > + "P:iops-read-max", group->read_iops_sec_max, > + "P:iops-write-max", group->write_iops_sec_max, > + "P:iops-size", group->size_iops_sec, > + /* avoid error from QEMU: "the burst length cannot be 0" for throttlelimits > + * when setting max-length > + */ What is the point of this comment? All the conversions use "P:" conversion which skips the value if it's 0. > + "P:bps-total-max-length", group->total_bytes_sec_max_length, > + "P:bps-read-max-length", group->read_bytes_sec_max_length, > + "P:bps-write-max-length", group->write_bytes_sec_max_length, > + "P:iops-total-max-length", group->total_iops_sec_max_length, > + "P:iops-read-max-length", group->read_iops_sec_max_length, > + "P:iops-write-max-length", group->write_iops_sec_max_length, > + NULL) < 0) > + return -1; > + > + return 0; > +} > + > + > +int > +qemuMonitorJSONUpdateThrottleGroup(qemuMonitor *mon, > + const char *qomid, > + virDomainBlockIoTuneInfo *info) > +{ > + g_autoptr(virJSONValue) cmd = NULL; > + g_autoptr(virJSONValue) result = NULL; > + g_autoptr(virJSONValue) limits = virJSONValueNewObject(); > + /* prefix group name with "throttle-" in QOM */ > + g_autofree char *prefixed_group_name = g_strdup_printf("throttle-%s", qomid);a I'd suggest storing the name with the prefix in the main struct itself but no need to change that now. > + > + if (qemuMonitorMakeThrottleGroupLimits(limits, info) < 0) > + return -1; > + > + if (!(cmd = qemuMonitorJSONMakeCommand("qom-set", > + "s:property", "limits", > + "s:path", prefixed_group_name, > + "a:value", &limits, > + NULL))) Since tests are added in another patch this one can use: Reviewed-by: Peter Krempa <pkrempa@xxxxxxxxxx>