From: Chun Feng Wu <danielwuwy(a)163.com>
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(a)163.com>
* change throttle group config conversions P to U allow zero.
* Apply suggested coding style changes.
Signed-off-by: Harikumar Rajkumar <harirajkumar230(a)gmail.com>
* Deleted all getter code.
Reviewed-by: Peter Krempa <pkrempa(a)redhat.com>
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/qemu/qemu_monitor.c | 21 +++++++++++++
src/qemu/qemu_monitor.h | 9 ++++++
src/qemu/qemu_monitor_json.c | 61 ++++++++++++++++++++++++++++++++++++
src/qemu/qemu_monitor_json.h | 9 ++++++
4 files changed, 100 insertions(+)
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 8d8e73d38d..4ec8d4eae1 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -3011,6 +3011,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)
{
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index f7b9263b64..c6332630bd 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -1074,6 +1074,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,
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 9c60807926..4532d32697 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -4684,6 +4684,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;
diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h
index 25e3ae2cbb..5b05aa38b5 100644
--- a/src/qemu/qemu_monitor_json.h
+++ b/src/qemu/qemu_monitor_json.h
@@ -375,6 +375,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,
--
2.48.1