[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 64/69] libqtest: add qmp_async
From: |
Stefan Hajnoczi |
Subject: |
[Qemu-devel] [PULL 64/69] libqtest: add qmp_async |
Date: |
Fri, 27 Feb 2015 18:19:02 +0000 |
From: John Snow <address@hidden>
Add qmp_async, which lets us send QMP commands asynchronously.
This is useful when we want to send commands that will trigger
event responses, but we don't know in what order to expect them.
Sometimes the event responses may arrive even before the command
confirmation will show up, so it is convenient to leave the responses
in the stream.
Signed-off-by: John Snow <address@hidden>
Message-id: address@hidden
Signed-off-by: Stefan Hajnoczi <address@hidden>
---
tests/libqtest.c | 30 +++++++++++++++++++++++++++++-
tests/libqtest.h | 27 +++++++++++++++++++++++++++
2 files changed, 56 insertions(+), 1 deletion(-)
diff --git a/tests/libqtest.c b/tests/libqtest.c
index a3ee8ae..70a172e 100644
--- a/tests/libqtest.c
+++ b/tests/libqtest.c
@@ -388,7 +388,12 @@ QDict *qtest_qmp_receive(QTestState *s)
return qmp.response;
}
-QDict *qtest_qmpv(QTestState *s, const char *fmt, va_list ap)
+/**
+ * Allow users to send a message without waiting for the reply,
+ * in the case that they choose to discard all replies up until
+ * a particular EVENT is received.
+ */
+void qtest_async_qmpv(QTestState *s, const char *fmt, va_list ap)
{
va_list ap_copy;
QObject *qobj;
@@ -417,6 +422,11 @@ QDict *qtest_qmpv(QTestState *s, const char *fmt, va_list
ap)
QDECREF(qstr);
qobject_decref(qobj);
}
+}
+
+QDict *qtest_qmpv(QTestState *s, const char *fmt, va_list ap)
+{
+ qtest_async_qmpv(s, fmt, ap);
/* Receive reply */
return qtest_qmp_receive(s);
@@ -433,6 +443,15 @@ QDict *qtest_qmp(QTestState *s, const char *fmt, ...)
return response;
}
+void qtest_async_qmp(QTestState *s, const char *fmt, ...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+ qtest_async_qmpv(s, fmt, ap);
+ va_end(ap);
+}
+
void qtest_qmpv_discard_response(QTestState *s, const char *fmt, va_list ap)
{
QDict *response = qtest_qmpv(s, fmt, ap);
@@ -704,6 +723,15 @@ QDict *qmp(const char *fmt, ...)
return response;
}
+void qmp_async(const char *fmt, ...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+ qtest_async_qmpv(global_qtest, fmt, ap);
+ va_end(ap);
+}
+
void qmp_discard_response(const char *fmt, ...)
{
va_list ap;
diff --git a/tests/libqtest.h b/tests/libqtest.h
index 2aa2e6f..cc57124 100644
--- a/tests/libqtest.h
+++ b/tests/libqtest.h
@@ -64,6 +64,15 @@ void qtest_qmp_discard_response(QTestState *s, const char
*fmt, ...);
QDict *qtest_qmp(QTestState *s, const char *fmt, ...);
/**
+ * qtest_async_qmp:
+ * @s: #QTestState instance to operate on.
+ * @fmt...: QMP message to send to qemu
+ *
+ * Sends a QMP message to QEMU and leaves the response in the stream.
+ */
+void qtest_async_qmp(QTestState *s, const char *fmt, ...);
+
+/**
* qtest_qmpv_discard_response:
* @s: #QTestState instance to operate on.
* @fmt: QMP message to send to QEMU
@@ -84,6 +93,16 @@ void qtest_qmpv_discard_response(QTestState *s, const char
*fmt, va_list ap);
QDict *qtest_qmpv(QTestState *s, const char *fmt, va_list ap);
/**
+ * qtest_async_qmpv:
+ * @s: #QTestState instance to operate on.
+ * @fmt: QMP message to send to QEMU
+ * @ap: QMP message arguments
+ *
+ * Sends a QMP message to QEMU and leaves the response in the stream.
+ */
+void qtest_async_qmpv(QTestState *s, const char *fmt, va_list ap);
+
+/**
* qtest_receive:
* @s: #QTestState instance to operate on.
*
@@ -388,6 +407,14 @@ static inline void qtest_end(void)
QDict *qmp(const char *fmt, ...);
/**
+ * qmp_async:
+ * @fmt...: QMP message to send to qemu
+ *
+ * Sends a QMP message to QEMU and leaves the response in the stream.
+ */
+void qmp_async(const char *fmt, ...);
+
+/**
* qmp_discard_response:
* @fmt...: QMP message to send to qemu
*
--
2.1.0
- [Qemu-devel] [PULL 56/69] qtest/ahci: Add DMA test variants, (continued)
- [Qemu-devel] [PULL 56/69] qtest/ahci: Add DMA test variants, Stefan Hajnoczi, 2015/02/27
- [Qemu-devel] [PULL 54/69] qtest/ahci: Add a macro bootup routine, Stefan Hajnoczi, 2015/02/27
- [Qemu-devel] [PULL 58/69] qtest/ahci: add fragmented dma test, Stefan Hajnoczi, 2015/02/27
- [Qemu-devel] [PULL 55/69] libqos/ahci: add ahci command helpers, Stefan Hajnoczi, 2015/02/27
- [Qemu-devel] [PULL 57/69] qtest/ahci: Add PIO and LBA48 tests, Stefan Hajnoczi, 2015/02/27
- [Qemu-devel] [PULL 59/69] qtest/ahci: add qcow2 support to ahci-test, Stefan Hajnoczi, 2015/02/27
- [Qemu-devel] [PULL 61/69] qtest/ahci: Add simple flush test, Stefan Hajnoczi, 2015/02/27
- [Qemu-devel] [PULL 62/69] qtest/ahci: Allow override of default CLI options, Stefan Hajnoczi, 2015/02/27
- [Qemu-devel] [PULL 60/69] qtest/ahci: test different disk sectors, Stefan Hajnoczi, 2015/02/27
- [Qemu-devel] [PULL 63/69] libqtest: add qmp_eventwait, Stefan Hajnoczi, 2015/02/27
- [Qemu-devel] [PULL 64/69] libqtest: add qmp_async,
Stefan Hajnoczi <=
- [Qemu-devel] [PULL 65/69] libqos: add blkdebug_prepare_script, Stefan Hajnoczi, 2015/02/27
- [Qemu-devel] [PULL 66/69] qtest/ahci: add flush retry test, Stefan Hajnoczi, 2015/02/27
- [Qemu-devel] [PULL 69/69] tests: Check QVIRTIO_F_ANY_LAYOUT flag in virtio-blk test, Stefan Hajnoczi, 2015/02/27
- [Qemu-devel] [PULL 68/69] libqos: Solve bug in interrupt checking when using MSIX in virtio-pci.c, Stefan Hajnoczi, 2015/02/27
- [Qemu-devel] [PULL 67/69] sheepdog: fix confused return values, Stefan Hajnoczi, 2015/02/27
- Re: [Qemu-devel] [PULL 00/69] Block patches, Stefan Hajnoczi, 2015/02/27