From ba906ab1c0342b98495938f283d1ab7806b72082 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Date: Wed, 12 Feb 2020 14:56:29 +0000 Subject: [PATCH] tests: start/stop an event thread for QEMU monitor/agent tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Tests which are using the QEMU monitor / agent need to have an event thread running a private GMainContext. There is already a thread running the main libvirt event loop but this can't be eliminated yet as it is used for more than just the monitor client I/O. Reviewed-by: Michal Privoznik Signed-off-by: Daniel P. Berrangé --- tests/qemumonitortestutils.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/qemumonitortestutils.c b/tests/qemumonitortestutils.c index 00f5b49439..a30851aa63 100644 --- a/tests/qemumonitortestutils.c +++ b/tests/qemumonitortestutils.c @@ -36,6 +36,7 @@ #include "virlog.h" #include "virerror.h" #include "virstring.h" +#include "vireventthread.h" #define VIR_FROM_THIS VIR_FROM_NONE @@ -66,6 +67,8 @@ struct _qemuMonitorTest { virNetSocketPtr server; virNetSocketPtr client; + virEventThread *eventThread; + qemuMonitorPtr mon; qemuAgentPtr agent; @@ -389,6 +392,8 @@ qemuMonitorTestFree(qemuMonitorTestPtr test) qemuAgentClose(test->agent); } + g_object_unref(test->eventThread); + virObjectUnref(test->vm); if (test->started) @@ -1138,6 +1143,7 @@ qemuMonitorCommonTestInit(qemuMonitorTestPtr test) "}" /* We skip the normal handshake reply of "{\"execute\":\"qmp_capabilities\"}" */ + qemuMonitorTestPtr qemuMonitorTestNew(virDomainXMLOptionPtr xmlopt, virDomainObjPtr vm, @@ -1153,6 +1159,9 @@ qemuMonitorTestNew(virDomainXMLOptionPtr xmlopt, if (!(test = qemuMonitorCommonTestNew(xmlopt, vm, &src))) goto error; + if (!(test->eventThread = virEventThreadNew("mon-test"))) + goto error; + test->qapischema = schema; if (!(test->mon = qemuMonitorOpen(test->vm, &src, @@ -1391,6 +1400,9 @@ qemuMonitorTestNewAgent(virDomainXMLOptionPtr xmlopt) if (!(test = qemuMonitorCommonTestNew(xmlopt, NULL, &src))) goto error; + if (!(test->eventThread = virEventThreadNew("agent-test"))) + goto error; + if (!(test->agent = qemuAgentOpen(test->vm, &src, &qemuMonitorTestAgentCallbacks)))