[PATCH 1/3] qemuagenttest: Test arbitrary command passthrough

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Excercise the arbitrary command passthrough API.
---
 tests/qemuagenttest.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)

diff --git a/tests/qemuagenttest.c b/tests/qemuagenttest.c
index cabd5b7..1818d50 100644
--- a/tests/qemuagenttest.c
+++ b/tests/qemuagenttest.c
@@ -444,6 +444,50 @@ cleanup:
 }


+static const char testQemuAgentArbitraryCommandResponse[] =
+    "{\"return\":\"bla\"}";
+
+static int
+testQemuAgentArbitraryCommand(const void *data)
+{
+    virDomainXMLOptionPtr xmlopt = (virDomainXMLOptionPtr)data;
+    qemuMonitorTestPtr test = qemuMonitorTestNewAgent(xmlopt);
+    int ret = -1;
+    char *reply = NULL;
+
+    if (!test)
+        return -1;
+
+    if (qemuMonitorTestAddAgentSyncResponse(test) < 0)
+        goto cleanup;
+
+    if (qemuMonitorTestAddItem(test, "ble",
+                               testQemuAgentArbitraryCommandResponse) < 0)
+        goto cleanup;
+
+    if (qemuAgentArbitraryCommand(qemuMonitorTestGetAgent(test),
+                                  "{\"execute\":\"ble\"}",
+                                  &reply,
+                                  VIR_DOMAIN_QEMU_AGENT_COMMAND_BLOCK) < 0)
+        goto cleanup;
+
+    if (STRNEQ(reply, testQemuAgentArbitraryCommandResponse)) {
+        virReportError(VIR_ERR_INTERNAL_ERROR,
+                       "invalid processing of guest agent reply: "
+                       "got '%s' expected '%s'",
+                       reply, testQemuAgentArbitraryCommandResponse);
+        goto cleanup;
+    }
+
+    ret = 0;
+
+cleanup:
+    VIR_FREE(reply);
+    qemuMonitorTestFree(test);
+    return ret;
+}
+
+
 static int
 mymain(void)
 {
@@ -471,6 +515,7 @@ mymain(void)
     DO_TEST(Suspend);
     DO_TEST(Shutdown);
     DO_TEST(CPU);
+    DO_TEST(ArbitraryCommand);

     virObjectUnref(xmlopt);

-- 
1.8.3.2

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]