xref: /qemu/tests/qtest/libqtest.h (revision 64965b4b30e6634ce874156ae94d336bfb0fdfd4)
149ee3590SAnthony Liguori /*
249ee3590SAnthony Liguori  * QTest
349ee3590SAnthony Liguori  *
449ee3590SAnthony Liguori  * Copyright IBM, Corp. 2012
549ee3590SAnthony Liguori  * Copyright Red Hat, Inc. 2012
6872536bfSAndreas Färber  * Copyright SUSE LINUX Products GmbH 2013
749ee3590SAnthony Liguori  *
849ee3590SAnthony Liguori  * Authors:
949ee3590SAnthony Liguori  *  Anthony Liguori   <aliguori@us.ibm.com>
1049ee3590SAnthony Liguori  *  Paolo Bonzini     <pbonzini@redhat.com>
11872536bfSAndreas Färber  *  Andreas Färber    <afaerber@suse.de>
1249ee3590SAnthony Liguori  *
1349ee3590SAnthony Liguori  * This work is licensed under the terms of the GNU GPL, version 2 or later.
1449ee3590SAnthony Liguori  * See the COPYING file in the top-level directory.
1549ee3590SAnthony Liguori  *
1649ee3590SAnthony Liguori  */
1749ee3590SAnthony Liguori #ifndef LIBQTEST_H
1849ee3590SAnthony Liguori #define LIBQTEST_H
1949ee3590SAnthony Liguori 
205cb8f0dbSPaolo Bonzini #include "qapi/qmp/qobject.h"
215cb8f0dbSPaolo Bonzini #include "qapi/qmp/qdict.h"
22c6d3bcb4SMarc-André Lureau #include "libqmp.h"
235cb8f0dbSPaolo Bonzini 
2449ee3590SAnthony Liguori typedef struct QTestState QTestState;
2549ee3590SAnthony Liguori 
2649ee3590SAnthony Liguori /**
2788b988c8SMarkus Armbruster  * qtest_initf:
2851c778edSEduardo Habkost  * @fmt: Format for creating other arguments to pass to QEMU, formatted
2978b27badSEric Blake  * like sprintf().
3078b27badSEric Blake  *
3100825d96SThomas Huth  * Convenience wrapper around qtest_init().
3278b27badSEric Blake  *
3378b27badSEric Blake  * Returns: #QTestState instance.
3478b27badSEric Blake  */
359edc6313SMarc-André Lureau QTestState *qtest_initf(const char *fmt, ...) G_GNUC_PRINTF(1, 2);
3678b27badSEric Blake 
3778b27badSEric Blake /**
3888b988c8SMarkus Armbruster  * qtest_vinitf:
3978b27badSEric Blake  * @fmt: Format for creating other arguments to pass to QEMU, formatted
4078b27badSEric Blake  * like vsprintf().
4178b27badSEric Blake  * @ap: Format arguments.
4278b27badSEric Blake  *
4300825d96SThomas Huth  * Convenience wrapper around qtest_init().
4478b27badSEric Blake  *
4578b27badSEric Blake  * Returns: #QTestState instance.
4678b27badSEric Blake  */
479edc6313SMarc-André Lureau QTestState *qtest_vinitf(const char *fmt, va_list ap) G_GNUC_PRINTF(1, 0);
4878b27badSEric Blake 
4978b27badSEric Blake /**
5049ee3590SAnthony Liguori  * qtest_init:
5188b988c8SMarkus Armbruster  * @extra_args: other arguments to pass to QEMU.  CAUTION: these
5288b988c8SMarkus Armbruster  * arguments are subject to word splitting and shell evaluation.
536acf801dSAndreas Färber  *
546acf801dSAndreas Färber  * Returns: #QTestState instance.
5549ee3590SAnthony Liguori  */
5649ee3590SAnthony Liguori QTestState *qtest_init(const char *extra_args);
5749ee3590SAnthony Liguori 
5849ee3590SAnthony Liguori /**
599931215bSFabiano Rosas  * qtest_init_with_env:
609931215bSFabiano Rosas  * @var: Environment variable from where to take the QEMU binary
619931215bSFabiano Rosas  * @extra_args: Other arguments to pass to QEMU.  CAUTION: these
629931215bSFabiano Rosas  * arguments are subject to word splitting and shell evaluation.
639931215bSFabiano Rosas  *
649931215bSFabiano Rosas  * Like qtest_init(), but use a different environment variable for the
659931215bSFabiano Rosas  * QEMU binary.
669931215bSFabiano Rosas  *
679931215bSFabiano Rosas  * Returns: #QTestState instance.
689931215bSFabiano Rosas  */
699931215bSFabiano Rosas QTestState *qtest_init_with_env(const char *var, const char *extra_args);
709931215bSFabiano Rosas 
719931215bSFabiano Rosas /**
72f66e7ac8SMarkus Armbruster  * qtest_init_without_qmp_handshake:
73ddee57e0SEric Blake  * @extra_args: other arguments to pass to QEMU.  CAUTION: these
74ddee57e0SEric Blake  * arguments are subject to word splitting and shell evaluation.
75f66e7ac8SMarkus Armbruster  *
76f66e7ac8SMarkus Armbruster  * Returns: #QTestState instance.
77f66e7ac8SMarkus Armbruster  */
78192f26a7SPeter Xu QTestState *qtest_init_without_qmp_handshake(const char *extra_args);
79f66e7ac8SMarkus Armbruster 
80f66e7ac8SMarkus Armbruster /**
816c90a82cSJulia Suvorova  * qtest_init_with_serial:
826c90a82cSJulia Suvorova  * @extra_args: other arguments to pass to QEMU.  CAUTION: these
836c90a82cSJulia Suvorova  * arguments are subject to word splitting and shell evaluation.
846c90a82cSJulia Suvorova  * @sock_fd: pointer to store the socket file descriptor for
856c90a82cSJulia Suvorova  * connection with serial.
866c90a82cSJulia Suvorova  *
876c90a82cSJulia Suvorova  * Returns: #QTestState instance.
886c90a82cSJulia Suvorova  */
896c90a82cSJulia Suvorova QTestState *qtest_init_with_serial(const char *extra_args, int *sock_fd);
906c90a82cSJulia Suvorova 
916c90a82cSJulia Suvorova /**
926b76264eSPeter Maydell  * qtest_system_reset:
936b76264eSPeter Maydell  * @s: #QTestState instance to operate on.
946b76264eSPeter Maydell  *
956b76264eSPeter Maydell  * Send a "system_reset" command to the QEMU under test, and wait for
966b76264eSPeter Maydell  * the reset to complete before returning.
976b76264eSPeter Maydell  */
986b76264eSPeter Maydell void qtest_system_reset(QTestState *s);
996b76264eSPeter Maydell 
1006b76264eSPeter Maydell /**
1016b76264eSPeter Maydell  * qtest_system_reset_nowait:
1026b76264eSPeter Maydell  * @s: #QTestState instance to operate on.
1036b76264eSPeter Maydell  *
1046b76264eSPeter Maydell  * Send a "system_reset" command to the QEMU under test, but do not
1056b76264eSPeter Maydell  * wait for the reset to complete before returning. The caller is
1066b76264eSPeter Maydell  * responsible for waiting for either the RESET event or some other
1076b76264eSPeter Maydell  * event of interest to them before proceeding.
1086b76264eSPeter Maydell  *
1096b76264eSPeter Maydell  * This function should only be used if you're specifically testing
1106b76264eSPeter Maydell  * for some other event; in that case you can't use qtest_system_reset()
1116b76264eSPeter Maydell  * because it will read and discard any other QMP events that arrive
1126b76264eSPeter Maydell  * before the RESET event.
1136b76264eSPeter Maydell  */
1146b76264eSPeter Maydell void qtest_system_reset_nowait(QTestState *s);
1156b76264eSPeter Maydell 
1166b76264eSPeter Maydell /**
11769c056fbSBin Meng  * qtest_wait_qemu:
11869c056fbSBin Meng  * @s: #QTestState instance to operate on.
11969c056fbSBin Meng  *
12069c056fbSBin Meng  * Wait for the QEMU process to terminate. It is safe to call this function
12169c056fbSBin Meng  * multiple times.
12269c056fbSBin Meng  */
12369c056fbSBin Meng void qtest_wait_qemu(QTestState *s);
12469c056fbSBin Meng 
12569c056fbSBin Meng /**
1267a23c523SStefan Hajnoczi  * qtest_kill_qemu:
1277a23c523SStefan Hajnoczi  * @s: #QTestState instance to operate on.
1287a23c523SStefan Hajnoczi  *
1297a23c523SStefan Hajnoczi  * Kill the QEMU process and wait for it to terminate. It is safe to call this
1307a23c523SStefan Hajnoczi  * function multiple times. Normally qtest_quit() is used instead because it
1317a23c523SStefan Hajnoczi  * also frees QTestState. Use qtest_kill_qemu() when you just want to kill QEMU
1327a23c523SStefan Hajnoczi  * and qtest_quit() will be called later.
1337a23c523SStefan Hajnoczi  */
1347a23c523SStefan Hajnoczi void qtest_kill_qemu(QTestState *s);
1357a23c523SStefan Hajnoczi 
1367a23c523SStefan Hajnoczi /**
13749ee3590SAnthony Liguori  * qtest_quit:
1386acf801dSAndreas Färber  * @s: #QTestState instance to operate on.
13949ee3590SAnthony Liguori  *
14049ee3590SAnthony Liguori  * Shut down the QEMU process associated to @s.
14149ee3590SAnthony Liguori  */
14249ee3590SAnthony Liguori void qtest_quit(QTestState *s);
14349ee3590SAnthony Liguori 
144490081b2SBin Meng #ifndef _WIN32
14549ee3590SAnthony Liguori /**
14624d5588cSYury Kotov  * qtest_qmp_fds:
14724d5588cSYury Kotov  * @s: #QTestState instance to operate on.
14824d5588cSYury Kotov  * @fds: array of file descriptors
14924d5588cSYury Kotov  * @fds_num: number of elements in @fds
15051c778edSEduardo Habkost  * @fmt: QMP message to send to qemu, formatted like
151ad57e2b1SPeter Maydell  * qobject_from_jsonf_nofail().  See parse_interpolation() for what's
15224d5588cSYury Kotov  * supported after '%'.
15324d5588cSYury Kotov  *
15424d5588cSYury Kotov  * Sends a QMP message to QEMU with fds and returns the response.
15524d5588cSYury Kotov  */
15624d5588cSYury Kotov QDict *qtest_qmp_fds(QTestState *s, int *fds, size_t fds_num,
15724d5588cSYury Kotov                      const char *fmt, ...)
1589edc6313SMarc-André Lureau     G_GNUC_PRINTF(4, 5);
159490081b2SBin Meng #endif /* _WIN32 */
16024d5588cSYury Kotov 
16124d5588cSYury Kotov /**
1620c460dacSStefan Hajnoczi  * qtest_qmp:
1630c460dacSStefan Hajnoczi  * @s: #QTestState instance to operate on.
16451c778edSEduardo Habkost  * @fmt: QMP message to send to qemu, formatted like
165ad57e2b1SPeter Maydell  * qobject_from_jsonf_nofail().  See parse_interpolation() for what's
1666ce80fd8SMarkus Armbruster  * supported after '%'.
1670c460dacSStefan Hajnoczi  *
1680c460dacSStefan Hajnoczi  * Sends a QMP message to QEMU and returns the response.
1690c460dacSStefan Hajnoczi  */
170e3dc93beSMarkus Armbruster QDict *qtest_qmp(QTestState *s, const char *fmt, ...)
1719edc6313SMarc-André Lureau     G_GNUC_PRINTF(2, 3);
1720c460dacSStefan Hajnoczi 
1730c460dacSStefan Hajnoczi /**
1744277f1ebSMarkus Armbruster  * qtest_qmp_send:
175ba4ed393SJohn Snow  * @s: #QTestState instance to operate on.
17651c778edSEduardo Habkost  * @fmt: QMP message to send to qemu, formatted like
177ad57e2b1SPeter Maydell  * qobject_from_jsonf_nofail().  See parse_interpolation() for what's
1786ce80fd8SMarkus Armbruster  * supported after '%'.
179ba4ed393SJohn Snow  *
180ba4ed393SJohn Snow  * Sends a QMP message to QEMU and leaves the response in the stream.
181ba4ed393SJohn Snow  */
182e3dc93beSMarkus Armbruster void qtest_qmp_send(QTestState *s, const char *fmt, ...)
1839edc6313SMarc-André Lureau     G_GNUC_PRINTF(2, 3);
184ba4ed393SJohn Snow 
185ba4ed393SJohn Snow /**
186aed877c5SMarkus Armbruster  * qtest_qmp_send_raw:
187aed877c5SMarkus Armbruster  * @s: #QTestState instance to operate on.
18851c778edSEduardo Habkost  * @fmt: text to send, formatted like sprintf()
189aed877c5SMarkus Armbruster  *
190aed877c5SMarkus Armbruster  * Sends text to the QMP monitor verbatim.  Need not be valid JSON;
191aed877c5SMarkus Armbruster  * this is useful for negative tests.
192aed877c5SMarkus Armbruster  */
193aed877c5SMarkus Armbruster void qtest_qmp_send_raw(QTestState *s, const char *fmt, ...)
1949edc6313SMarc-André Lureau     G_GNUC_PRINTF(2, 3);
195aed877c5SMarkus Armbruster 
196aed877c5SMarkus Armbruster /**
1979fb7bb06SStefan Hajnoczi  * qtest_socket_server:
1989fb7bb06SStefan Hajnoczi  * @socket_path: the UNIX domain socket path
1999fb7bb06SStefan Hajnoczi  *
2009fb7bb06SStefan Hajnoczi  * Create and return a listen socket file descriptor, or abort on failure.
2019fb7bb06SStefan Hajnoczi  */
2029fb7bb06SStefan Hajnoczi int qtest_socket_server(const char *socket_path);
2039fb7bb06SStefan Hajnoczi 
204490081b2SBin Meng #ifndef _WIN32
2059fb7bb06SStefan Hajnoczi /**
20624d5588cSYury Kotov  * qtest_vqmp_fds:
20724d5588cSYury Kotov  * @s: #QTestState instance to operate on.
20824d5588cSYury Kotov  * @fds: array of file descriptors
20924d5588cSYury Kotov  * @fds_num: number of elements in @fds
21024d5588cSYury Kotov  * @fmt: QMP message to send to QEMU, formatted like
211ad57e2b1SPeter Maydell  * qobject_from_jsonf_nofail().  See parse_interpolation() for what's
21224d5588cSYury Kotov  * supported after '%'.
21324d5588cSYury Kotov  * @ap: QMP message arguments
21424d5588cSYury Kotov  *
21524d5588cSYury Kotov  * Sends a QMP message to QEMU with fds and returns the response.
21624d5588cSYury Kotov  */
21724d5588cSYury Kotov QDict *qtest_vqmp_fds(QTestState *s, int *fds, size_t fds_num,
21824d5588cSYury Kotov                       const char *fmt, va_list ap)
2199edc6313SMarc-André Lureau     G_GNUC_PRINTF(4, 0);
220490081b2SBin Meng #endif /* _WIN32 */
22124d5588cSYury Kotov 
22224d5588cSYury Kotov /**
22324d5588cSYury Kotov  * qtest_vqmp:
2240c460dacSStefan Hajnoczi  * @s: #QTestState instance to operate on.
225bb340eb2SEric Blake  * @fmt: QMP message to send to QEMU, formatted like
226ad57e2b1SPeter Maydell  * qobject_from_jsonf_nofail().  See parse_interpolation() for what's
2276ce80fd8SMarkus Armbruster  * supported after '%'.
2280c460dacSStefan Hajnoczi  * @ap: QMP message arguments
2290c460dacSStefan Hajnoczi  *
2300c460dacSStefan Hajnoczi  * Sends a QMP message to QEMU and returns the response.
2310c460dacSStefan Hajnoczi  */
232248eef02SMarkus Armbruster QDict *qtest_vqmp(QTestState *s, const char *fmt, va_list ap)
2339edc6313SMarc-André Lureau     G_GNUC_PRINTF(2, 0);
2340c460dacSStefan Hajnoczi 
235490081b2SBin Meng #ifndef _WIN32
2360c460dacSStefan Hajnoczi /**
23724d5588cSYury Kotov  * qtest_qmp_vsend_fds:
23824d5588cSYury Kotov  * @s: #QTestState instance to operate on.
23924d5588cSYury Kotov  * @fds: array of file descriptors
24024d5588cSYury Kotov  * @fds_num: number of elements in @fds
24124d5588cSYury Kotov  * @fmt: QMP message to send to QEMU, formatted like
242ad57e2b1SPeter Maydell  * qobject_from_jsonf_nofail().  See parse_interpolation() for what's
24324d5588cSYury Kotov  * supported after '%'.
24424d5588cSYury Kotov  * @ap: QMP message arguments
24524d5588cSYury Kotov  *
24624d5588cSYury Kotov  * Sends a QMP message to QEMU and leaves the response in the stream.
24724d5588cSYury Kotov  */
24824d5588cSYury Kotov void qtest_qmp_vsend_fds(QTestState *s, int *fds, size_t fds_num,
24924d5588cSYury Kotov                          const char *fmt, va_list ap)
2509edc6313SMarc-André Lureau     G_GNUC_PRINTF(4, 0);
251490081b2SBin Meng #endif /* _WIN32 */
25224d5588cSYury Kotov 
25324d5588cSYury Kotov /**
2544277f1ebSMarkus Armbruster  * qtest_qmp_vsend:
255ba4ed393SJohn Snow  * @s: #QTestState instance to operate on.
256bb340eb2SEric Blake  * @fmt: QMP message to send to QEMU, formatted like
257ad57e2b1SPeter Maydell  * qobject_from_jsonf_nofail().  See parse_interpolation() for what's
2586ce80fd8SMarkus Armbruster  * supported after '%'.
259ba4ed393SJohn Snow  * @ap: QMP message arguments
260ba4ed393SJohn Snow  *
261ba4ed393SJohn Snow  * Sends a QMP message to QEMU and leaves the response in the stream.
262ba4ed393SJohn Snow  */
263e3dc93beSMarkus Armbruster void qtest_qmp_vsend(QTestState *s, const char *fmt, va_list ap)
2649edc6313SMarc-André Lureau     G_GNUC_PRINTF(2, 0);
265ba4ed393SJohn Snow 
266ba4ed393SJohn Snow /**
2671c3e2a38SMaxim Levitsky  * qtest_qmp_receive_dict:
26866e0c7b1SAndreas Färber  * @s: #QTestState instance to operate on.
26966e0c7b1SAndreas Färber  *
27066e0c7b1SAndreas Färber  * Reads a QMP message from QEMU and returns the response.
27166e0c7b1SAndreas Färber  */
2721c3e2a38SMaxim Levitsky QDict *qtest_qmp_receive_dict(QTestState *s);
27366e0c7b1SAndreas Färber 
27466e0c7b1SAndreas Färber /**
275c22045bfSMaxim Levitsky  * qtest_qmp_receive:
276c22045bfSMaxim Levitsky  * @s: #QTestState instance to operate on.
277c22045bfSMaxim Levitsky  *
278c22045bfSMaxim Levitsky  * Reads a QMP message from QEMU and returns the response.
2790150e75dSDaniel P. Berrangé  *
2800150e75dSDaniel P. Berrangé  * If a callback is registered with qtest_qmp_set_event_callback,
2810150e75dSDaniel P. Berrangé  * it will be invoked for every event seen, otherwise events
2820150e75dSDaniel P. Berrangé  * will be buffered until a call to one of the qtest_qmp_eventwait
2830150e75dSDaniel P. Berrangé  * family of functions.
284c22045bfSMaxim Levitsky  */
285c22045bfSMaxim Levitsky QDict *qtest_qmp_receive(QTestState *s);
286c22045bfSMaxim Levitsky 
2870150e75dSDaniel P. Berrangé /*
2880150e75dSDaniel P. Berrangé  * QTestQMPEventCallback:
2890150e75dSDaniel P. Berrangé  * @s: #QTestState instance event was received on
2900150e75dSDaniel P. Berrangé  * @name: name of the event type
2910150e75dSDaniel P. Berrangé  * @event: #QDict for the event details
2920150e75dSDaniel P. Berrangé  * @opaque: opaque data from time of callback registration
2930150e75dSDaniel P. Berrangé  *
2940150e75dSDaniel P. Berrangé  * This callback will be invoked whenever an event is received.
2950150e75dSDaniel P. Berrangé  * If the callback returns true the event will be consumed,
2960150e75dSDaniel P. Berrangé  * otherwise it will be put on the list of pending events.
2970150e75dSDaniel P. Berrangé  * Pending events can be later handled by calling either
2980150e75dSDaniel P. Berrangé  * qtest_qmp_eventwait or qtest_qmp_eventwait_ref.
2990150e75dSDaniel P. Berrangé  *
3000150e75dSDaniel P. Berrangé  * Return: true to consume the event, false to let it be queued
3010150e75dSDaniel P. Berrangé  */
3020150e75dSDaniel P. Berrangé typedef bool (*QTestQMPEventCallback)(QTestState *s, const char *name,
3030150e75dSDaniel P. Berrangé                                       QDict *event, void *opaque);
3040150e75dSDaniel P. Berrangé 
3050150e75dSDaniel P. Berrangé /**
3060150e75dSDaniel P. Berrangé  * qtest_qmp_set_event_callback:
3070150e75dSDaniel P. Berrangé  * @s: #QTestSTate instance to operate on
3080150e75dSDaniel P. Berrangé  * @cb: callback to invoke for events
3090150e75dSDaniel P. Berrangé  * @opaque: data to pass to @cb
3100150e75dSDaniel P. Berrangé  *
3110150e75dSDaniel P. Berrangé  * Register a callback to be invoked whenever an event arrives
3120150e75dSDaniel P. Berrangé  */
3130150e75dSDaniel P. Berrangé void qtest_qmp_set_event_callback(QTestState *s,
3140150e75dSDaniel P. Berrangé                                   QTestQMPEventCallback cb, void *opaque);
3150150e75dSDaniel P. Berrangé 
316c22045bfSMaxim Levitsky /**
3178fe941f7SJohn Snow  * qtest_qmp_eventwait:
3188fe941f7SJohn Snow  * @s: #QTestState instance to operate on.
31951c778edSEduardo Habkost  * @event: event to wait for.
3208fe941f7SJohn Snow  *
321e8ec0117SEric Blake  * Continuously polls for QMP responses until it receives the desired event.
3220150e75dSDaniel P. Berrangé  *
3230150e75dSDaniel P. Berrangé  * Any callback registered with qtest_qmp_set_event_callback will
3240150e75dSDaniel P. Berrangé  * be invoked for every event seen.
3258fe941f7SJohn Snow  */
3268fe941f7SJohn Snow void qtest_qmp_eventwait(QTestState *s, const char *event);
3278fe941f7SJohn Snow 
3288fe941f7SJohn Snow /**
3297ffe3124SJohn Snow  * qtest_qmp_eventwait_ref:
3307ffe3124SJohn Snow  * @s: #QTestState instance to operate on.
33151c778edSEduardo Habkost  * @event: event to wait for.
3327ffe3124SJohn Snow  *
333e8ec0117SEric Blake  * Continuously polls for QMP responses until it receives the desired event.
3340150e75dSDaniel P. Berrangé  *
3350150e75dSDaniel P. Berrangé  * Any callback registered with qtest_qmp_set_event_callback will
3360150e75dSDaniel P. Berrangé  * be invoked for every event seen.
3370150e75dSDaniel P. Berrangé  *
3387ffe3124SJohn Snow  * Returns a copy of the event for further investigation.
3397ffe3124SJohn Snow  */
3407ffe3124SJohn Snow QDict *qtest_qmp_eventwait_ref(QTestState *s, const char *event);
3417ffe3124SJohn Snow 
3427ffe3124SJohn Snow /**
343c22045bfSMaxim Levitsky  * qtest_qmp_event_ref:
344c22045bfSMaxim Levitsky  * @s: #QTestState instance to operate on.
345c22045bfSMaxim Levitsky  * @event: event to return.
346c22045bfSMaxim Levitsky  *
347c22045bfSMaxim Levitsky  * Removes non-matching events from the buffer that was set by
348c22045bfSMaxim Levitsky  * qtest_qmp_receive, until an event bearing the given name is found,
349c22045bfSMaxim Levitsky  * and returns it.
350c22045bfSMaxim Levitsky  * If no event matches, clears the buffer and returns NULL.
351c22045bfSMaxim Levitsky  *
352c22045bfSMaxim Levitsky  */
353c22045bfSMaxim Levitsky QDict *qtest_qmp_event_ref(QTestState *s, const char *event);
354c22045bfSMaxim Levitsky 
355c22045bfSMaxim Levitsky /**
3566bb87be8SThomas Huth  * qtest_hmp:
3575fb48d96SMarkus Armbruster  * @s: #QTestState instance to operate on.
35851c778edSEduardo Habkost  * @fmt: HMP command to send to QEMU, formats arguments like sprintf().
3595fb48d96SMarkus Armbruster  *
3605fb48d96SMarkus Armbruster  * Send HMP command to QEMU via QMP's human-monitor-command.
3616bb87be8SThomas Huth  * QMP events are discarded.
3625fb48d96SMarkus Armbruster  *
3635fb48d96SMarkus Armbruster  * Returns: the command's output.  The caller should g_free() it.
3645fb48d96SMarkus Armbruster  */
3659edc6313SMarc-André Lureau char *qtest_hmp(QTestState *s, const char *fmt, ...) G_GNUC_PRINTF(2, 3);
3665fb48d96SMarkus Armbruster 
3675fb48d96SMarkus Armbruster /**
368*64965b4bSAlex Bennée  * qtest_vhmp:
3695fb48d96SMarkus Armbruster  * @s: #QTestState instance to operate on.
370bb340eb2SEric Blake  * @fmt: HMP command to send to QEMU, formats arguments like vsprintf().
3715fb48d96SMarkus Armbruster  * @ap: HMP command arguments
3725fb48d96SMarkus Armbruster  *
3735fb48d96SMarkus Armbruster  * Send HMP command to QEMU via QMP's human-monitor-command.
3746bb87be8SThomas Huth  * QMP events are discarded.
3755fb48d96SMarkus Armbruster  *
3765fb48d96SMarkus Armbruster  * Returns: the command's output.  The caller should g_free() it.
3775fb48d96SMarkus Armbruster  */
378248eef02SMarkus Armbruster char *qtest_vhmp(QTestState *s, const char *fmt, va_list ap)
3799edc6313SMarc-André Lureau     G_GNUC_PRINTF(2, 0);
3805fb48d96SMarkus Armbruster 
381eb062cfaSMarc-André Lureau void qtest_module_load(QTestState *s, const char *prefix, const char *libname);
382eb062cfaSMarc-André Lureau 
3835fb48d96SMarkus Armbruster /**
38449ee3590SAnthony Liguori  * qtest_get_irq:
3856acf801dSAndreas Färber  * @s: #QTestState instance to operate on.
38649ee3590SAnthony Liguori  * @num: Interrupt to observe.
38749ee3590SAnthony Liguori  *
3886acf801dSAndreas Färber  * Returns: The level of the @num interrupt.
38949ee3590SAnthony Liguori  */
39049ee3590SAnthony Liguori bool qtest_get_irq(QTestState *s, int num);
39149ee3590SAnthony Liguori 
39249ee3590SAnthony Liguori /**
39349ee3590SAnthony Liguori  * qtest_irq_intercept_in:
3946acf801dSAndreas Färber  * @s: #QTestState instance to operate on.
39549ee3590SAnthony Liguori  * @string: QOM path of a device.
39649ee3590SAnthony Liguori  *
39749ee3590SAnthony Liguori  * Associate qtest irqs with the GPIO-in pins of the device
39849ee3590SAnthony Liguori  * whose path is specified by @string.
39949ee3590SAnthony Liguori  */
40049ee3590SAnthony Liguori void qtest_irq_intercept_in(QTestState *s, const char *string);
40149ee3590SAnthony Liguori 
40249ee3590SAnthony Liguori /**
40349ee3590SAnthony Liguori  * qtest_irq_intercept_out:
4046acf801dSAndreas Färber  * @s: #QTestState instance to operate on.
40549ee3590SAnthony Liguori  * @string: QOM path of a device.
40649ee3590SAnthony Liguori  *
40749ee3590SAnthony Liguori  * Associate qtest irqs with the GPIO-out pins of the device
40849ee3590SAnthony Liguori  * whose path is specified by @string.
40949ee3590SAnthony Liguori  */
41049ee3590SAnthony Liguori void qtest_irq_intercept_out(QTestState *s, const char *string);
41149ee3590SAnthony Liguori 
41249ee3590SAnthony Liguori /**
413a8610f8bSChris Laplante  * qtest_irq_intercept_out_named:
414a8610f8bSChris Laplante  * @s: #QTestState instance to operate on.
415a8610f8bSChris Laplante  * @qom_path: QOM path of a device.
416a8610f8bSChris Laplante  * @name: Name of the GPIO out pin
417a8610f8bSChris Laplante  *
418a8610f8bSChris Laplante  * Associate a qtest irq with the named GPIO-out pin of the device
419a8610f8bSChris Laplante  * whose path is specified by @string and whose name is @name.
420a8610f8bSChris Laplante  */
421a8610f8bSChris Laplante void qtest_irq_intercept_out_named(QTestState *s, const char *qom_path, const char *name);
422a8610f8bSChris Laplante 
423a8610f8bSChris Laplante /**
4249813dc6aSSteffen Görtz  * qtest_set_irq_in:
4259813dc6aSSteffen Görtz  * @s: QTestState instance to operate on.
4269813dc6aSSteffen Görtz  * @string: QOM path of a device
4279813dc6aSSteffen Görtz  * @name: IRQ name
4289813dc6aSSteffen Görtz  * @irq: IRQ number
4299813dc6aSSteffen Görtz  * @level: IRQ level
4309813dc6aSSteffen Görtz  *
4319813dc6aSSteffen Görtz  * Force given device/irq GPIO-in pin to the given level.
4329813dc6aSSteffen Görtz  */
4339813dc6aSSteffen Görtz void qtest_set_irq_in(QTestState *s, const char *string, const char *name,
4349813dc6aSSteffen Görtz                       int irq, int level);
4359813dc6aSSteffen Görtz 
4369813dc6aSSteffen Görtz /**
43749ee3590SAnthony Liguori  * qtest_outb:
4386acf801dSAndreas Färber  * @s: #QTestState instance to operate on.
43949ee3590SAnthony Liguori  * @addr: I/O port to write to.
44049ee3590SAnthony Liguori  * @value: Value being written.
44149ee3590SAnthony Liguori  *
44249ee3590SAnthony Liguori  * Write an 8-bit value to an I/O port.
44349ee3590SAnthony Liguori  */
44449ee3590SAnthony Liguori void qtest_outb(QTestState *s, uint16_t addr, uint8_t value);
44549ee3590SAnthony Liguori 
44649ee3590SAnthony Liguori /**
44749ee3590SAnthony Liguori  * qtest_outw:
4486acf801dSAndreas Färber  * @s: #QTestState instance to operate on.
44949ee3590SAnthony Liguori  * @addr: I/O port to write to.
45049ee3590SAnthony Liguori  * @value: Value being written.
45149ee3590SAnthony Liguori  *
45249ee3590SAnthony Liguori  * Write a 16-bit value to an I/O port.
45349ee3590SAnthony Liguori  */
45449ee3590SAnthony Liguori void qtest_outw(QTestState *s, uint16_t addr, uint16_t value);
45549ee3590SAnthony Liguori 
45649ee3590SAnthony Liguori /**
45749ee3590SAnthony Liguori  * qtest_outl:
4586acf801dSAndreas Färber  * @s: #QTestState instance to operate on.
45949ee3590SAnthony Liguori  * @addr: I/O port to write to.
46049ee3590SAnthony Liguori  * @value: Value being written.
46149ee3590SAnthony Liguori  *
46249ee3590SAnthony Liguori  * Write a 32-bit value to an I/O port.
46349ee3590SAnthony Liguori  */
46449ee3590SAnthony Liguori void qtest_outl(QTestState *s, uint16_t addr, uint32_t value);
46549ee3590SAnthony Liguori 
46649ee3590SAnthony Liguori /**
46749ee3590SAnthony Liguori  * qtest_inb:
4686acf801dSAndreas Färber  * @s: #QTestState instance to operate on.
46949ee3590SAnthony Liguori  * @addr: I/O port to read from.
47049ee3590SAnthony Liguori  *
47149ee3590SAnthony Liguori  * Returns an 8-bit value from an I/O port.
47249ee3590SAnthony Liguori  */
47349ee3590SAnthony Liguori uint8_t qtest_inb(QTestState *s, uint16_t addr);
47449ee3590SAnthony Liguori 
47549ee3590SAnthony Liguori /**
47649ee3590SAnthony Liguori  * qtest_inw:
4776acf801dSAndreas Färber  * @s: #QTestState instance to operate on.
47849ee3590SAnthony Liguori  * @addr: I/O port to read from.
47949ee3590SAnthony Liguori  *
48049ee3590SAnthony Liguori  * Returns a 16-bit value from an I/O port.
48149ee3590SAnthony Liguori  */
48249ee3590SAnthony Liguori uint16_t qtest_inw(QTestState *s, uint16_t addr);
48349ee3590SAnthony Liguori 
48449ee3590SAnthony Liguori /**
48549ee3590SAnthony Liguori  * qtest_inl:
4866acf801dSAndreas Färber  * @s: #QTestState instance to operate on.
48749ee3590SAnthony Liguori  * @addr: I/O port to read from.
48849ee3590SAnthony Liguori  *
48949ee3590SAnthony Liguori  * Returns a 32-bit value from an I/O port.
49049ee3590SAnthony Liguori  */
49149ee3590SAnthony Liguori uint32_t qtest_inl(QTestState *s, uint16_t addr);
49249ee3590SAnthony Liguori 
49349ee3590SAnthony Liguori /**
494872536bfSAndreas Färber  * qtest_writeb:
495872536bfSAndreas Färber  * @s: #QTestState instance to operate on.
496872536bfSAndreas Färber  * @addr: Guest address to write to.
497872536bfSAndreas Färber  * @value: Value being written.
498872536bfSAndreas Färber  *
499872536bfSAndreas Färber  * Writes an 8-bit value to memory.
500872536bfSAndreas Färber  */
501872536bfSAndreas Färber void qtest_writeb(QTestState *s, uint64_t addr, uint8_t value);
502872536bfSAndreas Färber 
503872536bfSAndreas Färber /**
504872536bfSAndreas Färber  * qtest_writew:
505872536bfSAndreas Färber  * @s: #QTestState instance to operate on.
506872536bfSAndreas Färber  * @addr: Guest address to write to.
507872536bfSAndreas Färber  * @value: Value being written.
508872536bfSAndreas Färber  *
509872536bfSAndreas Färber  * Writes a 16-bit value to memory.
510872536bfSAndreas Färber  */
511872536bfSAndreas Färber void qtest_writew(QTestState *s, uint64_t addr, uint16_t value);
512872536bfSAndreas Färber 
513872536bfSAndreas Färber /**
514872536bfSAndreas Färber  * qtest_writel:
515872536bfSAndreas Färber  * @s: #QTestState instance to operate on.
516872536bfSAndreas Färber  * @addr: Guest address to write to.
517872536bfSAndreas Färber  * @value: Value being written.
518872536bfSAndreas Färber  *
519872536bfSAndreas Färber  * Writes a 32-bit value to memory.
520872536bfSAndreas Färber  */
521872536bfSAndreas Färber void qtest_writel(QTestState *s, uint64_t addr, uint32_t value);
522872536bfSAndreas Färber 
523872536bfSAndreas Färber /**
524872536bfSAndreas Färber  * qtest_writeq:
525872536bfSAndreas Färber  * @s: #QTestState instance to operate on.
526872536bfSAndreas Färber  * @addr: Guest address to write to.
527872536bfSAndreas Färber  * @value: Value being written.
528872536bfSAndreas Färber  *
529872536bfSAndreas Färber  * Writes a 64-bit value to memory.
530872536bfSAndreas Färber  */
531872536bfSAndreas Färber void qtest_writeq(QTestState *s, uint64_t addr, uint64_t value);
532872536bfSAndreas Färber 
533872536bfSAndreas Färber /**
534872536bfSAndreas Färber  * qtest_readb:
535872536bfSAndreas Färber  * @s: #QTestState instance to operate on.
536872536bfSAndreas Färber  * @addr: Guest address to read from.
537872536bfSAndreas Färber  *
538872536bfSAndreas Färber  * Reads an 8-bit value from memory.
539872536bfSAndreas Färber  *
540872536bfSAndreas Färber  * Returns: Value read.
541872536bfSAndreas Färber  */
542872536bfSAndreas Färber uint8_t qtest_readb(QTestState *s, uint64_t addr);
543872536bfSAndreas Färber 
544872536bfSAndreas Färber /**
545872536bfSAndreas Färber  * qtest_readw:
546872536bfSAndreas Färber  * @s: #QTestState instance to operate on.
547872536bfSAndreas Färber  * @addr: Guest address to read from.
548872536bfSAndreas Färber  *
549872536bfSAndreas Färber  * Reads a 16-bit value from memory.
550872536bfSAndreas Färber  *
551872536bfSAndreas Färber  * Returns: Value read.
552872536bfSAndreas Färber  */
553872536bfSAndreas Färber uint16_t qtest_readw(QTestState *s, uint64_t addr);
554872536bfSAndreas Färber 
555872536bfSAndreas Färber /**
556872536bfSAndreas Färber  * qtest_readl:
557872536bfSAndreas Färber  * @s: #QTestState instance to operate on.
558872536bfSAndreas Färber  * @addr: Guest address to read from.
559872536bfSAndreas Färber  *
560872536bfSAndreas Färber  * Reads a 32-bit value from memory.
561872536bfSAndreas Färber  *
562872536bfSAndreas Färber  * Returns: Value read.
563872536bfSAndreas Färber  */
564872536bfSAndreas Färber uint32_t qtest_readl(QTestState *s, uint64_t addr);
565872536bfSAndreas Färber 
566872536bfSAndreas Färber /**
567872536bfSAndreas Färber  * qtest_readq:
568872536bfSAndreas Färber  * @s: #QTestState instance to operate on.
569872536bfSAndreas Färber  * @addr: Guest address to read from.
570872536bfSAndreas Färber  *
571872536bfSAndreas Färber  * Reads a 64-bit value from memory.
572872536bfSAndreas Färber  *
573872536bfSAndreas Färber  * Returns: Value read.
574872536bfSAndreas Färber  */
575872536bfSAndreas Färber uint64_t qtest_readq(QTestState *s, uint64_t addr);
576872536bfSAndreas Färber 
577872536bfSAndreas Färber /**
57849ee3590SAnthony Liguori  * qtest_memread:
5796acf801dSAndreas Färber  * @s: #QTestState instance to operate on.
58049ee3590SAnthony Liguori  * @addr: Guest address to read from.
58149ee3590SAnthony Liguori  * @data: Pointer to where memory contents will be stored.
58249ee3590SAnthony Liguori  * @size: Number of bytes to read.
58349ee3590SAnthony Liguori  *
58449ee3590SAnthony Liguori  * Read guest memory into a buffer.
58549ee3590SAnthony Liguori  */
58649ee3590SAnthony Liguori void qtest_memread(QTestState *s, uint64_t addr, void *data, size_t size);
58749ee3590SAnthony Liguori 
58849ee3590SAnthony Liguori /**
589eeddd59fSLaurent Vivier  * qtest_rtas_call:
590eeddd59fSLaurent Vivier  * @s: #QTestState instance to operate on.
591eeddd59fSLaurent Vivier  * @name: name of the command to call.
592eeddd59fSLaurent Vivier  * @nargs: Number of args.
593eeddd59fSLaurent Vivier  * @args: Guest address to read args from.
594eeddd59fSLaurent Vivier  * @nret: Number of return value.
595eeddd59fSLaurent Vivier  * @ret: Guest address to write return values to.
596eeddd59fSLaurent Vivier  *
597eeddd59fSLaurent Vivier  * Call an RTAS function
598eeddd59fSLaurent Vivier  */
599eeddd59fSLaurent Vivier uint64_t qtest_rtas_call(QTestState *s, const char *name,
600eeddd59fSLaurent Vivier                          uint32_t nargs, uint64_t args,
601eeddd59fSLaurent Vivier                          uint32_t nret, uint64_t ret);
602eeddd59fSLaurent Vivier 
603eeddd59fSLaurent Vivier /**
6047a6a740dSJohn Snow  * qtest_bufread:
6057a6a740dSJohn Snow  * @s: #QTestState instance to operate on.
6067a6a740dSJohn Snow  * @addr: Guest address to read from.
6077a6a740dSJohn Snow  * @data: Pointer to where memory contents will be stored.
6087a6a740dSJohn Snow  * @size: Number of bytes to read.
6097a6a740dSJohn Snow  *
6107a6a740dSJohn Snow  * Read guest memory into a buffer and receive using a base64 encoding.
6117a6a740dSJohn Snow  */
6127a6a740dSJohn Snow void qtest_bufread(QTestState *s, uint64_t addr, void *data, size_t size);
6137a6a740dSJohn Snow 
6147a6a740dSJohn Snow /**
61549ee3590SAnthony Liguori  * qtest_memwrite:
6166acf801dSAndreas Färber  * @s: #QTestState instance to operate on.
61749ee3590SAnthony Liguori  * @addr: Guest address to write to.
61849ee3590SAnthony Liguori  * @data: Pointer to the bytes that will be written to guest memory.
61949ee3590SAnthony Liguori  * @size: Number of bytes to write.
62049ee3590SAnthony Liguori  *
62149ee3590SAnthony Liguori  * Write a buffer to guest memory.
62249ee3590SAnthony Liguori  */
62349ee3590SAnthony Liguori void qtest_memwrite(QTestState *s, uint64_t addr, const void *data, size_t size);
62449ee3590SAnthony Liguori 
62549ee3590SAnthony Liguori /**
6267a6a740dSJohn Snow  * qtest_bufwrite:
6277a6a740dSJohn Snow  * @s: #QTestState instance to operate on.
6287a6a740dSJohn Snow  * @addr: Guest address to write to.
6297a6a740dSJohn Snow  * @data: Pointer to the bytes that will be written to guest memory.
6307a6a740dSJohn Snow  * @size: Number of bytes to write.
6317a6a740dSJohn Snow  *
6327a6a740dSJohn Snow  * Write a buffer to guest memory and transmit using a base64 encoding.
6337a6a740dSJohn Snow  */
6347a6a740dSJohn Snow void qtest_bufwrite(QTestState *s, uint64_t addr,
6357a6a740dSJohn Snow                     const void *data, size_t size);
6367a6a740dSJohn Snow 
6377a6a740dSJohn Snow /**
63886298845SJohn Snow  * qtest_memset:
63986298845SJohn Snow  * @s: #QTestState instance to operate on.
64086298845SJohn Snow  * @addr: Guest address to write to.
64186298845SJohn Snow  * @patt: Byte pattern to fill the guest memory region with.
64286298845SJohn Snow  * @size: Number of bytes to write.
64386298845SJohn Snow  *
64486298845SJohn Snow  * Write a pattern to guest memory.
64586298845SJohn Snow  */
64686298845SJohn Snow void qtest_memset(QTestState *s, uint64_t addr, uint8_t patt, size_t size);
64786298845SJohn Snow 
64886298845SJohn Snow /**
64949ee3590SAnthony Liguori  * qtest_clock_step_next:
6506acf801dSAndreas Färber  * @s: #QTestState instance to operate on.
65149ee3590SAnthony Liguori  *
652bc72ad67SAlex Bligh  * Advance the QEMU_CLOCK_VIRTUAL to the next deadline.
6536acf801dSAndreas Färber  *
654bc72ad67SAlex Bligh  * Returns: The current value of the QEMU_CLOCK_VIRTUAL in nanoseconds.
65549ee3590SAnthony Liguori  */
65649ee3590SAnthony Liguori int64_t qtest_clock_step_next(QTestState *s);
65749ee3590SAnthony Liguori 
65849ee3590SAnthony Liguori /**
65949ee3590SAnthony Liguori  * qtest_clock_step:
66049ee3590SAnthony Liguori  * @s: QTestState instance to operate on.
66149ee3590SAnthony Liguori  * @step: Number of nanoseconds to advance the clock by.
66249ee3590SAnthony Liguori  *
663bc72ad67SAlex Bligh  * Advance the QEMU_CLOCK_VIRTUAL by @step nanoseconds.
6646acf801dSAndreas Färber  *
665bc72ad67SAlex Bligh  * Returns: The current value of the QEMU_CLOCK_VIRTUAL in nanoseconds.
66649ee3590SAnthony Liguori  */
66749ee3590SAnthony Liguori int64_t qtest_clock_step(QTestState *s, int64_t step);
66849ee3590SAnthony Liguori 
66949ee3590SAnthony Liguori /**
67049ee3590SAnthony Liguori  * qtest_clock_set:
67149ee3590SAnthony Liguori  * @s: QTestState instance to operate on.
67249ee3590SAnthony Liguori  * @val: Nanoseconds value to advance the clock to.
67349ee3590SAnthony Liguori  *
674bc72ad67SAlex Bligh  * Advance the QEMU_CLOCK_VIRTUAL to @val nanoseconds since the VM was launched.
6756acf801dSAndreas Färber  *
676bc72ad67SAlex Bligh  * Returns: The current value of the QEMU_CLOCK_VIRTUAL in nanoseconds.
67749ee3590SAnthony Liguori  */
67849ee3590SAnthony Liguori int64_t qtest_clock_set(QTestState *s, int64_t val);
67949ee3590SAnthony Liguori 
68049ee3590SAnthony Liguori /**
68154ce6f22SLaurent Vivier  * qtest_big_endian:
68254ce6f22SLaurent Vivier  * @s: QTestState instance to operate on.
68354ce6f22SLaurent Vivier  *
68454ce6f22SLaurent Vivier  * Returns: True if the architecture under test has a big endian configuration.
68554ce6f22SLaurent Vivier  */
68654ce6f22SLaurent Vivier bool qtest_big_endian(QTestState *s);
68754ce6f22SLaurent Vivier 
68854ce6f22SLaurent Vivier /**
68949ee3590SAnthony Liguori  * qtest_get_arch:
69049ee3590SAnthony Liguori  *
6916acf801dSAndreas Färber  * Returns: The architecture for the QEMU executable under test.
69249ee3590SAnthony Liguori  */
69349ee3590SAnthony Liguori const char *qtest_get_arch(void);
69449ee3590SAnthony Liguori 
69549ee3590SAnthony Liguori /**
696e741aff0SIgor Mammedov  * qtest_has_accel:
697e741aff0SIgor Mammedov  * @accel_name: Accelerator name to check for.
698e741aff0SIgor Mammedov  *
699e741aff0SIgor Mammedov  * Returns: true if the accelerator is built in.
700e741aff0SIgor Mammedov  */
701e741aff0SIgor Mammedov bool qtest_has_accel(const char *accel_name);
702e741aff0SIgor Mammedov 
703e741aff0SIgor Mammedov /**
70449ee3590SAnthony Liguori  * qtest_add_func:
70549ee3590SAnthony Liguori  * @str: Test case path.
70649ee3590SAnthony Liguori  * @fn: Test case function
70749ee3590SAnthony Liguori  *
70849ee3590SAnthony Liguori  * Add a GTester testcase with the given name and function.
70949ee3590SAnthony Liguori  * The path is prefixed with the architecture under test, as
7106acf801dSAndreas Färber  * returned by qtest_get_arch().
71149ee3590SAnthony Liguori  */
712041088c7SMarkus Armbruster void qtest_add_func(const char *str, void (*fn)(void));
71349ee3590SAnthony Liguori 
71449ee3590SAnthony Liguori /**
7157949c0e3SAndreas Färber  * qtest_add_data_func:
7167949c0e3SAndreas Färber  * @str: Test case path.
7177949c0e3SAndreas Färber  * @data: Test case data
7187949c0e3SAndreas Färber  * @fn: Test case function
7197949c0e3SAndreas Färber  *
7207949c0e3SAndreas Färber  * Add a GTester testcase with the given name, data and function.
7217949c0e3SAndreas Färber  * The path is prefixed with the architecture under test, as
7227949c0e3SAndreas Färber  * returned by qtest_get_arch().
7237949c0e3SAndreas Färber  */
724041088c7SMarkus Armbruster void qtest_add_data_func(const char *str, const void *data,
725041088c7SMarkus Armbruster                          void (*fn)(const void *));
7267949c0e3SAndreas Färber 
7277949c0e3SAndreas Färber /**
728822e36caSMarc-André Lureau  * qtest_add_data_func_full:
729822e36caSMarc-André Lureau  * @str: Test case path.
730822e36caSMarc-André Lureau  * @data: Test case data
731822e36caSMarc-André Lureau  * @fn: Test case function
732822e36caSMarc-André Lureau  * @data_free_func: GDestroyNotify for data
733822e36caSMarc-André Lureau  *
734822e36caSMarc-André Lureau  * Add a GTester testcase with the given name, data and function.
735822e36caSMarc-André Lureau  * The path is prefixed with the architecture under test, as
736822e36caSMarc-André Lureau  * returned by qtest_get_arch().
737822e36caSMarc-André Lureau  *
738822e36caSMarc-André Lureau  * @data is passed to @data_free_func() on test completion.
739822e36caSMarc-André Lureau  */
740822e36caSMarc-André Lureau void qtest_add_data_func_full(const char *str, void *data,
741822e36caSMarc-André Lureau                               void (*fn)(const void *),
742822e36caSMarc-André Lureau                               GDestroyNotify data_free_func);
743822e36caSMarc-André Lureau 
744822e36caSMarc-André Lureau /**
74545b0f830SAndreas Färber  * qtest_add:
74645b0f830SAndreas Färber  * @testpath: Test case path
74745b0f830SAndreas Färber  * @Fixture: Fixture type
74845b0f830SAndreas Färber  * @tdata: Test case data
74945b0f830SAndreas Färber  * @fsetup: Test case setup function
75045b0f830SAndreas Färber  * @ftest: Test case function
75145b0f830SAndreas Färber  * @fteardown: Test case teardown function
75245b0f830SAndreas Färber  *
75345b0f830SAndreas Färber  * Add a GTester testcase with the given name, data and functions.
75445b0f830SAndreas Färber  * The path is prefixed with the architecture under test, as
75545b0f830SAndreas Färber  * returned by qtest_get_arch().
75645b0f830SAndreas Färber  */
75745b0f830SAndreas Färber #define qtest_add(testpath, Fixture, tdata, fsetup, ftest, fteardown) \
75845b0f830SAndreas Färber     do { \
75945b0f830SAndreas Färber         char *path = g_strdup_printf("/%s/%s", qtest_get_arch(), testpath); \
76045b0f830SAndreas Färber         g_test_add(path, Fixture, tdata, fsetup, ftest, fteardown); \
76145b0f830SAndreas Färber         g_free(path); \
76245b0f830SAndreas Färber     } while (0)
76345b0f830SAndreas Färber 
764e1fa7f55SStefan Hajnoczi /**
765e1fa7f55SStefan Hajnoczi  * qtest_add_abrt_handler:
766e1fa7f55SStefan Hajnoczi  * @fn: Handler function
767e1fa7f55SStefan Hajnoczi  * @data: Argument that is passed to the handler
768e1fa7f55SStefan Hajnoczi  *
769e1fa7f55SStefan Hajnoczi  * Add a handler function that is invoked on SIGABRT. This can be used to
770e1fa7f55SStefan Hajnoczi  * terminate processes and perform other cleanup. The handler can be removed
771e1fa7f55SStefan Hajnoczi  * with qtest_remove_abrt_handler().
772e1fa7f55SStefan Hajnoczi  */
773041088c7SMarkus Armbruster void qtest_add_abrt_handler(GHookFunc fn, const void *data);
774063c23d9SMarc-André Lureau 
77545b0f830SAndreas Färber /**
776e1fa7f55SStefan Hajnoczi  * qtest_remove_abrt_handler:
777e1fa7f55SStefan Hajnoczi  * @data: Argument previously passed to qtest_add_abrt_handler()
778e1fa7f55SStefan Hajnoczi  *
779e1fa7f55SStefan Hajnoczi  * Remove an abrt handler that was previously added with
780e1fa7f55SStefan Hajnoczi  * qtest_add_abrt_handler().
781e1fa7f55SStefan Hajnoczi  */
782e1fa7f55SStefan Hajnoczi void qtest_remove_abrt_handler(void *data);
783e1fa7f55SStefan Hajnoczi 
784e1fa7f55SStefan Hajnoczi /**
78528760edcSDaniel P. Berrangé  * qtest_vqmp_assert_success_ref:
78628760edcSDaniel P. Berrangé  * @qts: QTestState instance to operate on
78728760edcSDaniel P. Berrangé  * @fmt: QMP message to send to qemu, formatted like
78828760edcSDaniel P. Berrangé  * qobject_from_jsonf_nofail().  See parse_interpolation() for what's
78928760edcSDaniel P. Berrangé  * supported after '%'.
79028760edcSDaniel P. Berrangé  * @args: variable arguments for @fmt
79128760edcSDaniel P. Berrangé  *
79228760edcSDaniel P. Berrangé  * Sends a QMP message to QEMU, asserts that a 'return' key is present in
79328760edcSDaniel P. Berrangé  * the response, and returns the response.
79428760edcSDaniel P. Berrangé  */
79528760edcSDaniel P. Berrangé QDict *qtest_vqmp_assert_success_ref(QTestState *qts,
79628760edcSDaniel P. Berrangé                                      const char *fmt, va_list args)
79728760edcSDaniel P. Berrangé     G_GNUC_PRINTF(2, 0);
79828760edcSDaniel P. Berrangé 
79928760edcSDaniel P. Berrangé /**
80028760edcSDaniel P. Berrangé  * qtest_vqmp_assert_success:
80128760edcSDaniel P. Berrangé  * @qts: QTestState instance to operate on
80228760edcSDaniel P. Berrangé  * @fmt: QMP message to send to qemu, formatted like
80328760edcSDaniel P. Berrangé  * qobject_from_jsonf_nofail().  See parse_interpolation() for what's
80428760edcSDaniel P. Berrangé  * supported after '%'.
80528760edcSDaniel P. Berrangé  * @args: variable arguments for @fmt
80628760edcSDaniel P. Berrangé  *
80728760edcSDaniel P. Berrangé  * Sends a QMP message to QEMU and asserts that a 'return' key is present in
80828760edcSDaniel P. Berrangé  * the response.
80928760edcSDaniel P. Berrangé  */
81028760edcSDaniel P. Berrangé void qtest_vqmp_assert_success(QTestState *qts,
81128760edcSDaniel P. Berrangé                                const char *fmt, va_list args)
81228760edcSDaniel P. Berrangé     G_GNUC_PRINTF(2, 0);
81328760edcSDaniel P. Berrangé 
81428760edcSDaniel P. Berrangé #ifndef _WIN32
81528760edcSDaniel P. Berrangé /**
81628760edcSDaniel P. Berrangé  * qtest_vqmp_fds_assert_success_ref:
81728760edcSDaniel P. Berrangé  * @qts: QTestState instance to operate on
81828760edcSDaniel P. Berrangé  * @fds: the file descriptors to send
81928760edcSDaniel P. Berrangé  * @nfds: number of @fds to send
82028760edcSDaniel P. Berrangé  * @fmt: QMP message to send to qemu, formatted like
82128760edcSDaniel P. Berrangé  * qobject_from_jsonf_nofail().  See parse_interpolation() for what's
82228760edcSDaniel P. Berrangé  * supported after '%'.
82328760edcSDaniel P. Berrangé  * @args: variable arguments for @fmt
82428760edcSDaniel P. Berrangé  *
82528760edcSDaniel P. Berrangé  * Sends a QMP message with file descriptors to QEMU,
82628760edcSDaniel P. Berrangé  * asserts that a 'return' key is present in the response,
82728760edcSDaniel P. Berrangé  * and returns the response.
82828760edcSDaniel P. Berrangé  */
82928760edcSDaniel P. Berrangé QDict *qtest_vqmp_fds_assert_success_ref(QTestState *qts, int *fds, size_t nfds,
83028760edcSDaniel P. Berrangé                                          const char *fmt, va_list args)
83128760edcSDaniel P. Berrangé     G_GNUC_PRINTF(4, 0);
83228760edcSDaniel P. Berrangé 
83328760edcSDaniel P. Berrangé /**
83428760edcSDaniel P. Berrangé  * qtest_vqmp_fds_assert_success:
83528760edcSDaniel P. Berrangé  * @qts: QTestState instance to operate on
83628760edcSDaniel P. Berrangé  * @fds: the file descriptors to send
83728760edcSDaniel P. Berrangé  * @nfds: number of @fds to send
83828760edcSDaniel P. Berrangé  * @fmt: QMP message to send to qemu, formatted like
83928760edcSDaniel P. Berrangé  * qobject_from_jsonf_nofail().  See parse_interpolation() for what's
84028760edcSDaniel P. Berrangé  * supported after '%'.
84128760edcSDaniel P. Berrangé  * @args: variable arguments for @fmt
84228760edcSDaniel P. Berrangé  *
84328760edcSDaniel P. Berrangé  * Sends a QMP message with file descriptors to QEMU and
84428760edcSDaniel P. Berrangé  * asserts that a 'return' key is present in the response.
84528760edcSDaniel P. Berrangé  */
84628760edcSDaniel P. Berrangé void qtest_vqmp_fds_assert_success(QTestState *qts, int *fds, size_t nfds,
84728760edcSDaniel P. Berrangé                                    const char *fmt, va_list args)
84828760edcSDaniel P. Berrangé     G_GNUC_PRINTF(4, 0);
84928760edcSDaniel P. Berrangé #endif /* !_WIN32 */
85028760edcSDaniel P. Berrangé 
85128760edcSDaniel P. Berrangé /**
8525274274cSFabiano Rosas  * qtest_qmp_assert_failure_ref:
8535274274cSFabiano Rosas  * @qts: QTestState instance to operate on
8545274274cSFabiano Rosas  * @fmt: QMP message to send to qemu, formatted like
8555274274cSFabiano Rosas  * qobject_from_jsonf_nofail().  See parse_interpolation() for what's
8565274274cSFabiano Rosas  * supported after '%'.
8575274274cSFabiano Rosas  *
8585274274cSFabiano Rosas  * Sends a QMP message to QEMU, asserts that an 'error' key is present in
8595274274cSFabiano Rosas  * the response, and returns the response.
8605274274cSFabiano Rosas  */
8615274274cSFabiano Rosas QDict *qtest_qmp_assert_failure_ref(QTestState *qts, const char *fmt, ...)
8625274274cSFabiano Rosas     G_GNUC_PRINTF(2, 3);
8635274274cSFabiano Rosas 
8645274274cSFabiano Rosas /**
8655274274cSFabiano Rosas  * qtest_vqmp_assert_failure_ref:
8665274274cSFabiano Rosas  * @qts: QTestState instance to operate on
8675274274cSFabiano Rosas  * @fmt: QMP message to send to qemu, formatted like
8685274274cSFabiano Rosas  * qobject_from_jsonf_nofail().  See parse_interpolation() for what's
8695274274cSFabiano Rosas  * supported after '%'.
8705274274cSFabiano Rosas  * @args: variable arguments for @fmt
8715274274cSFabiano Rosas  *
8725274274cSFabiano Rosas  * Sends a QMP message to QEMU, asserts that an 'error' key is present in
8735274274cSFabiano Rosas  * the response, and returns the response.
8745274274cSFabiano Rosas  */
8755274274cSFabiano Rosas QDict *qtest_vqmp_assert_failure_ref(QTestState *qts,
8765274274cSFabiano Rosas                                      const char *fmt, va_list args)
8775274274cSFabiano Rosas     G_GNUC_PRINTF(2, 0);
8785274274cSFabiano Rosas 
8795274274cSFabiano Rosas /**
88028760edcSDaniel P. Berrangé  * qtest_qmp_assert_success_ref:
88128760edcSDaniel P. Berrangé  * @qts: QTestState instance to operate on
88228760edcSDaniel P. Berrangé  * @fmt: QMP message to send to qemu, formatted like
88328760edcSDaniel P. Berrangé  * qobject_from_jsonf_nofail().  See parse_interpolation() for what's
88428760edcSDaniel P. Berrangé  * supported after '%'.
88528760edcSDaniel P. Berrangé  *
88628760edcSDaniel P. Berrangé  * Sends a QMP message to QEMU, asserts that a 'return' key is present in
88728760edcSDaniel P. Berrangé  * the response, and returns the response.
88828760edcSDaniel P. Berrangé  */
88928760edcSDaniel P. Berrangé QDict *qtest_qmp_assert_success_ref(QTestState *qts, const char *fmt, ...)
89028760edcSDaniel P. Berrangé     G_GNUC_PRINTF(2, 3);
89128760edcSDaniel P. Berrangé 
89228760edcSDaniel P. Berrangé /**
8936fc9f3d3SThomas Huth  * qtest_qmp_assert_success:
8946fc9f3d3SThomas Huth  * @qts: QTestState instance to operate on
89551c778edSEduardo Habkost  * @fmt: QMP message to send to qemu, formatted like
896ad57e2b1SPeter Maydell  * qobject_from_jsonf_nofail().  See parse_interpolation() for what's
897edbe36adSKevin Wolf  * supported after '%'.
898edbe36adSKevin Wolf  *
899edbe36adSKevin Wolf  * Sends a QMP message to QEMU and asserts that a 'return' key is present in
900edbe36adSKevin Wolf  * the response.
901edbe36adSKevin Wolf  */
9026fc9f3d3SThomas Huth void qtest_qmp_assert_success(QTestState *qts, const char *fmt, ...)
9039edc6313SMarc-André Lureau     G_GNUC_PRINTF(2, 3);
904edbe36adSKevin Wolf 
90528760edcSDaniel P. Berrangé #ifndef _WIN32
90628760edcSDaniel P. Berrangé /**
907*64965b4bSAlex Bennée  * qtest_qmp_fds_assert_success_ref:
90828760edcSDaniel P. Berrangé  * @qts: QTestState instance to operate on
90928760edcSDaniel P. Berrangé  * @fds: the file descriptors to send
91028760edcSDaniel P. Berrangé  * @nfds: number of @fds to send
91128760edcSDaniel P. Berrangé  * @fmt: QMP message to send to qemu, formatted like
91228760edcSDaniel P. Berrangé  * qobject_from_jsonf_nofail().  See parse_interpolation() for what's
91328760edcSDaniel P. Berrangé  * supported after '%'.
91428760edcSDaniel P. Berrangé  *
91528760edcSDaniel P. Berrangé  * Sends a QMP message with file descriptors to QEMU,
91628760edcSDaniel P. Berrangé  * asserts that a 'return' key is present in the response,
91728760edcSDaniel P. Berrangé  * and returns the response.
91828760edcSDaniel P. Berrangé  */
91928760edcSDaniel P. Berrangé QDict *qtest_qmp_fds_assert_success_ref(QTestState *qts, int *fds, size_t nfds,
92028760edcSDaniel P. Berrangé                                         const char *fmt, ...)
92128760edcSDaniel P. Berrangé     G_GNUC_PRINTF(4, 5);
92228760edcSDaniel P. Berrangé 
92328760edcSDaniel P. Berrangé /**
924*64965b4bSAlex Bennée  * qtest_qmp_fds_assert_success:
92528760edcSDaniel P. Berrangé  * @qts: QTestState instance to operate on
92628760edcSDaniel P. Berrangé  * @fds: the file descriptors to send
92728760edcSDaniel P. Berrangé  * @nfds: number of @fds to send
92828760edcSDaniel P. Berrangé  * @fmt: QMP message to send to qemu, formatted like
92928760edcSDaniel P. Berrangé  * qobject_from_jsonf_nofail().  See parse_interpolation() for what's
93028760edcSDaniel P. Berrangé  * supported after '%'.
93128760edcSDaniel P. Berrangé  *
93228760edcSDaniel P. Berrangé  * Sends a QMP message with file descriptors to QEMU and
93328760edcSDaniel P. Berrangé  * asserts that a 'return' key is present in the response.
93428760edcSDaniel P. Berrangé  */
93528760edcSDaniel P. Berrangé void qtest_qmp_fds_assert_success(QTestState *qts, int *fds, size_t nfds,
93628760edcSDaniel P. Berrangé                                   const char *fmt, ...)
93728760edcSDaniel P. Berrangé     G_GNUC_PRINTF(4, 5);
93828760edcSDaniel P. Berrangé #endif /* !_WIN32 */
93928760edcSDaniel P. Berrangé 
94002ef6e87SThomas Huth /**
94102ef6e87SThomas Huth  * qtest_cb_for_every_machine:
94202ef6e87SThomas Huth  * @cb: Pointer to the callback function
9431f4a0d81SThomas Huth  * @skip_old_versioned: true if versioned old machine types should be skipped
94402ef6e87SThomas Huth  *
94502ef6e87SThomas Huth  *  Call a callback function for every name of all available machines.
94602ef6e87SThomas Huth  */
9471f4a0d81SThomas Huth void qtest_cb_for_every_machine(void (*cb)(const char *machine),
9481f4a0d81SThomas Huth                                 bool skip_old_versioned);
94902ef6e87SThomas Huth 
950acd80015SThomas Huth /**
951a3c0ebc9SFabiano Rosas  * qtest_resolve_machine_alias:
952a3c0ebc9SFabiano Rosas  * @var: Environment variable from where to take the QEMU binary
953a3c0ebc9SFabiano Rosas  * @alias: The alias to resolve
954a3c0ebc9SFabiano Rosas  *
955a3c0ebc9SFabiano Rosas  * Returns: the machine type corresponding to the alias if any,
956a3c0ebc9SFabiano Rosas  * otherwise NULL.
957a3c0ebc9SFabiano Rosas  */
958a3c0ebc9SFabiano Rosas char *qtest_resolve_machine_alias(const char *var, const char *alias);
959a3c0ebc9SFabiano Rosas 
960a3c0ebc9SFabiano Rosas /**
961719051caSThomas Huth  * qtest_has_machine:
962719051caSThomas Huth  * @machine: The machine to look for
963719051caSThomas Huth  *
964719051caSThomas Huth  * Returns: true if the machine is available in the target binary.
965719051caSThomas Huth  */
966719051caSThomas Huth bool qtest_has_machine(const char *machine);
967719051caSThomas Huth 
968719051caSThomas Huth /**
9691027fc0aSFabiano Rosas  * qtest_has_machine_with_env:
9701027fc0aSFabiano Rosas  * @var: Environment variable from where to take the QEMU binary
9711027fc0aSFabiano Rosas  * @machine: The machine to look for
9721027fc0aSFabiano Rosas  *
9731027fc0aSFabiano Rosas  * Returns: true if the machine is available in the specified binary.
9741027fc0aSFabiano Rosas  */
9751027fc0aSFabiano Rosas bool qtest_has_machine_with_env(const char *var, const char *machine);
9761027fc0aSFabiano Rosas 
9771027fc0aSFabiano Rosas /**
978f43f8abeSAni Sinha  * qtest_has_cpu_model:
979f43f8abeSAni Sinha  * @cpu: The cpu to look for
980f43f8abeSAni Sinha  *
981f43f8abeSAni Sinha  * Returns: true if the cpu is available in the target binary.
982f43f8abeSAni Sinha  */
983f43f8abeSAni Sinha bool qtest_has_cpu_model(const char *cpu);
984f43f8abeSAni Sinha 
985f43f8abeSAni Sinha /**
986ad9e129bSThomas Huth  * qtest_has_device:
987ad9e129bSThomas Huth  * @device: The device to look for
988ad9e129bSThomas Huth  *
989ad9e129bSThomas Huth  * Returns: true if the device is available in the target binary.
990ad9e129bSThomas Huth  */
991ad9e129bSThomas Huth bool qtest_has_device(const char *device);
992ad9e129bSThomas Huth 
993ad9e129bSThomas Huth /**
994b4510bb4SIgor Mammedov  * qtest_qmp_device_add_qdict:
995b4510bb4SIgor Mammedov  * @qts: QTestState instance to operate on
996b4510bb4SIgor Mammedov  * @drv: Name of the device that should be added
9971e458f11SStefan Weil  * @arguments: QDict with properties for the device to initialize
998b4510bb4SIgor Mammedov  *
999b4510bb4SIgor Mammedov  * Generic hot-plugging test via the device_add QMP command with properties
1000b4510bb4SIgor Mammedov  * supplied in form of QDict. Use NULL for empty properties list.
1001b4510bb4SIgor Mammedov  */
1002b4510bb4SIgor Mammedov void qtest_qmp_device_add_qdict(QTestState *qts, const char *drv,
1003b4510bb4SIgor Mammedov                                 const QDict *arguments);
1004b4510bb4SIgor Mammedov 
1005b4510bb4SIgor Mammedov /**
1006acd80015SThomas Huth  * qtest_qmp_device_add:
1007e5758de4SThomas Huth  * @qts: QTestState instance to operate on
1008acd80015SThomas Huth  * @driver: Name of the device that should be added
1009acd80015SThomas Huth  * @id: Identification string
101051c778edSEduardo Habkost  * @fmt: QMP message to send to qemu, formatted like
1011ad57e2b1SPeter Maydell  * qobject_from_jsonf_nofail().  See parse_interpolation() for what's
101282cab70bSMarkus Armbruster  * supported after '%'.
1013acd80015SThomas Huth  *
1014acd80015SThomas Huth  * Generic hot-plugging test via the device_add QMP command.
1015acd80015SThomas Huth  */
1016e5758de4SThomas Huth void qtest_qmp_device_add(QTestState *qts, const char *driver, const char *id,
10179edc6313SMarc-André Lureau                           const char *fmt, ...) G_GNUC_PRINTF(4, 5);
1018acd80015SThomas Huth 
1019acd80015SThomas Huth /**
10202c7294d7SMarc-André Lureau  * qtest_qmp_add_client:
10212c7294d7SMarc-André Lureau  * @qts: QTestState instance to operate on
10222c7294d7SMarc-André Lureau  * @protocol: the protocol to add to
10232c7294d7SMarc-André Lureau  * @fd: the client file-descriptor
10242c7294d7SMarc-André Lureau  *
102561683d27SMarc-André Lureau  * Call QMP ``getfd`` (on Windows ``get-win32-socket``) followed by
102661683d27SMarc-André Lureau  * ``add_client`` with the given @fd.
10272c7294d7SMarc-André Lureau  */
10282c7294d7SMarc-André Lureau void qtest_qmp_add_client(QTestState *qts, const char *protocol, int fd);
10292c7294d7SMarc-André Lureau 
10302c7294d7SMarc-André Lureau /**
1031ea42a6c4SMichael Labiuk  * qtest_qmp_device_del_send:
1032ea42a6c4SMichael Labiuk  * @qts: QTestState instance to operate on
1033ea42a6c4SMichael Labiuk  * @id: Identification string
1034ea42a6c4SMichael Labiuk  *
1035ea42a6c4SMichael Labiuk  * Generic hot-unplugging test via the device_del QMP command.
1036ea42a6c4SMichael Labiuk  */
1037ea42a6c4SMichael Labiuk void qtest_qmp_device_del_send(QTestState *qts, const char *id);
1038ea42a6c4SMichael Labiuk 
1039ea42a6c4SMichael Labiuk /**
1040acd80015SThomas Huth  * qtest_qmp_device_del:
1041e5758de4SThomas Huth  * @qts: QTestState instance to operate on
1042acd80015SThomas Huth  * @id: Identification string
1043acd80015SThomas Huth  *
1044acd80015SThomas Huth  * Generic hot-unplugging test via the device_del QMP command.
1045ea42a6c4SMichael Labiuk  * Waiting for command completion event.
1046acd80015SThomas Huth  */
1047e5758de4SThomas Huth void qtest_qmp_device_del(QTestState *qts, const char *id);
1048acd80015SThomas Huth 
1049c35665e1SIgor Mammedov /**
105021f80286SRichard Henderson  * qtest_probe_child:
105121f80286SRichard Henderson  * @s: QTestState instance to operate on.
105221f80286SRichard Henderson  *
105321f80286SRichard Henderson  * Returns: true if the child is still alive.
105421f80286SRichard Henderson  */
105521f80286SRichard Henderson bool qtest_probe_child(QTestState *s);
105621f80286SRichard Henderson 
1057d43e59e7SYury Kotov /**
1058d43e59e7SYury Kotov  * qtest_set_expected_status:
1059d43e59e7SYury Kotov  * @s: QTestState instance to operate on.
1060d43e59e7SYury Kotov  * @status: an expected exit status.
1061d43e59e7SYury Kotov  *
1062d43e59e7SYury Kotov  * Set expected exit status of the child.
1063d43e59e7SYury Kotov  */
1064d43e59e7SYury Kotov void qtest_set_expected_status(QTestState *s, int status);
1065d43e59e7SYury Kotov 
1066ca5d4641SAlexander Bulekov QTestState *qtest_inproc_init(QTestState **s, bool log, const char* arch,
1067ca5d4641SAlexander Bulekov                     void (*send)(void*, const char*));
1068ca5d4641SAlexander Bulekov 
1069ca5d4641SAlexander Bulekov void qtest_client_inproc_recv(void *opaque, const char *str);
1070188052a1SIris Chen 
1071188052a1SIris Chen /**
1072188052a1SIris Chen  * qtest_qom_set_bool:
1073188052a1SIris Chen  * @s: QTestState instance to operate on.
1074188052a1SIris Chen  * @path: Path to the property being set.
1075188052a1SIris Chen  * @property: Property being set.
1076188052a1SIris Chen  * @value: Value to set the property.
1077188052a1SIris Chen  *
1078188052a1SIris Chen  * Set the property with passed in value.
1079188052a1SIris Chen  */
1080188052a1SIris Chen void qtest_qom_set_bool(QTestState *s, const char *path, const char *property,
1081188052a1SIris Chen                          bool value);
1082188052a1SIris Chen 
1083188052a1SIris Chen /**
1084188052a1SIris Chen  * qtest_qom_get_bool:
1085188052a1SIris Chen  * @s: QTestState instance to operate on.
1086188052a1SIris Chen  * @path: Path to the property being retrieved.
1087188052a1SIris Chen  * @property: Property from where the value is being retrieved.
1088188052a1SIris Chen  *
1089188052a1SIris Chen  * Returns: Value retrieved from property.
1090188052a1SIris Chen  */
1091188052a1SIris Chen bool qtest_qom_get_bool(QTestState *s, const char *path, const char *property);
1092ed097649SMarc-André Lureau 
1093ed097649SMarc-André Lureau /**
1094ed097649SMarc-André Lureau  * qtest_pid:
1095ed097649SMarc-André Lureau  * @s: QTestState instance to operate on.
1096ed097649SMarc-André Lureau  *
1097ed097649SMarc-André Lureau  * Returns: the PID of the QEMU process, or <= 0
1098ed097649SMarc-André Lureau  */
1099ed097649SMarc-André Lureau pid_t qtest_pid(QTestState *s);
1100ed097649SMarc-André Lureau 
110125919c40SThomas Huth /**
110225919c40SThomas Huth  * have_qemu_img:
110325919c40SThomas Huth  *
110425919c40SThomas Huth  * Returns: true if "qemu-img" is available.
110525919c40SThomas Huth  */
110625919c40SThomas Huth bool have_qemu_img(void);
110725919c40SThomas Huth 
110825919c40SThomas Huth /**
110925919c40SThomas Huth  * mkimg:
111025919c40SThomas Huth  * @file: File name of the image that should be created
111125919c40SThomas Huth  * @fmt: Format, e.g. "qcow2" or "raw"
111225919c40SThomas Huth  * @size_mb: Size of the image in megabytes
111325919c40SThomas Huth  *
111425919c40SThomas Huth  * Create a disk image with qemu-img. Note that the QTEST_QEMU_IMG
111525919c40SThomas Huth  * environment variable must point to the qemu-img file.
111625919c40SThomas Huth  *
111725919c40SThomas Huth  * Returns: true if the image has been created successfully.
111825919c40SThomas Huth  */
111925919c40SThomas Huth bool mkimg(const char *file, const char *fmt, unsigned size_mb);
112025919c40SThomas Huth 
112149ee3590SAnthony Liguori #endif
1122