[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 03/12] qtest: return string from QMP commands
From: |
Anthony Liguori |
Subject: |
[Qemu-devel] [PATCH 03/12] qtest: return string from QMP commands |
Date: |
Wed, 19 Jun 2013 15:40:26 -0500 |
Signed-off-by: Anthony Liguori <address@hidden>
---
tests/libqtest.c | 16 +++++++++++++---
tests/libqtest.h | 14 +++++++++++---
2 files changed, 24 insertions(+), 6 deletions(-)
diff --git a/tests/libqtest.c b/tests/libqtest.c
index 81107cf..235ec62 100644
--- a/tests/libqtest.c
+++ b/tests/libqtest.c
@@ -287,10 +287,13 @@ redo:
return words;
}
-void qtest_qmpv(QTestState *s, const char *fmt, va_list ap)
+char *qtest_qmpv(QTestState *s, const char *fmt, va_list ap)
{
bool has_reply = false;
int nesting = 0;
+ GString *ret;
+
+ ret = g_string_new("");
/* Send QMP request */
socket_sendf(s->qmp_fd, fmt, ap);
@@ -319,16 +322,23 @@ void qtest_qmpv(QTestState *s, const char *fmt, va_list
ap)
nesting--;
break;
}
+
+ g_string_append_c(ret, c);
}
+
+ return g_string_free(ret, FALSE);
}
-void qtest_qmp(QTestState *s, const char *fmt, ...)
+char *qtest_qmp(QTestState *s, const char *fmt, ...)
{
va_list ap;
+ char *ret;
va_start(ap, fmt);
- qtest_qmpv(s, fmt, ap);
+ ret = qtest_qmpv(s, fmt, ap);
va_end(ap);
+
+ return ret;
}
const char *qtest_get_arch(void)
diff --git a/tests/libqtest.h b/tests/libqtest.h
index 592f035..5cdcae7 100644
--- a/tests/libqtest.h
+++ b/tests/libqtest.h
@@ -21,6 +21,7 @@
#include <stdbool.h>
#include <stdarg.h>
#include <sys/types.h>
+#include <glib.h>
typedef struct QTestState QTestState;
@@ -48,8 +49,10 @@ void qtest_quit(QTestState *s);
* @fmt...: QMP message to send to qemu
*
* Sends a QMP message to QEMU
+ *
+ * Returns: the result of the QMP command
*/
-void qtest_qmp(QTestState *s, const char *fmt, ...);
+char *qtest_qmp(QTestState *s, const char *fmt, ...);
/**
* qtest_qmpv:
@@ -58,8 +61,10 @@ void qtest_qmp(QTestState *s, const char *fmt, ...);
* @ap: QMP message arguments
*
* Sends a QMP message to QEMU.
+ *
+ * Returns: the result of the QMP command
*/
-void qtest_qmpv(QTestState *s, const char *fmt, va_list ap);
+char *qtest_qmpv(QTestState *s, const char *fmt, va_list ap);
/**
* qtest_get_irq:
@@ -340,10 +345,13 @@ static inline QTestState *qtest_start(const char *args)
static inline void qmp(const char *fmt, ...)
{
va_list ap;
+ char *ret;
va_start(ap, fmt);
- qtest_qmpv(global_qtest, fmt, ap);
+ ret = qtest_qmpv(global_qtest, fmt, ap);
va_end(ap);
+
+ g_free(ret);
}
/**
--
1.8.0
- [Qemu-devel] [PATCH 00/12] spapr: add qtest support and refactor vty, Anthony Liguori, 2013/06/19
- [Qemu-devel] [PATCH 01/12] chardev: ringbuf: add optional save parameter to save state, Anthony Liguori, 2013/06/19
- [Qemu-devel] [PATCH 03/12] qtest: return string from QMP commands,
Anthony Liguori <=
- [Qemu-devel] [PATCH 06/12] spapr-vty: add copyright and license, Anthony Liguori, 2013/06/19
- Re: [Qemu-devel] [PATCH 06/12] spapr-vty: add copyright and license, Michael Ellerman, 2013/06/19
- Re: [Qemu-devel] [PATCH 06/12] spapr-vty: add copyright and license, Alexey Kardashevskiy, 2013/06/20
- Re: [Qemu-devel] [PATCH 06/12] spapr-vty: add copyright and license, David Gibson, 2013/06/20
- Re: [Qemu-devel] [PATCH 06/12] spapr-vty: add copyright and license, Paolo Bonzini, 2013/06/20
- Re: [Qemu-devel] [PATCH 06/12] spapr-vty: add copyright and license, Andreas Färber, 2013/06/20
- [Qemu-devel] [PATCH 09/12] spapr-vio: move special case handling for reg=0 to vio, Anthony Liguori, 2013/06/19