On Thu, Apr 11, 2024 at 19:01:57 -0700, wucf(a)linux.ibm.com wrote:
From: Chun Feng Wu <wucf(a)linux.ibm.com>
Within "testQemuMonitorJSONqemuMonitorJSONUpdateThrottleGroup"
* Test qemuMonitorJSONGetThrottleGroup
* Test qemuMonitorJSONUpdateThrottleGroup, which updates limits through
"qom-set"
Signed-off-by: Chun Feng Wu <wucf(a)linux.ibm.com>
---
tests/qemumonitorjsontest.c | 88 +++++++++++++++++++++++++++++++++++++
1 file changed, 88 insertions(+)
Ah okay so this is indeed testing both the getter and setter.
Move this patch either directly after the code implementing the monitor
or squash them together.
diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c
index 45cee23798..b4ddddc243 100644
--- a/tests/qemumonitorjsontest.c
+++ b/tests/qemumonitorjsontest.c
@@ -147,6 +147,32 @@ const char *queryBlockReply =
" \"id\": \"libvirt-10\""
"}";
+const char *qomGetReply =
+"{"
+" \"return\": {"
+" \"bps-total\": 1,"
+" \"bps-read\": 2,"
+" \"bps-write\": 3,"
+" \"iops-total\": 4,"
+" \"iops-read\": 5,"
+" \"iops-write\": 6,"
+" \"bps-total-max\": 7,"
+" \"bps-read-max\": 8,"
+" \"bps-write-max\": 9,"
+" \"iops-total-max\": 10,"
+" \"iops-read-max\": 11,"
+" \"iops-write-max\": 12,"
+" \"iops-size\": 13,"
+" \"bps-total-max-length\": 15,"
+" \"bps-read-max-length\": 16,"
+" \"bps-write-max-length\": 17,"
+" \"iops-total-max-length\": 18,"
+" \"iops-read-max-length\": 19,"
+" \"iops-write-max-length\": 20"
+" },"
+" \"id\": \"libvirt-12\""
+"}";
This is in an extra variable ...
+
static int
testQemuMonitorJSONGetStatus(const void *opaque)
{
@@ -1853,6 +1879,67 @@ testQemuMonitorJSONqemuMonitorJSONSetBlockIoThrottle(const void
*opaque)
return ret;
}
+
+static int
+testQemuMonitorJSONqemuMonitorJSONUpdateThrottleGroup(const void *opaque)
+{
+ const testGenericData *data = opaque;
+ virDomainXMLOption *xmlopt = data->xmlopt;
+ virDomainBlockIoTuneInfo info, expectedInfo;
+ g_autoptr(qemuMonitorTest) test = NULL;
+
+ if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
+ return -1;
+
+ expectedInfo = (virDomainBlockIoTuneInfo) {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
13, NULL, 15, 16, 17, 18, 19, 20};
+ expectedInfo.group_name = g_strdup("limit0");
+
+ if (qemuMonitorTestAddItem(test, "qom-get", qomGetReply) < 0)
+ return -1;
+
+ if (qemuMonitorTestAddItemVerbatim(test,
+
"{\"execute\":\"qom-set\","
+ "
\"arguments\":{\"property\": \"limits\","
+ " \"path\":
\"limit1\","
+ "
\"value\":{\"bps-total\": 1,"
+ "
\"bps-read\": 2,"
+ "
\"bps-write\": 3,"
+ "
\"iops-total\": 4,"
+ "
\"iops-read\": 5,"
+ "
\"iops-write\": 6,"
+ "
\"bps-total-max\": 7,"
+ "
\"bps-read-max\": 8,"
+ "
\"bps-write-max\": 9,"
+ "
\"iops-total-max\": 10,"
+ "
\"iops-read-max\": 11,"
+ "
\"iops-write-max\": 12,"
+ "
\"iops-size\": 13,"
+ "
\"bps-total-max-length\": 15,"
+ "
\"bps-read-max-length\": 16,"
+ "
\"bps-write-max-length\": 17,"
+ "
\"iops-total-max-length\": 18,"
+ "
\"iops-read-max-length\": 19,"
+ "
\"iops-write-max-length\": 20}},"
+ "
\"id\":\"libvirt-2\"}",
+ NULL,
+ "{ \"return\" : {}}") < 0)
... while this is not. Make them consistent, preferrably by putting all
code inline as in the case above.
+ return -1;
+
+ if (qemuMonitorJSONGetThrottleGroup(qemuMonitorTestGetMonitor(test),
+ "limit0", &info) < 0)
+ return -1;
+
+ if (testValidateGetBlockIoThrottle(&info, &expectedInfo) < 0)
+ return -1;
+
+ if (qemuMonitorJSONUpdateThrottleGroup(qemuMonitorTestGetMonitor(test),
+ "limit1", &info) < 0)
+ return -1;
+
+ return 0;
+}
+