Add a function to specify the qmp capabilities content.
Signed-off-by: Marc-André Lureau <[email protected]>
---
tests/libqtest.h | 9 +++++++++
tests/libqtest.c | 13 +++++++++++--
2 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/tests/libqtest.h b/tests/libqtest.h
index 90f182e1d8..e7ab509d1a 100644
--- a/tests/libqtest.h
+++ b/tests/libqtest.h
@@ -32,6 +32,15 @@ extern QTestState *global_qtest;
QTestState *qtest_init(const char *extra_args);
/**
+ * qtest_init_qmp_caps:
+ * @extra_args: other arguments to pass to QEMU.
+ * @qmp_caps: qmp capabilities (ex: "'cap1', 'cap2'")
+ *
+ * Returns: #QTestState instance.
+ */
+QTestState *qtest_init_qmp_caps(const char *extra_args, const char *qmp_caps);
+
+/**
* qtest_quit:
* @s: #QTestState instance to operate on.
*
diff --git a/tests/libqtest.c b/tests/libqtest.c
index d8fba6647a..eb4a0c12c0 100644
--- a/tests/libqtest.c
+++ b/tests/libqtest.c
@@ -149,7 +149,7 @@ void qtest_add_abrt_handler(GHookFunc fn, const void *data)
g_hook_prepend(&abrt_hooks, hook);
}
-QTestState *qtest_init(const char *extra_args)
+QTestState *qtest_init_qmp_caps(const char *extra_args, const char *qmp_caps)
{
QTestState *s;
int sock, qmpsock, i;
@@ -206,7 +206,11 @@ QTestState *qtest_init(const char *extra_args)
/* Read the QMP greeting and then do the handshake */
qtest_qmp_discard_response(s, "");
- qtest_qmp_discard_response(s, "{ 'execute': 'qmp_capabilities' }");
+ command = g_strdup_printf(
+ "{ 'execute': 'qmp_capabilities',"
+ " 'arguments': {'capabilities': [%s]}}", qmp_caps);
+ qtest_qmp_discard_response(s, command);
+ g_free(command);
if (getenv("QTEST_STOP")) {
kill(s->qemu_pid, SIGSTOP);
@@ -219,6 +223,11 @@ QTestState *qtest_init(const char *extra_args)
return s;
}
+QTestState *qtest_init(const char *extra_args)
+{
+ return qtest_init_qmp_caps(extra_args, "");
+}
+
void qtest_quit(QTestState *s)
{
qtest_instances = g_list_remove(qtest_instances, s);
--
2.11.0.295.gd7dffce1c