xref: /qemu/tests/qtest/libqtest.h (revision 407bc4bf9027f7ac4333e47cd900d773b99a23e3)
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 
20*407bc4bfSDaniel P. Berrangé #include "qobject/qobject.h"
21*407bc4bfSDaniel P. Berrangé #include "qobject/qdict.h"
22*407bc4bfSDaniel P. Berrangé #include "qobject/qlist.h"
23c6d3bcb4SMarc-André Lureau #include "libqmp.h"
245cb8f0dbSPaolo Bonzini 
2549ee3590SAnthony Liguori typedef struct QTestState QTestState;
2649ee3590SAnthony Liguori 
2749ee3590SAnthony Liguori /**
2888b988c8SMarkus Armbruster  * qtest_initf:
2951c778edSEduardo Habkost  * @fmt: Format for creating other arguments to pass to QEMU, formatted
3078b27badSEric Blake  * like sprintf().
3178b27badSEric Blake  *
3200825d96SThomas Huth  * Convenience wrapper around qtest_init().
3378b27badSEric Blake  *
3478b27badSEric Blake  * Returns: #QTestState instance.
3578b27badSEric Blake  */
369edc6313SMarc-André Lureau QTestState *qtest_initf(const char *fmt, ...) G_GNUC_PRINTF(1, 2);
3778b27badSEric Blake 
3878b27badSEric Blake /**
3988b988c8SMarkus Armbruster  * qtest_vinitf:
4078b27badSEric Blake  * @fmt: Format for creating other arguments to pass to QEMU, formatted
4178b27badSEric Blake  * like vsprintf().
4278b27badSEric Blake  * @ap: Format arguments.
4378b27badSEric Blake  *
4400825d96SThomas Huth  * Convenience wrapper around qtest_init().
4578b27badSEric Blake  *
4678b27badSEric Blake  * Returns: #QTestState instance.
4778b27badSEric Blake  */
489edc6313SMarc-André Lureau QTestState *qtest_vinitf(const char *fmt, va_list ap) G_GNUC_PRINTF(1, 0);
4978b27badSEric Blake 
5078b27badSEric Blake /**
5149ee3590SAnthony Liguori  * qtest_init:
5288b988c8SMarkus Armbruster  * @extra_args: other arguments to pass to QEMU.  CAUTION: these
5388b988c8SMarkus Armbruster  * arguments are subject to word splitting and shell evaluation.
546acf801dSAndreas Färber  *
556acf801dSAndreas Färber  * Returns: #QTestState instance.
5649ee3590SAnthony Liguori  */
5749ee3590SAnthony Liguori QTestState *qtest_init(const char *extra_args);
5849ee3590SAnthony Liguori 
5949ee3590SAnthony Liguori /**
609931215bSFabiano Rosas  * qtest_init_with_env:
619931215bSFabiano Rosas  * @var: Environment variable from where to take the QEMU binary
629931215bSFabiano Rosas  * @extra_args: Other arguments to pass to QEMU.  CAUTION: these
639931215bSFabiano Rosas  * arguments are subject to word splitting and shell evaluation.
645357ef82SSteve Sistare  * @do_connect: connect to qemu monitor and qtest socket.
659931215bSFabiano Rosas  *
669931215bSFabiano Rosas  * Like qtest_init(), but use a different environment variable for the
679931215bSFabiano Rosas  * QEMU binary.
689931215bSFabiano Rosas  *
699931215bSFabiano Rosas  * Returns: #QTestState instance.
709931215bSFabiano Rosas  */
715357ef82SSteve Sistare QTestState *qtest_init_with_env(const char *var, const char *extra_args,
725357ef82SSteve Sistare                                 bool do_connect);
739931215bSFabiano Rosas 
749931215bSFabiano Rosas /**
7599baa5d9SJuraj Marcin  * qtest_init_with_env_and_capabilities:
7699baa5d9SJuraj Marcin  * @var: Environment variable from where to take the QEMU binary
7799baa5d9SJuraj Marcin  * @extra_args: Other arguments to pass to QEMU.  CAUTION: these
7899baa5d9SJuraj Marcin  * arguments are subject to word splitting and shell evaluation.
7999baa5d9SJuraj Marcin  * @capabilities: list of QMP capabilities (strings) to enable
805357ef82SSteve Sistare  * @do_connect: connect to qemu monitor and qtest socket.
8199baa5d9SJuraj Marcin  *
8299baa5d9SJuraj Marcin  * Like qtest_init_with_env(), but enable specified capabilities during
8399baa5d9SJuraj Marcin  * hadshake.
8499baa5d9SJuraj Marcin  *
8599baa5d9SJuraj Marcin  * Returns: #QTestState instance.
8699baa5d9SJuraj Marcin  */
8799baa5d9SJuraj Marcin QTestState *qtest_init_with_env_and_capabilities(const char *var,
8899baa5d9SJuraj Marcin                                                  const char *extra_args,
895357ef82SSteve Sistare                                                  QList *capabilities,
905357ef82SSteve Sistare                                                  bool do_connect);
9199baa5d9SJuraj Marcin 
9299baa5d9SJuraj Marcin /**
93f66e7ac8SMarkus Armbruster  * qtest_init_without_qmp_handshake:
94ddee57e0SEric Blake  * @extra_args: other arguments to pass to QEMU.  CAUTION: these
95ddee57e0SEric Blake  * arguments are subject to word splitting and shell evaluation.
96f66e7ac8SMarkus Armbruster  *
97f66e7ac8SMarkus Armbruster  * Returns: #QTestState instance.
98f66e7ac8SMarkus Armbruster  */
99192f26a7SPeter Xu QTestState *qtest_init_without_qmp_handshake(const char *extra_args);
100f66e7ac8SMarkus Armbruster 
101f66e7ac8SMarkus Armbruster /**
1025357ef82SSteve Sistare  * qtest_connect
1035357ef82SSteve Sistare  * @s: #QTestState instance to connect
1045357ef82SSteve Sistare  * Connect to qemu monitor and qtest socket, after skipping them in
1055357ef82SSteve Sistare  * qtest_init_with_env.  Does not handshake with the monitor.
1065357ef82SSteve Sistare  */
1075357ef82SSteve Sistare void qtest_connect(QTestState *s);
1085357ef82SSteve Sistare 
1095357ef82SSteve Sistare /**
1105357ef82SSteve Sistare  * qtest_qmp_handshake:
1115357ef82SSteve Sistare  * @s: #QTestState instance to operate on.
1125357ef82SSteve Sistare  * @capabilities: list of QMP capabilities (strings) to enable
1135357ef82SSteve Sistare  * Perform handshake after connecting to qemu monitor.
1145357ef82SSteve Sistare  */
1155357ef82SSteve Sistare void qtest_qmp_handshake(QTestState *s, QList *capabilities);
1165357ef82SSteve Sistare 
1175357ef82SSteve Sistare /**
1186c90a82cSJulia Suvorova  * qtest_init_with_serial:
1196c90a82cSJulia Suvorova  * @extra_args: other arguments to pass to QEMU.  CAUTION: these
1206c90a82cSJulia Suvorova  * arguments are subject to word splitting and shell evaluation.
1216c90a82cSJulia Suvorova  * @sock_fd: pointer to store the socket file descriptor for
1226c90a82cSJulia Suvorova  * connection with serial.
1236c90a82cSJulia Suvorova  *
1246c90a82cSJulia Suvorova  * Returns: #QTestState instance.
1256c90a82cSJulia Suvorova  */
1266c90a82cSJulia Suvorova QTestState *qtest_init_with_serial(const char *extra_args, int *sock_fd);
1276c90a82cSJulia Suvorova 
1286c90a82cSJulia Suvorova /**
1296b76264eSPeter Maydell  * qtest_system_reset:
1306b76264eSPeter Maydell  * @s: #QTestState instance to operate on.
1316b76264eSPeter Maydell  *
1326b76264eSPeter Maydell  * Send a "system_reset" command to the QEMU under test, and wait for
1336b76264eSPeter Maydell  * the reset to complete before returning.
1346b76264eSPeter Maydell  */
1356b76264eSPeter Maydell void qtest_system_reset(QTestState *s);
1366b76264eSPeter Maydell 
1376b76264eSPeter Maydell /**
1386b76264eSPeter Maydell  * qtest_system_reset_nowait:
1396b76264eSPeter Maydell  * @s: #QTestState instance to operate on.
1406b76264eSPeter Maydell  *
1416b76264eSPeter Maydell  * Send a "system_reset" command to the QEMU under test, but do not
1426b76264eSPeter Maydell  * wait for the reset to complete before returning. The caller is
1436b76264eSPeter Maydell  * responsible for waiting for either the RESET event or some other
1446b76264eSPeter Maydell  * event of interest to them before proceeding.
1456b76264eSPeter Maydell  *
1466b76264eSPeter Maydell  * This function should only be used if you're specifically testing
1476b76264eSPeter Maydell  * for some other event; in that case you can't use qtest_system_reset()
1486b76264eSPeter Maydell  * because it will read and discard any other QMP events that arrive
1496b76264eSPeter Maydell  * before the RESET event.
1506b76264eSPeter Maydell  */
1516b76264eSPeter Maydell void qtest_system_reset_nowait(QTestState *s);
1526b76264eSPeter Maydell 
1536b76264eSPeter Maydell /**
15469c056fbSBin Meng  * qtest_wait_qemu:
15569c056fbSBin Meng  * @s: #QTestState instance to operate on.
15669c056fbSBin Meng  *
15769c056fbSBin Meng  * Wait for the QEMU process to terminate. It is safe to call this function
15869c056fbSBin Meng  * multiple times.
15969c056fbSBin Meng  */
16069c056fbSBin Meng void qtest_wait_qemu(QTestState *s);
16169c056fbSBin Meng 
16269c056fbSBin Meng /**
1637a23c523SStefan Hajnoczi  * qtest_kill_qemu:
1647a23c523SStefan Hajnoczi  * @s: #QTestState instance to operate on.
1657a23c523SStefan Hajnoczi  *
1667a23c523SStefan Hajnoczi  * Kill the QEMU process and wait for it to terminate. It is safe to call this
1677a23c523SStefan Hajnoczi  * function multiple times. Normally qtest_quit() is used instead because it
1687a23c523SStefan Hajnoczi  * also frees QTestState. Use qtest_kill_qemu() when you just want to kill QEMU
1697a23c523SStefan Hajnoczi  * and qtest_quit() will be called later.
1707a23c523SStefan Hajnoczi  */
1717a23c523SStefan Hajnoczi void qtest_kill_qemu(QTestState *s);
1727a23c523SStefan Hajnoczi 
1737a23c523SStefan Hajnoczi /**
17449ee3590SAnthony Liguori  * qtest_quit:
1756acf801dSAndreas Färber  * @s: #QTestState instance to operate on.
17649ee3590SAnthony Liguori  *
17749ee3590SAnthony Liguori  * Shut down the QEMU process associated to @s.
17849ee3590SAnthony Liguori  */
17949ee3590SAnthony Liguori void qtest_quit(QTestState *s);
18049ee3590SAnthony Liguori 
181490081b2SBin Meng #ifndef _WIN32
18249ee3590SAnthony Liguori /**
18324d5588cSYury Kotov  * qtest_qmp_fds:
18424d5588cSYury Kotov  * @s: #QTestState instance to operate on.
18524d5588cSYury Kotov  * @fds: array of file descriptors
18624d5588cSYury Kotov  * @fds_num: number of elements in @fds
18751c778edSEduardo Habkost  * @fmt: QMP message to send to qemu, formatted like
188ad57e2b1SPeter Maydell  * qobject_from_jsonf_nofail().  See parse_interpolation() for what's
18924d5588cSYury Kotov  * supported after '%'.
19024d5588cSYury Kotov  *
19124d5588cSYury Kotov  * Sends a QMP message to QEMU with fds and returns the response.
19224d5588cSYury Kotov  */
19324d5588cSYury Kotov QDict *qtest_qmp_fds(QTestState *s, int *fds, size_t fds_num,
19424d5588cSYury Kotov                      const char *fmt, ...)
1959edc6313SMarc-André Lureau     G_GNUC_PRINTF(4, 5);
196490081b2SBin Meng #endif /* _WIN32 */
19724d5588cSYury Kotov 
19824d5588cSYury Kotov /**
1990c460dacSStefan Hajnoczi  * qtest_qmp:
2000c460dacSStefan Hajnoczi  * @s: #QTestState instance to operate on.
20151c778edSEduardo Habkost  * @fmt: QMP message to send to qemu, formatted like
202ad57e2b1SPeter Maydell  * qobject_from_jsonf_nofail().  See parse_interpolation() for what's
2036ce80fd8SMarkus Armbruster  * supported after '%'.
2040c460dacSStefan Hajnoczi  *
2050c460dacSStefan Hajnoczi  * Sends a QMP message to QEMU and returns the response.
2060c460dacSStefan Hajnoczi  */
207e3dc93beSMarkus Armbruster QDict *qtest_qmp(QTestState *s, const char *fmt, ...)
2089edc6313SMarc-André Lureau     G_GNUC_PRINTF(2, 3);
2090c460dacSStefan Hajnoczi 
2100c460dacSStefan Hajnoczi /**
2114277f1ebSMarkus Armbruster  * qtest_qmp_send:
212ba4ed393SJohn Snow  * @s: #QTestState instance to operate on.
21351c778edSEduardo Habkost  * @fmt: QMP message to send to qemu, formatted like
214ad57e2b1SPeter Maydell  * qobject_from_jsonf_nofail().  See parse_interpolation() for what's
2156ce80fd8SMarkus Armbruster  * supported after '%'.
216ba4ed393SJohn Snow  *
217ba4ed393SJohn Snow  * Sends a QMP message to QEMU and leaves the response in the stream.
218ba4ed393SJohn Snow  */
219e3dc93beSMarkus Armbruster void qtest_qmp_send(QTestState *s, const char *fmt, ...)
2209edc6313SMarc-André Lureau     G_GNUC_PRINTF(2, 3);
221ba4ed393SJohn Snow 
222ba4ed393SJohn Snow /**
223aed877c5SMarkus Armbruster  * qtest_qmp_send_raw:
224aed877c5SMarkus Armbruster  * @s: #QTestState instance to operate on.
22551c778edSEduardo Habkost  * @fmt: text to send, formatted like sprintf()
226aed877c5SMarkus Armbruster  *
227aed877c5SMarkus Armbruster  * Sends text to the QMP monitor verbatim.  Need not be valid JSON;
228aed877c5SMarkus Armbruster  * this is useful for negative tests.
229aed877c5SMarkus Armbruster  */
230aed877c5SMarkus Armbruster void qtest_qmp_send_raw(QTestState *s, const char *fmt, ...)
2319edc6313SMarc-André Lureau     G_GNUC_PRINTF(2, 3);
232aed877c5SMarkus Armbruster 
233aed877c5SMarkus Armbruster /**
2349fb7bb06SStefan Hajnoczi  * qtest_socket_server:
2359fb7bb06SStefan Hajnoczi  * @socket_path: the UNIX domain socket path
2369fb7bb06SStefan Hajnoczi  *
2379fb7bb06SStefan Hajnoczi  * Create and return a listen socket file descriptor, or abort on failure.
2389fb7bb06SStefan Hajnoczi  */
2399fb7bb06SStefan Hajnoczi int qtest_socket_server(const char *socket_path);
2409fb7bb06SStefan Hajnoczi 
241490081b2SBin Meng #ifndef _WIN32
2429fb7bb06SStefan Hajnoczi /**
24324d5588cSYury Kotov  * qtest_vqmp_fds:
24424d5588cSYury Kotov  * @s: #QTestState instance to operate on.
24524d5588cSYury Kotov  * @fds: array of file descriptors
24624d5588cSYury Kotov  * @fds_num: number of elements in @fds
24724d5588cSYury Kotov  * @fmt: QMP message to send to QEMU, formatted like
248ad57e2b1SPeter Maydell  * qobject_from_jsonf_nofail().  See parse_interpolation() for what's
24924d5588cSYury Kotov  * supported after '%'.
25024d5588cSYury Kotov  * @ap: QMP message arguments
25124d5588cSYury Kotov  *
25224d5588cSYury Kotov  * Sends a QMP message to QEMU with fds and returns the response.
25324d5588cSYury Kotov  */
25424d5588cSYury Kotov QDict *qtest_vqmp_fds(QTestState *s, int *fds, size_t fds_num,
25524d5588cSYury Kotov                       const char *fmt, va_list ap)
2569edc6313SMarc-André Lureau     G_GNUC_PRINTF(4, 0);
257490081b2SBin Meng #endif /* _WIN32 */
25824d5588cSYury Kotov 
25924d5588cSYury Kotov /**
26024d5588cSYury Kotov  * qtest_vqmp:
2610c460dacSStefan Hajnoczi  * @s: #QTestState instance to operate on.
262bb340eb2SEric Blake  * @fmt: QMP message to send to QEMU, formatted like
263ad57e2b1SPeter Maydell  * qobject_from_jsonf_nofail().  See parse_interpolation() for what's
2646ce80fd8SMarkus Armbruster  * supported after '%'.
2650c460dacSStefan Hajnoczi  * @ap: QMP message arguments
2660c460dacSStefan Hajnoczi  *
2670c460dacSStefan Hajnoczi  * Sends a QMP message to QEMU and returns the response.
2680c460dacSStefan Hajnoczi  */
269248eef02SMarkus Armbruster QDict *qtest_vqmp(QTestState *s, const char *fmt, va_list ap)
2709edc6313SMarc-André Lureau     G_GNUC_PRINTF(2, 0);
2710c460dacSStefan Hajnoczi 
272490081b2SBin Meng #ifndef _WIN32
2730c460dacSStefan Hajnoczi /**
27424d5588cSYury Kotov  * qtest_qmp_vsend_fds:
27524d5588cSYury Kotov  * @s: #QTestState instance to operate on.
27624d5588cSYury Kotov  * @fds: array of file descriptors
27724d5588cSYury Kotov  * @fds_num: number of elements in @fds
27824d5588cSYury Kotov  * @fmt: QMP message to send to QEMU, formatted like
279ad57e2b1SPeter Maydell  * qobject_from_jsonf_nofail().  See parse_interpolation() for what's
28024d5588cSYury Kotov  * supported after '%'.
28124d5588cSYury Kotov  * @ap: QMP message arguments
28224d5588cSYury Kotov  *
28324d5588cSYury Kotov  * Sends a QMP message to QEMU and leaves the response in the stream.
28424d5588cSYury Kotov  */
28524d5588cSYury Kotov void qtest_qmp_vsend_fds(QTestState *s, int *fds, size_t fds_num,
28624d5588cSYury Kotov                          const char *fmt, va_list ap)
2879edc6313SMarc-André Lureau     G_GNUC_PRINTF(4, 0);
288490081b2SBin Meng #endif /* _WIN32 */
28924d5588cSYury Kotov 
29024d5588cSYury Kotov /**
2914277f1ebSMarkus Armbruster  * qtest_qmp_vsend:
292ba4ed393SJohn Snow  * @s: #QTestState instance to operate on.
293bb340eb2SEric Blake  * @fmt: QMP message to send to QEMU, formatted like
294ad57e2b1SPeter Maydell  * qobject_from_jsonf_nofail().  See parse_interpolation() for what's
2956ce80fd8SMarkus Armbruster  * supported after '%'.
296ba4ed393SJohn Snow  * @ap: QMP message arguments
297ba4ed393SJohn Snow  *
298ba4ed393SJohn Snow  * Sends a QMP message to QEMU and leaves the response in the stream.
299ba4ed393SJohn Snow  */
300e3dc93beSMarkus Armbruster void qtest_qmp_vsend(QTestState *s, const char *fmt, va_list ap)
3019edc6313SMarc-André Lureau     G_GNUC_PRINTF(2, 0);
302ba4ed393SJohn Snow 
303ba4ed393SJohn Snow /**
3041c3e2a38SMaxim Levitsky  * qtest_qmp_receive_dict:
30566e0c7b1SAndreas Färber  * @s: #QTestState instance to operate on.
30666e0c7b1SAndreas Färber  *
30766e0c7b1SAndreas Färber  * Reads a QMP message from QEMU and returns the response.
30866e0c7b1SAndreas Färber  */
3091c3e2a38SMaxim Levitsky QDict *qtest_qmp_receive_dict(QTestState *s);
31066e0c7b1SAndreas Färber 
31166e0c7b1SAndreas Färber /**
312c22045bfSMaxim Levitsky  * qtest_qmp_receive:
313c22045bfSMaxim Levitsky  * @s: #QTestState instance to operate on.
314c22045bfSMaxim Levitsky  *
315c22045bfSMaxim Levitsky  * Reads a QMP message from QEMU and returns the response.
3160150e75dSDaniel P. Berrangé  *
3170150e75dSDaniel P. Berrangé  * If a callback is registered with qtest_qmp_set_event_callback,
3180150e75dSDaniel P. Berrangé  * it will be invoked for every event seen, otherwise events
3190150e75dSDaniel P. Berrangé  * will be buffered until a call to one of the qtest_qmp_eventwait
3200150e75dSDaniel P. Berrangé  * family of functions.
321c22045bfSMaxim Levitsky  */
322c22045bfSMaxim Levitsky QDict *qtest_qmp_receive(QTestState *s);
323c22045bfSMaxim Levitsky 
3240150e75dSDaniel P. Berrangé /*
3250150e75dSDaniel P. Berrangé  * QTestQMPEventCallback:
3260150e75dSDaniel P. Berrangé  * @s: #QTestState instance event was received on
3270150e75dSDaniel P. Berrangé  * @name: name of the event type
3280150e75dSDaniel P. Berrangé  * @event: #QDict for the event details
3290150e75dSDaniel P. Berrangé  * @opaque: opaque data from time of callback registration
3300150e75dSDaniel P. Berrangé  *
3310150e75dSDaniel P. Berrangé  * This callback will be invoked whenever an event is received.
3320150e75dSDaniel P. Berrangé  * If the callback returns true the event will be consumed,
3330150e75dSDaniel P. Berrangé  * otherwise it will be put on the list of pending events.
3340150e75dSDaniel P. Berrangé  * Pending events can be later handled by calling either
3350150e75dSDaniel P. Berrangé  * qtest_qmp_eventwait or qtest_qmp_eventwait_ref.
3360150e75dSDaniel P. Berrangé  *
3370150e75dSDaniel P. Berrangé  * Return: true to consume the event, false to let it be queued
3380150e75dSDaniel P. Berrangé  */
3390150e75dSDaniel P. Berrangé typedef bool (*QTestQMPEventCallback)(QTestState *s, const char *name,
3400150e75dSDaniel P. Berrangé                                       QDict *event, void *opaque);
3410150e75dSDaniel P. Berrangé 
3420150e75dSDaniel P. Berrangé /**
3430150e75dSDaniel P. Berrangé  * qtest_qmp_set_event_callback:
3440150e75dSDaniel P. Berrangé  * @s: #QTestSTate instance to operate on
3450150e75dSDaniel P. Berrangé  * @cb: callback to invoke for events
3460150e75dSDaniel P. Berrangé  * @opaque: data to pass to @cb
3470150e75dSDaniel P. Berrangé  *
3480150e75dSDaniel P. Berrangé  * Register a callback to be invoked whenever an event arrives
3490150e75dSDaniel P. Berrangé  */
3500150e75dSDaniel P. Berrangé void qtest_qmp_set_event_callback(QTestState *s,
3510150e75dSDaniel P. Berrangé                                   QTestQMPEventCallback cb, void *opaque);
3520150e75dSDaniel P. Berrangé 
353c22045bfSMaxim Levitsky /**
3548fe941f7SJohn Snow  * qtest_qmp_eventwait:
3558fe941f7SJohn Snow  * @s: #QTestState instance to operate on.
35651c778edSEduardo Habkost  * @event: event to wait for.
3578fe941f7SJohn Snow  *
358e8ec0117SEric Blake  * Continuously polls for QMP responses until it receives the desired event.
3590150e75dSDaniel P. Berrangé  *
3600150e75dSDaniel P. Berrangé  * Any callback registered with qtest_qmp_set_event_callback will
3610150e75dSDaniel P. Berrangé  * be invoked for every event seen.
3628fe941f7SJohn Snow  */
3638fe941f7SJohn Snow void qtest_qmp_eventwait(QTestState *s, const char *event);
3648fe941f7SJohn Snow 
3658fe941f7SJohn Snow /**
3667ffe3124SJohn Snow  * qtest_qmp_eventwait_ref:
3677ffe3124SJohn Snow  * @s: #QTestState instance to operate on.
36851c778edSEduardo Habkost  * @event: event to wait for.
3697ffe3124SJohn Snow  *
370e8ec0117SEric Blake  * Continuously polls for QMP responses until it receives the desired event.
3710150e75dSDaniel P. Berrangé  *
3720150e75dSDaniel P. Berrangé  * Any callback registered with qtest_qmp_set_event_callback will
3730150e75dSDaniel P. Berrangé  * be invoked for every event seen.
3740150e75dSDaniel P. Berrangé  *
3757ffe3124SJohn Snow  * Returns a copy of the event for further investigation.
3767ffe3124SJohn Snow  */
3777ffe3124SJohn Snow QDict *qtest_qmp_eventwait_ref(QTestState *s, const char *event);
3787ffe3124SJohn Snow 
3797ffe3124SJohn Snow /**
380c22045bfSMaxim Levitsky  * qtest_qmp_event_ref:
381c22045bfSMaxim Levitsky  * @s: #QTestState instance to operate on.
382c22045bfSMaxim Levitsky  * @event: event to return.
383c22045bfSMaxim Levitsky  *
384c22045bfSMaxim Levitsky  * Removes non-matching events from the buffer that was set by
385c22045bfSMaxim Levitsky  * qtest_qmp_receive, until an event bearing the given name is found,
386c22045bfSMaxim Levitsky  * and returns it.
387c22045bfSMaxim Levitsky  * If no event matches, clears the buffer and returns NULL.
388c22045bfSMaxim Levitsky  *
389c22045bfSMaxim Levitsky  */
390c22045bfSMaxim Levitsky QDict *qtest_qmp_event_ref(QTestState *s, const char *event);
391c22045bfSMaxim Levitsky 
392c22045bfSMaxim Levitsky /**
3936bb87be8SThomas Huth  * qtest_hmp:
3945fb48d96SMarkus Armbruster  * @s: #QTestState instance to operate on.
39551c778edSEduardo Habkost  * @fmt: HMP command to send to QEMU, formats arguments like sprintf().
3965fb48d96SMarkus Armbruster  *
3975fb48d96SMarkus Armbruster  * Send HMP command to QEMU via QMP's human-monitor-command.
3986bb87be8SThomas Huth  * QMP events are discarded.
3995fb48d96SMarkus Armbruster  *
4005fb48d96SMarkus Armbruster  * Returns: the command's output.  The caller should g_free() it.
4015fb48d96SMarkus Armbruster  */
4029edc6313SMarc-André Lureau char *qtest_hmp(QTestState *s, const char *fmt, ...) G_GNUC_PRINTF(2, 3);
4035fb48d96SMarkus Armbruster 
4045fb48d96SMarkus Armbruster /**
40564965b4bSAlex Bennée  * qtest_vhmp:
4065fb48d96SMarkus Armbruster  * @s: #QTestState instance to operate on.
407bb340eb2SEric Blake  * @fmt: HMP command to send to QEMU, formats arguments like vsprintf().
4085fb48d96SMarkus Armbruster  * @ap: HMP command arguments
4095fb48d96SMarkus Armbruster  *
4105fb48d96SMarkus Armbruster  * Send HMP command to QEMU via QMP's human-monitor-command.
4116bb87be8SThomas Huth  * QMP events are discarded.
4125fb48d96SMarkus Armbruster  *
4135fb48d96SMarkus Armbruster  * Returns: the command's output.  The caller should g_free() it.
4145fb48d96SMarkus Armbruster  */
415248eef02SMarkus Armbruster char *qtest_vhmp(QTestState *s, const char *fmt, va_list ap)
4169edc6313SMarc-André Lureau     G_GNUC_PRINTF(2, 0);
4175fb48d96SMarkus Armbruster 
418eb062cfaSMarc-André Lureau void qtest_module_load(QTestState *s, const char *prefix, const char *libname);
419eb062cfaSMarc-André Lureau 
4205fb48d96SMarkus Armbruster /**
42149ee3590SAnthony Liguori  * qtest_get_irq:
4226acf801dSAndreas Färber  * @s: #QTestState instance to operate on.
42349ee3590SAnthony Liguori  * @num: Interrupt to observe.
42449ee3590SAnthony Liguori  *
4256acf801dSAndreas Färber  * Returns: The level of the @num interrupt.
42649ee3590SAnthony Liguori  */
42749ee3590SAnthony Liguori bool qtest_get_irq(QTestState *s, int num);
42849ee3590SAnthony Liguori 
42949ee3590SAnthony Liguori /**
43049ee3590SAnthony Liguori  * qtest_irq_intercept_in:
4316acf801dSAndreas Färber  * @s: #QTestState instance to operate on.
43249ee3590SAnthony Liguori  * @string: QOM path of a device.
43349ee3590SAnthony Liguori  *
43449ee3590SAnthony Liguori  * Associate qtest irqs with the GPIO-in pins of the device
43549ee3590SAnthony Liguori  * whose path is specified by @string.
43649ee3590SAnthony Liguori  */
43749ee3590SAnthony Liguori void qtest_irq_intercept_in(QTestState *s, const char *string);
43849ee3590SAnthony Liguori 
43949ee3590SAnthony Liguori /**
44049ee3590SAnthony Liguori  * qtest_irq_intercept_out:
4416acf801dSAndreas Färber  * @s: #QTestState instance to operate on.
44249ee3590SAnthony Liguori  * @string: QOM path of a device.
44349ee3590SAnthony Liguori  *
44449ee3590SAnthony Liguori  * Associate qtest irqs with the GPIO-out pins of the device
44549ee3590SAnthony Liguori  * whose path is specified by @string.
44649ee3590SAnthony Liguori  */
44749ee3590SAnthony Liguori void qtest_irq_intercept_out(QTestState *s, const char *string);
44849ee3590SAnthony Liguori 
44949ee3590SAnthony Liguori /**
450a8610f8bSChris Laplante  * qtest_irq_intercept_out_named:
451a8610f8bSChris Laplante  * @s: #QTestState instance to operate on.
452a8610f8bSChris Laplante  * @qom_path: QOM path of a device.
453a8610f8bSChris Laplante  * @name: Name of the GPIO out pin
454a8610f8bSChris Laplante  *
455a8610f8bSChris Laplante  * Associate a qtest irq with the named GPIO-out pin of the device
456a8610f8bSChris Laplante  * whose path is specified by @string and whose name is @name.
457a8610f8bSChris Laplante  */
458a8610f8bSChris Laplante void qtest_irq_intercept_out_named(QTestState *s, const char *qom_path, const char *name);
459a8610f8bSChris Laplante 
460a8610f8bSChris Laplante /**
4619813dc6aSSteffen Görtz  * qtest_set_irq_in:
4629813dc6aSSteffen Görtz  * @s: QTestState instance to operate on.
4639813dc6aSSteffen Görtz  * @string: QOM path of a device
4649813dc6aSSteffen Görtz  * @name: IRQ name
4659813dc6aSSteffen Görtz  * @irq: IRQ number
4669813dc6aSSteffen Görtz  * @level: IRQ level
4679813dc6aSSteffen Görtz  *
4689813dc6aSSteffen Görtz  * Force given device/irq GPIO-in pin to the given level.
4699813dc6aSSteffen Görtz  */
4709813dc6aSSteffen Görtz void qtest_set_irq_in(QTestState *s, const char *string, const char *name,
4719813dc6aSSteffen Görtz                       int irq, int level);
4729813dc6aSSteffen Görtz 
4739813dc6aSSteffen Görtz /**
47449ee3590SAnthony Liguori  * qtest_outb:
4756acf801dSAndreas Färber  * @s: #QTestState instance to operate on.
47649ee3590SAnthony Liguori  * @addr: I/O port to write to.
47749ee3590SAnthony Liguori  * @value: Value being written.
47849ee3590SAnthony Liguori  *
47949ee3590SAnthony Liguori  * Write an 8-bit value to an I/O port.
48049ee3590SAnthony Liguori  */
48149ee3590SAnthony Liguori void qtest_outb(QTestState *s, uint16_t addr, uint8_t value);
48249ee3590SAnthony Liguori 
48349ee3590SAnthony Liguori /**
48449ee3590SAnthony Liguori  * qtest_outw:
4856acf801dSAndreas Färber  * @s: #QTestState instance to operate on.
48649ee3590SAnthony Liguori  * @addr: I/O port to write to.
48749ee3590SAnthony Liguori  * @value: Value being written.
48849ee3590SAnthony Liguori  *
48949ee3590SAnthony Liguori  * Write a 16-bit value to an I/O port.
49049ee3590SAnthony Liguori  */
49149ee3590SAnthony Liguori void qtest_outw(QTestState *s, uint16_t addr, uint16_t value);
49249ee3590SAnthony Liguori 
49349ee3590SAnthony Liguori /**
49449ee3590SAnthony Liguori  * qtest_outl:
4956acf801dSAndreas Färber  * @s: #QTestState instance to operate on.
49649ee3590SAnthony Liguori  * @addr: I/O port to write to.
49749ee3590SAnthony Liguori  * @value: Value being written.
49849ee3590SAnthony Liguori  *
49949ee3590SAnthony Liguori  * Write a 32-bit value to an I/O port.
50049ee3590SAnthony Liguori  */
50149ee3590SAnthony Liguori void qtest_outl(QTestState *s, uint16_t addr, uint32_t value);
50249ee3590SAnthony Liguori 
50349ee3590SAnthony Liguori /**
50449ee3590SAnthony Liguori  * qtest_inb:
5056acf801dSAndreas Färber  * @s: #QTestState instance to operate on.
50649ee3590SAnthony Liguori  * @addr: I/O port to read from.
50749ee3590SAnthony Liguori  *
50849ee3590SAnthony Liguori  * Returns an 8-bit value from an I/O port.
50949ee3590SAnthony Liguori  */
51049ee3590SAnthony Liguori uint8_t qtest_inb(QTestState *s, uint16_t addr);
51149ee3590SAnthony Liguori 
51249ee3590SAnthony Liguori /**
51349ee3590SAnthony Liguori  * qtest_inw:
5146acf801dSAndreas Färber  * @s: #QTestState instance to operate on.
51549ee3590SAnthony Liguori  * @addr: I/O port to read from.
51649ee3590SAnthony Liguori  *
51749ee3590SAnthony Liguori  * Returns a 16-bit value from an I/O port.
51849ee3590SAnthony Liguori  */
51949ee3590SAnthony Liguori uint16_t qtest_inw(QTestState *s, uint16_t addr);
52049ee3590SAnthony Liguori 
52149ee3590SAnthony Liguori /**
52249ee3590SAnthony Liguori  * qtest_inl:
5236acf801dSAndreas Färber  * @s: #QTestState instance to operate on.
52449ee3590SAnthony Liguori  * @addr: I/O port to read from.
52549ee3590SAnthony Liguori  *
52649ee3590SAnthony Liguori  * Returns a 32-bit value from an I/O port.
52749ee3590SAnthony Liguori  */
52849ee3590SAnthony Liguori uint32_t qtest_inl(QTestState *s, uint16_t addr);
52949ee3590SAnthony Liguori 
53049ee3590SAnthony Liguori /**
531872536bfSAndreas Färber  * qtest_writeb:
532872536bfSAndreas Färber  * @s: #QTestState instance to operate on.
533872536bfSAndreas Färber  * @addr: Guest address to write to.
534872536bfSAndreas Färber  * @value: Value being written.
535872536bfSAndreas Färber  *
536872536bfSAndreas Färber  * Writes an 8-bit value to memory.
537872536bfSAndreas Färber  */
538872536bfSAndreas Färber void qtest_writeb(QTestState *s, uint64_t addr, uint8_t value);
539872536bfSAndreas Färber 
540872536bfSAndreas Färber /**
541872536bfSAndreas Färber  * qtest_writew:
542872536bfSAndreas Färber  * @s: #QTestState instance to operate on.
543872536bfSAndreas Färber  * @addr: Guest address to write to.
544872536bfSAndreas Färber  * @value: Value being written.
545872536bfSAndreas Färber  *
546872536bfSAndreas Färber  * Writes a 16-bit value to memory.
547872536bfSAndreas Färber  */
548872536bfSAndreas Färber void qtest_writew(QTestState *s, uint64_t addr, uint16_t value);
549872536bfSAndreas Färber 
550872536bfSAndreas Färber /**
551872536bfSAndreas Färber  * qtest_writel:
552872536bfSAndreas Färber  * @s: #QTestState instance to operate on.
553872536bfSAndreas Färber  * @addr: Guest address to write to.
554872536bfSAndreas Färber  * @value: Value being written.
555872536bfSAndreas Färber  *
556872536bfSAndreas Färber  * Writes a 32-bit value to memory.
557872536bfSAndreas Färber  */
558872536bfSAndreas Färber void qtest_writel(QTestState *s, uint64_t addr, uint32_t value);
559872536bfSAndreas Färber 
560872536bfSAndreas Färber /**
561872536bfSAndreas Färber  * qtest_writeq:
562872536bfSAndreas Färber  * @s: #QTestState instance to operate on.
563872536bfSAndreas Färber  * @addr: Guest address to write to.
564872536bfSAndreas Färber  * @value: Value being written.
565872536bfSAndreas Färber  *
566872536bfSAndreas Färber  * Writes a 64-bit value to memory.
567872536bfSAndreas Färber  */
568872536bfSAndreas Färber void qtest_writeq(QTestState *s, uint64_t addr, uint64_t value);
569872536bfSAndreas Färber 
570872536bfSAndreas Färber /**
571872536bfSAndreas Färber  * qtest_readb:
572872536bfSAndreas Färber  * @s: #QTestState instance to operate on.
573872536bfSAndreas Färber  * @addr: Guest address to read from.
574872536bfSAndreas Färber  *
575872536bfSAndreas Färber  * Reads an 8-bit value from memory.
576872536bfSAndreas Färber  *
577872536bfSAndreas Färber  * Returns: Value read.
578872536bfSAndreas Färber  */
579872536bfSAndreas Färber uint8_t qtest_readb(QTestState *s, uint64_t addr);
580872536bfSAndreas Färber 
581872536bfSAndreas Färber /**
582872536bfSAndreas Färber  * qtest_readw:
583872536bfSAndreas Färber  * @s: #QTestState instance to operate on.
584872536bfSAndreas Färber  * @addr: Guest address to read from.
585872536bfSAndreas Färber  *
586872536bfSAndreas Färber  * Reads a 16-bit value from memory.
587872536bfSAndreas Färber  *
588872536bfSAndreas Färber  * Returns: Value read.
589872536bfSAndreas Färber  */
590872536bfSAndreas Färber uint16_t qtest_readw(QTestState *s, uint64_t addr);
591872536bfSAndreas Färber 
592872536bfSAndreas Färber /**
593872536bfSAndreas Färber  * qtest_readl:
594872536bfSAndreas Färber  * @s: #QTestState instance to operate on.
595872536bfSAndreas Färber  * @addr: Guest address to read from.
596872536bfSAndreas Färber  *
597872536bfSAndreas Färber  * Reads a 32-bit value from memory.
598872536bfSAndreas Färber  *
599872536bfSAndreas Färber  * Returns: Value read.
600872536bfSAndreas Färber  */
601872536bfSAndreas Färber uint32_t qtest_readl(QTestState *s, uint64_t addr);
602872536bfSAndreas Färber 
603872536bfSAndreas Färber /**
604872536bfSAndreas Färber  * qtest_readq:
605872536bfSAndreas Färber  * @s: #QTestState instance to operate on.
606872536bfSAndreas Färber  * @addr: Guest address to read from.
607872536bfSAndreas Färber  *
608872536bfSAndreas Färber  * Reads a 64-bit value from memory.
609872536bfSAndreas Färber  *
610872536bfSAndreas Färber  * Returns: Value read.
611872536bfSAndreas Färber  */
612872536bfSAndreas Färber uint64_t qtest_readq(QTestState *s, uint64_t addr);
613872536bfSAndreas Färber 
614872536bfSAndreas Färber /**
61549ee3590SAnthony Liguori  * qtest_memread:
6166acf801dSAndreas Färber  * @s: #QTestState instance to operate on.
61749ee3590SAnthony Liguori  * @addr: Guest address to read from.
61849ee3590SAnthony Liguori  * @data: Pointer to where memory contents will be stored.
61949ee3590SAnthony Liguori  * @size: Number of bytes to read.
62049ee3590SAnthony Liguori  *
62149ee3590SAnthony Liguori  * Read guest memory into a buffer.
62249ee3590SAnthony Liguori  */
62349ee3590SAnthony Liguori void qtest_memread(QTestState *s, uint64_t addr, void *data, size_t size);
62449ee3590SAnthony Liguori 
62549ee3590SAnthony Liguori /**
626eeddd59fSLaurent Vivier  * qtest_rtas_call:
627eeddd59fSLaurent Vivier  * @s: #QTestState instance to operate on.
628eeddd59fSLaurent Vivier  * @name: name of the command to call.
629eeddd59fSLaurent Vivier  * @nargs: Number of args.
630eeddd59fSLaurent Vivier  * @args: Guest address to read args from.
631eeddd59fSLaurent Vivier  * @nret: Number of return value.
632eeddd59fSLaurent Vivier  * @ret: Guest address to write return values to.
633eeddd59fSLaurent Vivier  *
634eeddd59fSLaurent Vivier  * Call an RTAS function
635eeddd59fSLaurent Vivier  */
636eeddd59fSLaurent Vivier uint64_t qtest_rtas_call(QTestState *s, const char *name,
637eeddd59fSLaurent Vivier                          uint32_t nargs, uint64_t args,
638eeddd59fSLaurent Vivier                          uint32_t nret, uint64_t ret);
639eeddd59fSLaurent Vivier 
640eeddd59fSLaurent Vivier /**
6411addf571SIvan Klokov  * qtest_csr_call:
6421addf571SIvan Klokov  * @s: #QTestState instance to operate on.
6431addf571SIvan Klokov  * @name: name of the command to call.
6441addf571SIvan Klokov  * @cpu: hart number.
6451addf571SIvan Klokov  * @csr: CSR number.
6461addf571SIvan Klokov  * @val: Value for reading/writing.
6471addf571SIvan Klokov  *
6481addf571SIvan Klokov  * Call an RISC-V CSR read/write function
6491addf571SIvan Klokov  */
6501addf571SIvan Klokov uint64_t qtest_csr_call(QTestState *s, const char *name,
6511addf571SIvan Klokov                          uint64_t cpu, int csr,
6521addf571SIvan Klokov                          uint64_t *val);
6531addf571SIvan Klokov 
6541addf571SIvan Klokov /**
6557a6a740dSJohn Snow  * qtest_bufread:
6567a6a740dSJohn Snow  * @s: #QTestState instance to operate on.
6577a6a740dSJohn Snow  * @addr: Guest address to read from.
6587a6a740dSJohn Snow  * @data: Pointer to where memory contents will be stored.
6597a6a740dSJohn Snow  * @size: Number of bytes to read.
6607a6a740dSJohn Snow  *
6617a6a740dSJohn Snow  * Read guest memory into a buffer and receive using a base64 encoding.
6627a6a740dSJohn Snow  */
6637a6a740dSJohn Snow void qtest_bufread(QTestState *s, uint64_t addr, void *data, size_t size);
6647a6a740dSJohn Snow 
6657a6a740dSJohn Snow /**
66649ee3590SAnthony Liguori  * qtest_memwrite:
6676acf801dSAndreas Färber  * @s: #QTestState instance to operate on.
66849ee3590SAnthony Liguori  * @addr: Guest address to write to.
66949ee3590SAnthony Liguori  * @data: Pointer to the bytes that will be written to guest memory.
67049ee3590SAnthony Liguori  * @size: Number of bytes to write.
67149ee3590SAnthony Liguori  *
67249ee3590SAnthony Liguori  * Write a buffer to guest memory.
67349ee3590SAnthony Liguori  */
67449ee3590SAnthony Liguori void qtest_memwrite(QTestState *s, uint64_t addr, const void *data, size_t size);
67549ee3590SAnthony Liguori 
67649ee3590SAnthony Liguori /**
6777a6a740dSJohn Snow  * qtest_bufwrite:
6787a6a740dSJohn Snow  * @s: #QTestState instance to operate on.
6797a6a740dSJohn Snow  * @addr: Guest address to write to.
6807a6a740dSJohn Snow  * @data: Pointer to the bytes that will be written to guest memory.
6817a6a740dSJohn Snow  * @size: Number of bytes to write.
6827a6a740dSJohn Snow  *
6837a6a740dSJohn Snow  * Write a buffer to guest memory and transmit using a base64 encoding.
6847a6a740dSJohn Snow  */
6857a6a740dSJohn Snow void qtest_bufwrite(QTestState *s, uint64_t addr,
6867a6a740dSJohn Snow                     const void *data, size_t size);
6877a6a740dSJohn Snow 
6887a6a740dSJohn Snow /**
68986298845SJohn Snow  * qtest_memset:
69086298845SJohn Snow  * @s: #QTestState instance to operate on.
69186298845SJohn Snow  * @addr: Guest address to write to.
69286298845SJohn Snow  * @patt: Byte pattern to fill the guest memory region with.
69386298845SJohn Snow  * @size: Number of bytes to write.
69486298845SJohn Snow  *
69586298845SJohn Snow  * Write a pattern to guest memory.
69686298845SJohn Snow  */
69786298845SJohn Snow void qtest_memset(QTestState *s, uint64_t addr, uint8_t patt, size_t size);
69886298845SJohn Snow 
69986298845SJohn Snow /**
70049ee3590SAnthony Liguori  * qtest_clock_step_next:
7016acf801dSAndreas Färber  * @s: #QTestState instance to operate on.
70249ee3590SAnthony Liguori  *
703bc72ad67SAlex Bligh  * Advance the QEMU_CLOCK_VIRTUAL to the next deadline.
7046acf801dSAndreas Färber  *
705bc72ad67SAlex Bligh  * Returns: The current value of the QEMU_CLOCK_VIRTUAL in nanoseconds.
70649ee3590SAnthony Liguori  */
70749ee3590SAnthony Liguori int64_t qtest_clock_step_next(QTestState *s);
70849ee3590SAnthony Liguori 
70949ee3590SAnthony Liguori /**
71049ee3590SAnthony Liguori  * qtest_clock_step:
71149ee3590SAnthony Liguori  * @s: QTestState instance to operate on.
71249ee3590SAnthony Liguori  * @step: Number of nanoseconds to advance the clock by.
71349ee3590SAnthony Liguori  *
714bc72ad67SAlex Bligh  * Advance the QEMU_CLOCK_VIRTUAL by @step nanoseconds.
7156acf801dSAndreas Färber  *
716bc72ad67SAlex Bligh  * Returns: The current value of the QEMU_CLOCK_VIRTUAL in nanoseconds.
71749ee3590SAnthony Liguori  */
71849ee3590SAnthony Liguori int64_t qtest_clock_step(QTestState *s, int64_t step);
71949ee3590SAnthony Liguori 
72049ee3590SAnthony Liguori /**
72149ee3590SAnthony Liguori  * qtest_clock_set:
72249ee3590SAnthony Liguori  * @s: QTestState instance to operate on.
72349ee3590SAnthony Liguori  * @val: Nanoseconds value to advance the clock to.
72449ee3590SAnthony Liguori  *
725bc72ad67SAlex Bligh  * Advance the QEMU_CLOCK_VIRTUAL to @val nanoseconds since the VM was launched.
7266acf801dSAndreas Färber  *
727bc72ad67SAlex Bligh  * Returns: The current value of the QEMU_CLOCK_VIRTUAL in nanoseconds.
72849ee3590SAnthony Liguori  */
72949ee3590SAnthony Liguori int64_t qtest_clock_set(QTestState *s, int64_t val);
73049ee3590SAnthony Liguori 
73149ee3590SAnthony Liguori /**
73254ce6f22SLaurent Vivier  * qtest_big_endian:
73354ce6f22SLaurent Vivier  * @s: QTestState instance to operate on.
73454ce6f22SLaurent Vivier  *
73554ce6f22SLaurent Vivier  * Returns: True if the architecture under test has a big endian configuration.
73654ce6f22SLaurent Vivier  */
73754ce6f22SLaurent Vivier bool qtest_big_endian(QTestState *s);
73854ce6f22SLaurent Vivier 
73954ce6f22SLaurent Vivier /**
74049ee3590SAnthony Liguori  * qtest_get_arch:
74149ee3590SAnthony Liguori  *
7426acf801dSAndreas Färber  * Returns: The architecture for the QEMU executable under test.
74349ee3590SAnthony Liguori  */
74449ee3590SAnthony Liguori const char *qtest_get_arch(void);
74549ee3590SAnthony Liguori 
74649ee3590SAnthony Liguori /**
747e741aff0SIgor Mammedov  * qtest_has_accel:
748e741aff0SIgor Mammedov  * @accel_name: Accelerator name to check for.
749e741aff0SIgor Mammedov  *
750e741aff0SIgor Mammedov  * Returns: true if the accelerator is built in.
751e741aff0SIgor Mammedov  */
752e741aff0SIgor Mammedov bool qtest_has_accel(const char *accel_name);
753e741aff0SIgor Mammedov 
754e741aff0SIgor Mammedov /**
75549ee3590SAnthony Liguori  * qtest_add_func:
75649ee3590SAnthony Liguori  * @str: Test case path.
75749ee3590SAnthony Liguori  * @fn: Test case function
75849ee3590SAnthony Liguori  *
75949ee3590SAnthony Liguori  * Add a GTester testcase with the given name and function.
76049ee3590SAnthony Liguori  * The path is prefixed with the architecture under test, as
7616acf801dSAndreas Färber  * returned by qtest_get_arch().
76249ee3590SAnthony Liguori  */
763041088c7SMarkus Armbruster void qtest_add_func(const char *str, void (*fn)(void));
76449ee3590SAnthony Liguori 
76549ee3590SAnthony Liguori /**
7667949c0e3SAndreas Färber  * qtest_add_data_func:
7677949c0e3SAndreas Färber  * @str: Test case path.
7687949c0e3SAndreas Färber  * @data: Test case data
7697949c0e3SAndreas Färber  * @fn: Test case function
7707949c0e3SAndreas Färber  *
7717949c0e3SAndreas Färber  * Add a GTester testcase with the given name, data and function.
7727949c0e3SAndreas Färber  * The path is prefixed with the architecture under test, as
7737949c0e3SAndreas Färber  * returned by qtest_get_arch().
7747949c0e3SAndreas Färber  */
775041088c7SMarkus Armbruster void qtest_add_data_func(const char *str, const void *data,
776041088c7SMarkus Armbruster                          void (*fn)(const void *));
7777949c0e3SAndreas Färber 
7787949c0e3SAndreas Färber /**
779822e36caSMarc-André Lureau  * qtest_add_data_func_full:
780822e36caSMarc-André Lureau  * @str: Test case path.
781822e36caSMarc-André Lureau  * @data: Test case data
782822e36caSMarc-André Lureau  * @fn: Test case function
783822e36caSMarc-André Lureau  * @data_free_func: GDestroyNotify for data
784822e36caSMarc-André Lureau  *
785822e36caSMarc-André Lureau  * Add a GTester testcase with the given name, data and function.
786822e36caSMarc-André Lureau  * The path is prefixed with the architecture under test, as
787822e36caSMarc-André Lureau  * returned by qtest_get_arch().
788822e36caSMarc-André Lureau  *
789822e36caSMarc-André Lureau  * @data is passed to @data_free_func() on test completion.
790822e36caSMarc-André Lureau  */
791822e36caSMarc-André Lureau void qtest_add_data_func_full(const char *str, void *data,
792822e36caSMarc-André Lureau                               void (*fn)(const void *),
793822e36caSMarc-André Lureau                               GDestroyNotify data_free_func);
794822e36caSMarc-André Lureau 
795822e36caSMarc-André Lureau /**
79645b0f830SAndreas Färber  * qtest_add:
79745b0f830SAndreas Färber  * @testpath: Test case path
79845b0f830SAndreas Färber  * @Fixture: Fixture type
79945b0f830SAndreas Färber  * @tdata: Test case data
80045b0f830SAndreas Färber  * @fsetup: Test case setup function
80145b0f830SAndreas Färber  * @ftest: Test case function
80245b0f830SAndreas Färber  * @fteardown: Test case teardown function
80345b0f830SAndreas Färber  *
80445b0f830SAndreas Färber  * Add a GTester testcase with the given name, data and functions.
80545b0f830SAndreas Färber  * The path is prefixed with the architecture under test, as
80645b0f830SAndreas Färber  * returned by qtest_get_arch().
80745b0f830SAndreas Färber  */
80845b0f830SAndreas Färber #define qtest_add(testpath, Fixture, tdata, fsetup, ftest, fteardown) \
80945b0f830SAndreas Färber     do { \
81045b0f830SAndreas Färber         char *path = g_strdup_printf("/%s/%s", qtest_get_arch(), testpath); \
81145b0f830SAndreas Färber         g_test_add(path, Fixture, tdata, fsetup, ftest, fteardown); \
81245b0f830SAndreas Färber         g_free(path); \
81345b0f830SAndreas Färber     } while (0)
81445b0f830SAndreas Färber 
815e1fa7f55SStefan Hajnoczi /**
816e1fa7f55SStefan Hajnoczi  * qtest_add_abrt_handler:
817e1fa7f55SStefan Hajnoczi  * @fn: Handler function
818e1fa7f55SStefan Hajnoczi  * @data: Argument that is passed to the handler
819e1fa7f55SStefan Hajnoczi  *
820e1fa7f55SStefan Hajnoczi  * Add a handler function that is invoked on SIGABRT. This can be used to
821e1fa7f55SStefan Hajnoczi  * terminate processes and perform other cleanup. The handler can be removed
822e1fa7f55SStefan Hajnoczi  * with qtest_remove_abrt_handler().
823e1fa7f55SStefan Hajnoczi  */
824041088c7SMarkus Armbruster void qtest_add_abrt_handler(GHookFunc fn, const void *data);
825063c23d9SMarc-André Lureau 
82645b0f830SAndreas Färber /**
827e1fa7f55SStefan Hajnoczi  * qtest_remove_abrt_handler:
828e1fa7f55SStefan Hajnoczi  * @data: Argument previously passed to qtest_add_abrt_handler()
829e1fa7f55SStefan Hajnoczi  *
830e1fa7f55SStefan Hajnoczi  * Remove an abrt handler that was previously added with
831e1fa7f55SStefan Hajnoczi  * qtest_add_abrt_handler().
832e1fa7f55SStefan Hajnoczi  */
833e1fa7f55SStefan Hajnoczi void qtest_remove_abrt_handler(void *data);
834e1fa7f55SStefan Hajnoczi 
835e1fa7f55SStefan Hajnoczi /**
83628760edcSDaniel P. Berrangé  * qtest_vqmp_assert_success_ref:
83728760edcSDaniel P. Berrangé  * @qts: QTestState instance to operate on
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 to QEMU, asserts that a 'return' key is present in
84428760edcSDaniel P. Berrangé  * the response, and returns the response.
84528760edcSDaniel P. Berrangé  */
84628760edcSDaniel P. Berrangé QDict *qtest_vqmp_assert_success_ref(QTestState *qts,
84728760edcSDaniel P. Berrangé                                      const char *fmt, va_list args)
84828760edcSDaniel P. Berrangé     G_GNUC_PRINTF(2, 0);
84928760edcSDaniel P. Berrangé 
85028760edcSDaniel P. Berrangé /**
85128760edcSDaniel P. Berrangé  * qtest_vqmp_assert_success:
85228760edcSDaniel P. Berrangé  * @qts: QTestState instance to operate on
85328760edcSDaniel P. Berrangé  * @fmt: QMP message to send to qemu, formatted like
85428760edcSDaniel P. Berrangé  * qobject_from_jsonf_nofail().  See parse_interpolation() for what's
85528760edcSDaniel P. Berrangé  * supported after '%'.
85628760edcSDaniel P. Berrangé  * @args: variable arguments for @fmt
85728760edcSDaniel P. Berrangé  *
85828760edcSDaniel P. Berrangé  * Sends a QMP message to QEMU and asserts that a 'return' key is present in
85928760edcSDaniel P. Berrangé  * the response.
86028760edcSDaniel P. Berrangé  */
86128760edcSDaniel P. Berrangé void qtest_vqmp_assert_success(QTestState *qts,
86228760edcSDaniel P. Berrangé                                const char *fmt, va_list args)
86328760edcSDaniel P. Berrangé     G_GNUC_PRINTF(2, 0);
86428760edcSDaniel P. Berrangé 
86528760edcSDaniel P. Berrangé #ifndef _WIN32
86628760edcSDaniel P. Berrangé /**
86728760edcSDaniel P. Berrangé  * qtest_vqmp_fds_assert_success_ref:
86828760edcSDaniel P. Berrangé  * @qts: QTestState instance to operate on
86928760edcSDaniel P. Berrangé  * @fds: the file descriptors to send
87028760edcSDaniel P. Berrangé  * @nfds: number of @fds to send
87128760edcSDaniel P. Berrangé  * @fmt: QMP message to send to qemu, formatted like
87228760edcSDaniel P. Berrangé  * qobject_from_jsonf_nofail().  See parse_interpolation() for what's
87328760edcSDaniel P. Berrangé  * supported after '%'.
87428760edcSDaniel P. Berrangé  * @args: variable arguments for @fmt
87528760edcSDaniel P. Berrangé  *
87628760edcSDaniel P. Berrangé  * Sends a QMP message with file descriptors to QEMU,
87728760edcSDaniel P. Berrangé  * asserts that a 'return' key is present in the response,
87828760edcSDaniel P. Berrangé  * and returns the response.
87928760edcSDaniel P. Berrangé  */
88028760edcSDaniel P. Berrangé QDict *qtest_vqmp_fds_assert_success_ref(QTestState *qts, int *fds, size_t nfds,
88128760edcSDaniel P. Berrangé                                          const char *fmt, va_list args)
88228760edcSDaniel P. Berrangé     G_GNUC_PRINTF(4, 0);
88328760edcSDaniel P. Berrangé 
88428760edcSDaniel P. Berrangé /**
88528760edcSDaniel P. Berrangé  * qtest_vqmp_fds_assert_success:
88628760edcSDaniel P. Berrangé  * @qts: QTestState instance to operate on
88728760edcSDaniel P. Berrangé  * @fds: the file descriptors to send
88828760edcSDaniel P. Berrangé  * @nfds: number of @fds to send
88928760edcSDaniel P. Berrangé  * @fmt: QMP message to send to qemu, formatted like
89028760edcSDaniel P. Berrangé  * qobject_from_jsonf_nofail().  See parse_interpolation() for what's
89128760edcSDaniel P. Berrangé  * supported after '%'.
89228760edcSDaniel P. Berrangé  * @args: variable arguments for @fmt
89328760edcSDaniel P. Berrangé  *
89428760edcSDaniel P. Berrangé  * Sends a QMP message with file descriptors to QEMU and
89528760edcSDaniel P. Berrangé  * asserts that a 'return' key is present in the response.
89628760edcSDaniel P. Berrangé  */
89728760edcSDaniel P. Berrangé void qtest_vqmp_fds_assert_success(QTestState *qts, int *fds, size_t nfds,
89828760edcSDaniel P. Berrangé                                    const char *fmt, va_list args)
89928760edcSDaniel P. Berrangé     G_GNUC_PRINTF(4, 0);
90028760edcSDaniel P. Berrangé #endif /* !_WIN32 */
90128760edcSDaniel P. Berrangé 
90228760edcSDaniel P. Berrangé /**
9035274274cSFabiano Rosas  * qtest_qmp_assert_failure_ref:
9045274274cSFabiano Rosas  * @qts: QTestState instance to operate on
9055274274cSFabiano Rosas  * @fmt: QMP message to send to qemu, formatted like
9065274274cSFabiano Rosas  * qobject_from_jsonf_nofail().  See parse_interpolation() for what's
9075274274cSFabiano Rosas  * supported after '%'.
9085274274cSFabiano Rosas  *
9095274274cSFabiano Rosas  * Sends a QMP message to QEMU, asserts that an 'error' key is present in
9105274274cSFabiano Rosas  * the response, and returns the response.
9115274274cSFabiano Rosas  */
9125274274cSFabiano Rosas QDict *qtest_qmp_assert_failure_ref(QTestState *qts, const char *fmt, ...)
9135274274cSFabiano Rosas     G_GNUC_PRINTF(2, 3);
9145274274cSFabiano Rosas 
9155274274cSFabiano Rosas /**
9165274274cSFabiano Rosas  * qtest_vqmp_assert_failure_ref:
9175274274cSFabiano Rosas  * @qts: QTestState instance to operate on
9185274274cSFabiano Rosas  * @fmt: QMP message to send to qemu, formatted like
9195274274cSFabiano Rosas  * qobject_from_jsonf_nofail().  See parse_interpolation() for what's
9205274274cSFabiano Rosas  * supported after '%'.
9215274274cSFabiano Rosas  * @args: variable arguments for @fmt
9225274274cSFabiano Rosas  *
9235274274cSFabiano Rosas  * Sends a QMP message to QEMU, asserts that an 'error' key is present in
9245274274cSFabiano Rosas  * the response, and returns the response.
9255274274cSFabiano Rosas  */
9265274274cSFabiano Rosas QDict *qtest_vqmp_assert_failure_ref(QTestState *qts,
9275274274cSFabiano Rosas                                      const char *fmt, va_list args)
9285274274cSFabiano Rosas     G_GNUC_PRINTF(2, 0);
9295274274cSFabiano Rosas 
9305274274cSFabiano Rosas /**
93128760edcSDaniel P. Berrangé  * qtest_qmp_assert_success_ref:
93228760edcSDaniel P. Berrangé  * @qts: QTestState instance to operate on
93328760edcSDaniel P. Berrangé  * @fmt: QMP message to send to qemu, formatted like
93428760edcSDaniel P. Berrangé  * qobject_from_jsonf_nofail().  See parse_interpolation() for what's
93528760edcSDaniel P. Berrangé  * supported after '%'.
93628760edcSDaniel P. Berrangé  *
93728760edcSDaniel P. Berrangé  * Sends a QMP message to QEMU, asserts that a 'return' key is present in
93828760edcSDaniel P. Berrangé  * the response, and returns the response.
93928760edcSDaniel P. Berrangé  */
94028760edcSDaniel P. Berrangé QDict *qtest_qmp_assert_success_ref(QTestState *qts, const char *fmt, ...)
94128760edcSDaniel P. Berrangé     G_GNUC_PRINTF(2, 3);
94228760edcSDaniel P. Berrangé 
94328760edcSDaniel P. Berrangé /**
9446fc9f3d3SThomas Huth  * qtest_qmp_assert_success:
9456fc9f3d3SThomas Huth  * @qts: QTestState instance to operate on
94651c778edSEduardo Habkost  * @fmt: QMP message to send to qemu, formatted like
947ad57e2b1SPeter Maydell  * qobject_from_jsonf_nofail().  See parse_interpolation() for what's
948edbe36adSKevin Wolf  * supported after '%'.
949edbe36adSKevin Wolf  *
950edbe36adSKevin Wolf  * Sends a QMP message to QEMU and asserts that a 'return' key is present in
951edbe36adSKevin Wolf  * the response.
952edbe36adSKevin Wolf  */
9536fc9f3d3SThomas Huth void qtest_qmp_assert_success(QTestState *qts, const char *fmt, ...)
9549edc6313SMarc-André Lureau     G_GNUC_PRINTF(2, 3);
955edbe36adSKevin Wolf 
95628760edcSDaniel P. Berrangé #ifndef _WIN32
95728760edcSDaniel P. Berrangé /**
95864965b4bSAlex Bennée  * qtest_qmp_fds_assert_success_ref:
95928760edcSDaniel P. Berrangé  * @qts: QTestState instance to operate on
96028760edcSDaniel P. Berrangé  * @fds: the file descriptors to send
96128760edcSDaniel P. Berrangé  * @nfds: number of @fds to send
96228760edcSDaniel P. Berrangé  * @fmt: QMP message to send to qemu, formatted like
96328760edcSDaniel P. Berrangé  * qobject_from_jsonf_nofail().  See parse_interpolation() for what's
96428760edcSDaniel P. Berrangé  * supported after '%'.
96528760edcSDaniel P. Berrangé  *
96628760edcSDaniel P. Berrangé  * Sends a QMP message with file descriptors to QEMU,
96728760edcSDaniel P. Berrangé  * asserts that a 'return' key is present in the response,
96828760edcSDaniel P. Berrangé  * and returns the response.
96928760edcSDaniel P. Berrangé  */
97028760edcSDaniel P. Berrangé QDict *qtest_qmp_fds_assert_success_ref(QTestState *qts, int *fds, size_t nfds,
97128760edcSDaniel P. Berrangé                                         const char *fmt, ...)
97228760edcSDaniel P. Berrangé     G_GNUC_PRINTF(4, 5);
97328760edcSDaniel P. Berrangé 
97428760edcSDaniel P. Berrangé /**
97564965b4bSAlex Bennée  * qtest_qmp_fds_assert_success:
97628760edcSDaniel P. Berrangé  * @qts: QTestState instance to operate on
97728760edcSDaniel P. Berrangé  * @fds: the file descriptors to send
97828760edcSDaniel P. Berrangé  * @nfds: number of @fds to send
97928760edcSDaniel P. Berrangé  * @fmt: QMP message to send to qemu, formatted like
98028760edcSDaniel P. Berrangé  * qobject_from_jsonf_nofail().  See parse_interpolation() for what's
98128760edcSDaniel P. Berrangé  * supported after '%'.
98228760edcSDaniel P. Berrangé  *
98328760edcSDaniel P. Berrangé  * Sends a QMP message with file descriptors to QEMU and
98428760edcSDaniel P. Berrangé  * asserts that a 'return' key is present in the response.
98528760edcSDaniel P. Berrangé  */
98628760edcSDaniel P. Berrangé void qtest_qmp_fds_assert_success(QTestState *qts, int *fds, size_t nfds,
98728760edcSDaniel P. Berrangé                                   const char *fmt, ...)
98828760edcSDaniel P. Berrangé     G_GNUC_PRINTF(4, 5);
98928760edcSDaniel P. Berrangé #endif /* !_WIN32 */
99028760edcSDaniel P. Berrangé 
99102ef6e87SThomas Huth /**
99202ef6e87SThomas Huth  * qtest_cb_for_every_machine:
99302ef6e87SThomas Huth  * @cb: Pointer to the callback function
9941f4a0d81SThomas Huth  * @skip_old_versioned: true if versioned old machine types should be skipped
99502ef6e87SThomas Huth  *
99602ef6e87SThomas Huth  *  Call a callback function for every name of all available machines.
99702ef6e87SThomas Huth  */
9981f4a0d81SThomas Huth void qtest_cb_for_every_machine(void (*cb)(const char *machine),
9991f4a0d81SThomas Huth                                 bool skip_old_versioned);
100002ef6e87SThomas Huth 
1001acd80015SThomas Huth /**
1002a3c0ebc9SFabiano Rosas  * qtest_resolve_machine_alias:
1003a3c0ebc9SFabiano Rosas  * @var: Environment variable from where to take the QEMU binary
1004a3c0ebc9SFabiano Rosas  * @alias: The alias to resolve
1005a3c0ebc9SFabiano Rosas  *
1006a3c0ebc9SFabiano Rosas  * Returns: the machine type corresponding to the alias if any,
1007a3c0ebc9SFabiano Rosas  * otherwise NULL.
1008a3c0ebc9SFabiano Rosas  */
1009a3c0ebc9SFabiano Rosas char *qtest_resolve_machine_alias(const char *var, const char *alias);
1010a3c0ebc9SFabiano Rosas 
1011a3c0ebc9SFabiano Rosas /**
1012719051caSThomas Huth  * qtest_has_machine:
1013719051caSThomas Huth  * @machine: The machine to look for
1014719051caSThomas Huth  *
1015719051caSThomas Huth  * Returns: true if the machine is available in the target binary.
1016719051caSThomas Huth  */
1017719051caSThomas Huth bool qtest_has_machine(const char *machine);
1018719051caSThomas Huth 
1019719051caSThomas Huth /**
10201027fc0aSFabiano Rosas  * qtest_has_machine_with_env:
10211027fc0aSFabiano Rosas  * @var: Environment variable from where to take the QEMU binary
10221027fc0aSFabiano Rosas  * @machine: The machine to look for
10231027fc0aSFabiano Rosas  *
10241027fc0aSFabiano Rosas  * Returns: true if the machine is available in the specified binary.
10251027fc0aSFabiano Rosas  */
10261027fc0aSFabiano Rosas bool qtest_has_machine_with_env(const char *var, const char *machine);
10271027fc0aSFabiano Rosas 
10281027fc0aSFabiano Rosas /**
1029f43f8abeSAni Sinha  * qtest_has_cpu_model:
1030f43f8abeSAni Sinha  * @cpu: The cpu to look for
1031f43f8abeSAni Sinha  *
1032f43f8abeSAni Sinha  * Returns: true if the cpu is available in the target binary.
1033f43f8abeSAni Sinha  */
1034f43f8abeSAni Sinha bool qtest_has_cpu_model(const char *cpu);
1035f43f8abeSAni Sinha 
1036f43f8abeSAni Sinha /**
1037ad9e129bSThomas Huth  * qtest_has_device:
1038ad9e129bSThomas Huth  * @device: The device to look for
1039ad9e129bSThomas Huth  *
1040ad9e129bSThomas Huth  * Returns: true if the device is available in the target binary.
1041ad9e129bSThomas Huth  */
1042ad9e129bSThomas Huth bool qtest_has_device(const char *device);
1043ad9e129bSThomas Huth 
1044ad9e129bSThomas Huth /**
1045b4510bb4SIgor Mammedov  * qtest_qmp_device_add_qdict:
1046b4510bb4SIgor Mammedov  * @qts: QTestState instance to operate on
1047b4510bb4SIgor Mammedov  * @drv: Name of the device that should be added
10481e458f11SStefan Weil  * @arguments: QDict with properties for the device to initialize
1049b4510bb4SIgor Mammedov  *
1050b4510bb4SIgor Mammedov  * Generic hot-plugging test via the device_add QMP command with properties
1051b4510bb4SIgor Mammedov  * supplied in form of QDict. Use NULL for empty properties list.
1052b4510bb4SIgor Mammedov  */
1053b4510bb4SIgor Mammedov void qtest_qmp_device_add_qdict(QTestState *qts, const char *drv,
1054b4510bb4SIgor Mammedov                                 const QDict *arguments);
1055b4510bb4SIgor Mammedov 
1056b4510bb4SIgor Mammedov /**
1057acd80015SThomas Huth  * qtest_qmp_device_add:
1058e5758de4SThomas Huth  * @qts: QTestState instance to operate on
1059acd80015SThomas Huth  * @driver: Name of the device that should be added
1060acd80015SThomas Huth  * @id: Identification string
106151c778edSEduardo Habkost  * @fmt: QMP message to send to qemu, formatted like
1062ad57e2b1SPeter Maydell  * qobject_from_jsonf_nofail().  See parse_interpolation() for what's
106382cab70bSMarkus Armbruster  * supported after '%'.
1064acd80015SThomas Huth  *
1065acd80015SThomas Huth  * Generic hot-plugging test via the device_add QMP command.
1066acd80015SThomas Huth  */
1067e5758de4SThomas Huth void qtest_qmp_device_add(QTestState *qts, const char *driver, const char *id,
10689edc6313SMarc-André Lureau                           const char *fmt, ...) G_GNUC_PRINTF(4, 5);
1069acd80015SThomas Huth 
1070acd80015SThomas Huth /**
10712c7294d7SMarc-André Lureau  * qtest_qmp_add_client:
10722c7294d7SMarc-André Lureau  * @qts: QTestState instance to operate on
10732c7294d7SMarc-André Lureau  * @protocol: the protocol to add to
10742c7294d7SMarc-André Lureau  * @fd: the client file-descriptor
10752c7294d7SMarc-André Lureau  *
107661683d27SMarc-André Lureau  * Call QMP ``getfd`` (on Windows ``get-win32-socket``) followed by
107761683d27SMarc-André Lureau  * ``add_client`` with the given @fd.
10782c7294d7SMarc-André Lureau  */
10792c7294d7SMarc-André Lureau void qtest_qmp_add_client(QTestState *qts, const char *protocol, int fd);
10802c7294d7SMarc-André Lureau 
10812c7294d7SMarc-André Lureau /**
1082ea42a6c4SMichael Labiuk  * qtest_qmp_device_del_send:
1083ea42a6c4SMichael Labiuk  * @qts: QTestState instance to operate on
1084ea42a6c4SMichael Labiuk  * @id: Identification string
1085ea42a6c4SMichael Labiuk  *
1086ea42a6c4SMichael Labiuk  * Generic hot-unplugging test via the device_del QMP command.
1087ea42a6c4SMichael Labiuk  */
1088ea42a6c4SMichael Labiuk void qtest_qmp_device_del_send(QTestState *qts, const char *id);
1089ea42a6c4SMichael Labiuk 
1090ea42a6c4SMichael Labiuk /**
1091acd80015SThomas Huth  * qtest_qmp_device_del:
1092e5758de4SThomas Huth  * @qts: QTestState instance to operate on
1093acd80015SThomas Huth  * @id: Identification string
1094acd80015SThomas Huth  *
1095acd80015SThomas Huth  * Generic hot-unplugging test via the device_del QMP command.
1096ea42a6c4SMichael Labiuk  * Waiting for command completion event.
1097acd80015SThomas Huth  */
1098e5758de4SThomas Huth void qtest_qmp_device_del(QTestState *qts, const char *id);
1099acd80015SThomas Huth 
1100c35665e1SIgor Mammedov /**
110121f80286SRichard Henderson  * qtest_probe_child:
110221f80286SRichard Henderson  * @s: QTestState instance to operate on.
110321f80286SRichard Henderson  *
110421f80286SRichard Henderson  * Returns: true if the child is still alive.
110521f80286SRichard Henderson  */
110621f80286SRichard Henderson bool qtest_probe_child(QTestState *s);
110721f80286SRichard Henderson 
1108d43e59e7SYury Kotov /**
1109d43e59e7SYury Kotov  * qtest_set_expected_status:
1110d43e59e7SYury Kotov  * @s: QTestState instance to operate on.
1111d43e59e7SYury Kotov  * @status: an expected exit status.
1112d43e59e7SYury Kotov  *
1113d43e59e7SYury Kotov  * Set expected exit status of the child.
1114d43e59e7SYury Kotov  */
1115d43e59e7SYury Kotov void qtest_set_expected_status(QTestState *s, int status);
1116d43e59e7SYury Kotov 
1117ca5d4641SAlexander Bulekov QTestState *qtest_inproc_init(QTestState **s, bool log, const char* arch,
1118ca5d4641SAlexander Bulekov                     void (*send)(void*, const char*));
1119ca5d4641SAlexander Bulekov 
1120ca5d4641SAlexander Bulekov void qtest_client_inproc_recv(void *opaque, const char *str);
1121188052a1SIris Chen 
1122188052a1SIris Chen /**
1123188052a1SIris Chen  * qtest_qom_set_bool:
1124188052a1SIris Chen  * @s: QTestState instance to operate on.
1125188052a1SIris Chen  * @path: Path to the property being set.
1126188052a1SIris Chen  * @property: Property being set.
1127188052a1SIris Chen  * @value: Value to set the property.
1128188052a1SIris Chen  *
1129188052a1SIris Chen  * Set the property with passed in value.
1130188052a1SIris Chen  */
1131188052a1SIris Chen void qtest_qom_set_bool(QTestState *s, const char *path, const char *property,
1132188052a1SIris Chen                          bool value);
1133188052a1SIris Chen 
1134188052a1SIris Chen /**
1135188052a1SIris Chen  * qtest_qom_get_bool:
1136188052a1SIris Chen  * @s: QTestState instance to operate on.
1137188052a1SIris Chen  * @path: Path to the property being retrieved.
1138188052a1SIris Chen  * @property: Property from where the value is being retrieved.
1139188052a1SIris Chen  *
1140188052a1SIris Chen  * Returns: Value retrieved from property.
1141188052a1SIris Chen  */
1142188052a1SIris Chen bool qtest_qom_get_bool(QTestState *s, const char *path, const char *property);
1143ed097649SMarc-André Lureau 
1144ed097649SMarc-André Lureau /**
1145ed097649SMarc-André Lureau  * qtest_pid:
1146ed097649SMarc-André Lureau  * @s: QTestState instance to operate on.
1147ed097649SMarc-André Lureau  *
1148ed097649SMarc-André Lureau  * Returns: the PID of the QEMU process, or <= 0
1149ed097649SMarc-André Lureau  */
1150ed097649SMarc-André Lureau pid_t qtest_pid(QTestState *s);
1151ed097649SMarc-André Lureau 
115225919c40SThomas Huth /**
115325919c40SThomas Huth  * have_qemu_img:
115425919c40SThomas Huth  *
115525919c40SThomas Huth  * Returns: true if "qemu-img" is available.
115625919c40SThomas Huth  */
115725919c40SThomas Huth bool have_qemu_img(void);
115825919c40SThomas Huth 
115925919c40SThomas Huth /**
116025919c40SThomas Huth  * mkimg:
116125919c40SThomas Huth  * @file: File name of the image that should be created
116225919c40SThomas Huth  * @fmt: Format, e.g. "qcow2" or "raw"
116325919c40SThomas Huth  * @size_mb: Size of the image in megabytes
116425919c40SThomas Huth  *
116525919c40SThomas Huth  * Create a disk image with qemu-img. Note that the QTEST_QEMU_IMG
116625919c40SThomas Huth  * environment variable must point to the qemu-img file.
116725919c40SThomas Huth  *
116825919c40SThomas Huth  * Returns: true if the image has been created successfully.
116925919c40SThomas Huth  */
117025919c40SThomas Huth bool mkimg(const char *file, const char *fmt, unsigned size_mb);
117125919c40SThomas Huth 
117249ee3590SAnthony Liguori #endif
1173