]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
testQemuAgentCPU: Rewrite using qemuMonitorTestAddItemVerbatim
authorPeter Krempa <pkrempa@redhat.com>
Mon, 22 May 2023 15:08:27 +0000 (17:08 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 5 Jun 2023 11:20:12 +0000 (13:20 +0200)
Replace qemuMonitorTestAddItemParams by qemuMonitorTestAddItemVerbatim

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
tests/qemuagenttest.c

index 7d8c66707d89dfc3dc38fc5af0cd33bf92483b96..04faf7b83a9ebfe74eb744521f3e954f255aecf5 100644 (file)
@@ -552,16 +552,6 @@ static const char testQemuAgentCPUResponse[] =
     "   ]"
     "}";
 
-static const char testQemuAgentCPUArguments1[] =
-    "[{\"logical-id\":1,\"online\":false}]";
-
-static const char testQemuAgentCPUArguments2[] =
-    "[{\"logical-id\":1,\"online\":true},"
-     "{\"logical-id\":3,\"online\":true}]";
-
-static const char testQemuAgentCPUArguments3[] =
-    "[{\"logical-id\":3,\"online\":true}]";
-
 static int
 testQemuAgentCPU(const void *data)
 {
@@ -595,26 +585,36 @@ testQemuAgentCPU(const void *data)
     if (qemuAgentUpdateCPUInfo(2, cpuinfo, nvcpus) < 0)
         return -1;
 
-    if (qemuMonitorTestAddItemParams(test, "guest-set-vcpus",
-                                     "{ \"return\" : 1 }",
-                                     "vcpus", testQemuAgentCPUArguments1,
-                                     NULL) < 0)
+    if (qemuMonitorTestAddItemVerbatim(test,
+                                       "{\"execute\":\"guest-set-vcpus\","
+                                       " \"arguments\": {"
+                                       "     \"vcpus\":[{\"logical-id\":1,\"online\":false}]"
+                                       "}}",
+                                       NULL,
+                                       "{ \"return\" : 1 }") < 0)
         return -1;
 
     if (qemuAgentSetVCPUs(qemuMonitorTestGetAgent(test), cpuinfo, nvcpus) < 0)
         return -1;
 
     /* try to hotplug two, second one will fail */
-    if (qemuMonitorTestAddItemParams(test, "guest-set-vcpus",
-                                     "{ \"return\" : 1 }",
-                                     "vcpus", testQemuAgentCPUArguments2,
-                                     NULL) < 0)
-        return -1;
-
-    if (qemuMonitorTestAddItemParams(test, "guest-set-vcpus",
-                                     "{ \"error\" : \"random error\" }",
-                                     "vcpus", testQemuAgentCPUArguments3,
-                                     NULL) < 0)
+    if (qemuMonitorTestAddItemVerbatim(test,
+                                       "{\"execute\":\"guest-set-vcpus\","
+                                       " \"arguments\": {"
+                                       "     \"vcpus\":[{\"logical-id\":1,\"online\":true},"
+                                       "                {\"logical-id\":3,\"online\":true}]"
+                                       "}}",
+                                       NULL,
+                                       "{ \"return\" : 1 }") < 0)
+        return -1;
+
+    if (qemuMonitorTestAddItemVerbatim(test,
+                                       "{\"execute\":\"guest-set-vcpus\","
+                                       " \"arguments\": {"
+                                       "     \"vcpus\":[{\"logical-id\":3,\"online\":true}]"
+                                       "}}",
+                                       NULL,
+                                       "{ \"error\" : \"random error\" }") < 0)
         return -1;
 
     if (qemuAgentUpdateCPUInfo(4, cpuinfo, nvcpus) < 0)