]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: monitor: Add support for ThrottleGroup operations
authorChun Feng Wu <danielwuwy@163.com>
Wed, 19 Feb 2025 16:57:09 +0000 (22:27 +0530)
committerPeter Krempa <pkrempa@redhat.com>
Thu, 20 Mar 2025 16:43:43 +0000 (17:43 +0100)
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@163.com>
* change throttle group config conversions P to U allow zero.
* Apply suggested coding style changes.

Signed-off-by: Harikumar Rajkumar <harirajkumar230@gmail.com>
* Deleted all getter code.

Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/qemu/qemu_monitor.c
src/qemu/qemu_monitor.h
src/qemu/qemu_monitor_json.c
src/qemu/qemu_monitor_json.h

index a903e4ac7d3b83fea1da5caa316486d2fe1a85d1..3a5940e697a8702e4782bec14c88f6beb38b4035 100644 (file)
@@ -3012,6 +3012,27 @@ qemuMonitorGetBlockIoThrottle(qemuMonitor *mon,
 }
 
 
+int
+qemuMonitorThrottleGroupLimits(virJSONValue *limits,
+                               const virDomainThrottleGroupDef *group)
+{
+    return qemuMonitorMakeThrottleGroupLimits(limits, group);
+}
+
+
+int
+qemuMonitorUpdateThrottleGroup(qemuMonitor *mon,
+                               const char *qomid,
+                               virDomainBlockIoTuneInfo *info)
+{
+    VIR_DEBUG("qomid=%s, info=%p", qomid, info);
+
+    QEMU_CHECK_MONITOR(mon);
+
+    return qemuMonitorJSONUpdateThrottleGroup(mon, qomid, info);
+}
+
+
 int
 qemuMonitorVMStatusToPausedReason(const char *status)
 {
index 8c3fb5e131178a08aba8f8d6ab3613841a0e008a..5e78a1876f3a54581584d06e41dde96f120ba070 100644 (file)
@@ -1075,6 +1075,15 @@ int qemuMonitorGetBlockIoThrottle(qemuMonitor *mon,
                                   const char *qdevid,
                                   virDomainBlockIoTuneInfo *reply);
 
+int
+qemuMonitorThrottleGroupLimits(virJSONValue *limits,
+                               const virDomainThrottleGroupDef *group);
+
+int
+qemuMonitorUpdateThrottleGroup(qemuMonitor *mon,
+                               const char *qomid,
+                               virDomainBlockIoTuneInfo *info);
+
 int qemuMonitorSystemWakeup(qemuMonitor *mon);
 
 int qemuMonitorGetVersion(qemuMonitor *mon,
index 646d8df24213eefc07a34dc3460b0fab0949a7a3..d0de48fb18aa6bd237ac3e177a4bc24e70ef20cd 100644 (file)
@@ -4686,6 +4686,67 @@ int qemuMonitorJSONGetBlockIoThrottle(qemuMonitor *mon,
     return qemuMonitorJSONBlockIoThrottleInfo(devices, qdevid, reply);
 }
 
+
+int
+qemuMonitorMakeThrottleGroupLimits(virJSONValue *limits,
+                                   const virDomainThrottleGroupDef *group)
+{
+    if (virJSONValueObjectAdd(&limits,
+                              "U:bps-total", group->total_bytes_sec,
+                              "U:bps-read", group->read_bytes_sec,
+                              "U:bps-write", group->write_bytes_sec,
+                              "U:iops-total", group->total_iops_sec,
+                              "U:iops-read", group->read_iops_sec,
+                              "U:iops-write", group->write_iops_sec,
+                              "U:bps-total-max", group->total_bytes_sec_max,
+                              "U:bps-read-max", group->read_bytes_sec_max,
+                              "U:bps-write-max", group->write_bytes_sec_max,
+                              "U:iops-total-max", group->total_iops_sec_max,
+                              "U:iops-read-max", group->read_iops_sec_max,
+                              "U:iops-write-max", group->write_iops_sec_max,
+                              "U:iops-size", group->size_iops_sec,
+                              "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();
+
+    if (qemuMonitorMakeThrottleGroupLimits(limits, info) < 0)
+        return -1;
+
+    if (!(cmd = qemuMonitorJSONMakeCommand("qom-set",
+                                           "s:property", "limits",
+                                           "s:path", qomid,
+                                           "a:value", &limits,
+                                           NULL)))
+        return -1;
+
+    if (qemuMonitorJSONCommand(mon, cmd, &result) < 0)
+        return -1;
+
+    if (qemuMonitorJSONCheckError(cmd, result) < 0)
+        return -1;
+
+    return 0;
+}
+
+
 int qemuMonitorJSONSystemWakeup(qemuMonitor *mon)
 {
     g_autoptr(virJSONValue) cmd = NULL;
index 77b8bf4a1b589f2f618549e9793792e2f66b519f..c97080f2369d8c051ae131fdd129c27311dca279 100644 (file)
@@ -376,6 +376,15 @@ qemuMonitorJSONSetBlockIoThrottle(qemuMonitor *mon,
                                   const char *qomid,
                                   virDomainBlockIoTuneInfo *info);
 
+int
+qemuMonitorMakeThrottleGroupLimits(virJSONValue *limits,
+                                   const virDomainThrottleGroupDef *group);
+
+int
+qemuMonitorJSONUpdateThrottleGroup(qemuMonitor *mon,
+                                   const char *qomid,
+                                   virDomainBlockIoTuneInfo *info);
+
 int
 qemuMonitorJSONGetBlockIoThrottle(qemuMonitor *mon,
                                   const char *qdevid,