mirror of https://gitee.com/openkylin/libvirt.git
tests: start/stop an event thread for QEMU monitor/agent tests
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 <mprivozn@redhat.com> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
92890fbfa1
commit
ba906ab1c0
|
@ -36,6 +36,7 @@
|
||||||
#include "virlog.h"
|
#include "virlog.h"
|
||||||
#include "virerror.h"
|
#include "virerror.h"
|
||||||
#include "virstring.h"
|
#include "virstring.h"
|
||||||
|
#include "vireventthread.h"
|
||||||
|
|
||||||
#define VIR_FROM_THIS VIR_FROM_NONE
|
#define VIR_FROM_THIS VIR_FROM_NONE
|
||||||
|
|
||||||
|
@ -66,6 +67,8 @@ struct _qemuMonitorTest {
|
||||||
virNetSocketPtr server;
|
virNetSocketPtr server;
|
||||||
virNetSocketPtr client;
|
virNetSocketPtr client;
|
||||||
|
|
||||||
|
virEventThread *eventThread;
|
||||||
|
|
||||||
qemuMonitorPtr mon;
|
qemuMonitorPtr mon;
|
||||||
qemuAgentPtr agent;
|
qemuAgentPtr agent;
|
||||||
|
|
||||||
|
@ -389,6 +392,8 @@ qemuMonitorTestFree(qemuMonitorTestPtr test)
|
||||||
qemuAgentClose(test->agent);
|
qemuAgentClose(test->agent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_object_unref(test->eventThread);
|
||||||
|
|
||||||
virObjectUnref(test->vm);
|
virObjectUnref(test->vm);
|
||||||
|
|
||||||
if (test->started)
|
if (test->started)
|
||||||
|
@ -1138,6 +1143,7 @@ qemuMonitorCommonTestInit(qemuMonitorTestPtr test)
|
||||||
"}"
|
"}"
|
||||||
/* We skip the normal handshake reply of "{\"execute\":\"qmp_capabilities\"}" */
|
/* We skip the normal handshake reply of "{\"execute\":\"qmp_capabilities\"}" */
|
||||||
|
|
||||||
|
|
||||||
qemuMonitorTestPtr
|
qemuMonitorTestPtr
|
||||||
qemuMonitorTestNew(virDomainXMLOptionPtr xmlopt,
|
qemuMonitorTestNew(virDomainXMLOptionPtr xmlopt,
|
||||||
virDomainObjPtr vm,
|
virDomainObjPtr vm,
|
||||||
|
@ -1153,6 +1159,9 @@ qemuMonitorTestNew(virDomainXMLOptionPtr xmlopt,
|
||||||
if (!(test = qemuMonitorCommonTestNew(xmlopt, vm, &src)))
|
if (!(test = qemuMonitorCommonTestNew(xmlopt, vm, &src)))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
|
if (!(test->eventThread = virEventThreadNew("mon-test")))
|
||||||
|
goto error;
|
||||||
|
|
||||||
test->qapischema = schema;
|
test->qapischema = schema;
|
||||||
if (!(test->mon = qemuMonitorOpen(test->vm,
|
if (!(test->mon = qemuMonitorOpen(test->vm,
|
||||||
&src,
|
&src,
|
||||||
|
@ -1391,6 +1400,9 @@ qemuMonitorTestNewAgent(virDomainXMLOptionPtr xmlopt)
|
||||||
if (!(test = qemuMonitorCommonTestNew(xmlopt, NULL, &src)))
|
if (!(test = qemuMonitorCommonTestNew(xmlopt, NULL, &src)))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
|
if (!(test->eventThread = virEventThreadNew("agent-test")))
|
||||||
|
goto error;
|
||||||
|
|
||||||
if (!(test->agent = qemuAgentOpen(test->vm,
|
if (!(test->agent = qemuAgentOpen(test->vm,
|
||||||
&src,
|
&src,
|
||||||
&qemuMonitorTestAgentCallbacks)))
|
&qemuMonitorTestAgentCallbacks)))
|
||||||
|
|
Loading…
Reference in New Issue