aboutsummaryrefslogtreecommitdiff
path: root/tests/qtest/libqtest.h
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2024-11-15 16:50:39 +0000
committerFabiano Rosas <farosas@suse.de>2024-12-12 10:25:38 -0300
commit6b76264ed0fed402df09aab8edacf1ee03d87c7f (patch)
tree40db50b23e87d23b65c509e89d7cb44ba0ffc070 /tests/qtest/libqtest.h
parent94aa1a0e30065e06ee81cd9f71cccb0c393ede3f (diff)
downloadqemu-6b76264ed0fed402df09aab8edacf1ee03d87c7f.zip
qemu-6b76264ed0fed402df09aab8edacf1ee03d87c7f.tar.gz
qemu-6b76264ed0fed402df09aab8edacf1ee03d87c7f.tar.bz2
tests/qtest: Add qtest_system_reset() utility function
We have several qtest tests which want to reset the QEMU under test during the course of testing something. They currently generally have their own functions to do this, which work by sending a "system_reset" QMP command. However, "system_reset" only requests a reset, and many of the tests which send the QMP command forget the "and then wait for the QMP RESET event" part which is needed to ensure that the reset has completed. Provide a qtest_system_reset() function in libqtest so that we don't need to reimplement this in multiple different tests. A few tests (for example device hotplug related tests) want to perform the reset command and then wait for some other event that is produced during the reset sequence. For them we provide qtest_system_reset_nowait() so they can clearly indicate that they are deliberately not waiting for the RESET event. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Signed-off-by: Fabiano Rosas <farosas@suse.de>
Diffstat (limited to 'tests/qtest/libqtest.h')
-rw-r--r--tests/qtest/libqtest.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/qtest/libqtest.h b/tests/qtest/libqtest.h
index beb96b1..f23d80e 100644
--- a/tests/qtest/libqtest.h
+++ b/tests/qtest/libqtest.h
@@ -89,6 +89,31 @@ QTestState *qtest_init_without_qmp_handshake(const char *extra_args);
QTestState *qtest_init_with_serial(const char *extra_args, int *sock_fd);
/**
+ * qtest_system_reset:
+ * @s: #QTestState instance to operate on.
+ *
+ * Send a "system_reset" command to the QEMU under test, and wait for
+ * the reset to complete before returning.
+ */
+void qtest_system_reset(QTestState *s);
+
+/**
+ * qtest_system_reset_nowait:
+ * @s: #QTestState instance to operate on.
+ *
+ * Send a "system_reset" command to the QEMU under test, but do not
+ * wait for the reset to complete before returning. The caller is
+ * responsible for waiting for either the RESET event or some other
+ * event of interest to them before proceeding.
+ *
+ * This function should only be used if you're specifically testing
+ * for some other event; in that case you can't use qtest_system_reset()
+ * because it will read and discard any other QMP events that arrive
+ * before the RESET event.
+ */
+void qtest_system_reset_nowait(QTestState *s);
+
+/**
* qtest_wait_qemu:
* @s: #QTestState instance to operate on.
*