]> Git Repo - qemu.git/commitdiff
libqtest: add qmp_async
authorJohn Snow <[email protected]>
Tue, 28 Apr 2015 19:27:51 +0000 (15:27 -0400)
committerJohn Snow <[email protected]>
Tue, 28 Apr 2015 19:27:51 +0000 (15:27 -0400)
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 <[email protected]>
Message-id: 1426018503[email protected]

tests/libqtest.c
tests/libqtest.h

index e2d01b47a2a18c6c2d8ff0ba3d6c66183f375693..659a3c7c63d6b1a47a0f3c2c1923ef0521108d86 100644 (file)
@@ -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);
@@ -711,6 +730,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;
index 30009ca5c95abcf7e024c720915df55f81bfaeb9..4b54b5da9eac93960856fb55bfed6b343e581b5b 100644 (file)
@@ -63,6 +63,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.
@@ -83,6 +92,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.
@@ -419,6 +438,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
This page took 0.031474 seconds and 4 git commands to generate.