summaryrefslogtreecommitdiff
path: root/tests/libqtest.h
diff options
context:
space:
mode:
authorThomas Huth <thuth@redhat.com>2017-08-15 08:58:54 +0200
committerThomas Huth <thuth@redhat.com>2017-09-15 09:05:18 +0200
commitacd80015fbe28f4f513e036ad1db2a76738d1f53 (patch)
treeeb1db46ee8961cffdda43c21958bb4540a65c2d8 /tests/libqtest.h
parent3dabde1128b671f36ac6cb36b97b273139964420 (diff)
downloadqemu-acd80015fbe28f4f513e036ad1db2a76738d1f53.tar.gz
tests: Introduce generic device hot-plug/hot-unplug functions
A lot of tests provide code for adding and removing a device via the device_add and device_del QMP commands. Maintaining this code in so many places is cumbersome and error-prone (some of the code parts check the responses for device deletion in an incorrect way, for example, we've got to deal with both, error code and DEVICE_DEL event here). So let's provide some proper generic functions for adding and removing a device instead. The code for correctly unplugging a device has been taken from a patch from Peter Xu. Reviewed-by: Peter Xu <peterx@redhat.com> Tested-by: Peter Xu <peterx@redhat.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
Diffstat (limited to 'tests/libqtest.h')
-rw-r--r--tests/libqtest.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/libqtest.h b/tests/libqtest.h
index 3ae570927a..44803d772e 100644
--- a/tests/libqtest.h
+++ b/tests/libqtest.h
@@ -927,4 +927,23 @@ QDict *qmp_fd(int fd, const char *fmt, ...);
*/
void qtest_cb_for_every_machine(void (*cb)(const char *machine));
+/**
+ * qtest_qmp_device_add:
+ * @driver: Name of the device that should be added
+ * @id: Identification string
+ * @fmt: printf-like format string for further options to device_add
+ *
+ * Generic hot-plugging test via the device_add QMP command.
+ */
+void qtest_qmp_device_add(const char *driver, const char *id, const char *fmt,
+ ...) GCC_FMT_ATTR(3, 4);
+
+/**
+ * qtest_qmp_device_del:
+ * @id: Identification string
+ *
+ * Generic hot-unplugging test via the device_del QMP command.
+ */
+void qtest_qmp_device_del(const char *id);
+
#endif