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 20407bc4bfSDaniel P. Berrangé #include "qobject/qobject.h" 21407bc4bfSDaniel P. Berrangé #include "qobject/qdict.h" 22407bc4bfSDaniel 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 /** 60*246069e8SVladimir Sementsov-Ogievskiy * qtest_init_ext: 6199baa5d9SJuraj Marcin * @var: Environment variable from where to take the QEMU binary 6299baa5d9SJuraj Marcin * @extra_args: Other arguments to pass to QEMU. CAUTION: these 6399baa5d9SJuraj Marcin * arguments are subject to word splitting and shell evaluation. 6499baa5d9SJuraj Marcin * @capabilities: list of QMP capabilities (strings) to enable 655357ef82SSteve Sistare * @do_connect: connect to qemu monitor and qtest socket. 6699baa5d9SJuraj Marcin * 67*246069e8SVladimir Sementsov-Ogievskiy * Like qtest_init(), but use a different environment variable for the 68*246069e8SVladimir Sementsov-Ogievskiy * QEMU binary, allow specify capabilities and skip connecting 69*246069e8SVladimir Sementsov-Ogievskiy * to QEMU monitor. 7099baa5d9SJuraj Marcin * 7199baa5d9SJuraj Marcin * Returns: #QTestState instance. 7299baa5d9SJuraj Marcin */ 73*246069e8SVladimir Sementsov-Ogievskiy QTestState *qtest_init_ext(const char *var, const char *extra_args, 74*246069e8SVladimir Sementsov-Ogievskiy QList *capabilities, bool do_connect); 7599baa5d9SJuraj Marcin 7699baa5d9SJuraj Marcin /** 77f66e7ac8SMarkus Armbruster * qtest_init_without_qmp_handshake: 78ddee57e0SEric Blake * @extra_args: other arguments to pass to QEMU. CAUTION: these 79ddee57e0SEric Blake * arguments are subject to word splitting and shell evaluation. 80f66e7ac8SMarkus Armbruster * 81f66e7ac8SMarkus Armbruster * Returns: #QTestState instance. 82f66e7ac8SMarkus Armbruster */ 83192f26a7SPeter Xu QTestState *qtest_init_without_qmp_handshake(const char *extra_args); 84f66e7ac8SMarkus Armbruster 85f66e7ac8SMarkus Armbruster /** 865357ef82SSteve Sistare * qtest_connect 875357ef82SSteve Sistare * @s: #QTestState instance to connect 885357ef82SSteve Sistare * Connect to qemu monitor and qtest socket, after skipping them in 89*246069e8SVladimir Sementsov-Ogievskiy * qtest_init_ext. Does not handshake with the monitor. 905357ef82SSteve Sistare */ 915357ef82SSteve Sistare void qtest_connect(QTestState *s); 925357ef82SSteve Sistare 935357ef82SSteve Sistare /** 945357ef82SSteve Sistare * qtest_qmp_handshake: 955357ef82SSteve Sistare * @s: #QTestState instance to operate on. 965357ef82SSteve Sistare * @capabilities: list of QMP capabilities (strings) to enable 975357ef82SSteve Sistare * Perform handshake after connecting to qemu monitor. 985357ef82SSteve Sistare */ 995357ef82SSteve Sistare void qtest_qmp_handshake(QTestState *s, QList *capabilities); 1005357ef82SSteve Sistare 1015357ef82SSteve Sistare /** 1026c90a82cSJulia Suvorova * qtest_init_with_serial: 1036c90a82cSJulia Suvorova * @extra_args: other arguments to pass to QEMU. CAUTION: these 1046c90a82cSJulia Suvorova * arguments are subject to word splitting and shell evaluation. 1056c90a82cSJulia Suvorova * @sock_fd: pointer to store the socket file descriptor for 1066c90a82cSJulia Suvorova * connection with serial. 1076c90a82cSJulia Suvorova * 1086c90a82cSJulia Suvorova * Returns: #QTestState instance. 1096c90a82cSJulia Suvorova */ 1106c90a82cSJulia Suvorova QTestState *qtest_init_with_serial(const char *extra_args, int *sock_fd); 1116c90a82cSJulia Suvorova 1126c90a82cSJulia Suvorova /** 1136b76264eSPeter Maydell * qtest_system_reset: 1146b76264eSPeter Maydell * @s: #QTestState instance to operate on. 1156b76264eSPeter Maydell * 1166b76264eSPeter Maydell * Send a "system_reset" command to the QEMU under test, and wait for 1176b76264eSPeter Maydell * the reset to complete before returning. 1186b76264eSPeter Maydell */ 1196b76264eSPeter Maydell void qtest_system_reset(QTestState *s); 1206b76264eSPeter Maydell 1216b76264eSPeter Maydell /** 1226b76264eSPeter Maydell * qtest_system_reset_nowait: 1236b76264eSPeter Maydell * @s: #QTestState instance to operate on. 1246b76264eSPeter Maydell * 1256b76264eSPeter Maydell * Send a "system_reset" command to the QEMU under test, but do not 1266b76264eSPeter Maydell * wait for the reset to complete before returning. The caller is 1276b76264eSPeter Maydell * responsible for waiting for either the RESET event or some other 1286b76264eSPeter Maydell * event of interest to them before proceeding. 1296b76264eSPeter Maydell * 1306b76264eSPeter Maydell * This function should only be used if you're specifically testing 1316b76264eSPeter Maydell * for some other event; in that case you can't use qtest_system_reset() 1326b76264eSPeter Maydell * because it will read and discard any other QMP events that arrive 1336b76264eSPeter Maydell * before the RESET event. 1346b76264eSPeter Maydell */ 1356b76264eSPeter Maydell void qtest_system_reset_nowait(QTestState *s); 1366b76264eSPeter Maydell 1376b76264eSPeter Maydell /** 13869c056fbSBin Meng * qtest_wait_qemu: 13969c056fbSBin Meng * @s: #QTestState instance to operate on. 14069c056fbSBin Meng * 14169c056fbSBin Meng * Wait for the QEMU process to terminate. It is safe to call this function 14269c056fbSBin Meng * multiple times. 14369c056fbSBin Meng */ 14469c056fbSBin Meng void qtest_wait_qemu(QTestState *s); 14569c056fbSBin Meng 14669c056fbSBin Meng /** 1477a23c523SStefan Hajnoczi * qtest_kill_qemu: 1487a23c523SStefan Hajnoczi * @s: #QTestState instance to operate on. 1497a23c523SStefan Hajnoczi * 1507a23c523SStefan Hajnoczi * Kill the QEMU process and wait for it to terminate. It is safe to call this 1517a23c523SStefan Hajnoczi * function multiple times. Normally qtest_quit() is used instead because it 1527a23c523SStefan Hajnoczi * also frees QTestState. Use qtest_kill_qemu() when you just want to kill QEMU 1537a23c523SStefan Hajnoczi * and qtest_quit() will be called later. 1547a23c523SStefan Hajnoczi */ 1557a23c523SStefan Hajnoczi void qtest_kill_qemu(QTestState *s); 1567a23c523SStefan Hajnoczi 1577a23c523SStefan Hajnoczi /** 15849ee3590SAnthony Liguori * qtest_quit: 1596acf801dSAndreas Färber * @s: #QTestState instance to operate on. 16049ee3590SAnthony Liguori * 16149ee3590SAnthony Liguori * Shut down the QEMU process associated to @s. 16249ee3590SAnthony Liguori */ 16349ee3590SAnthony Liguori void qtest_quit(QTestState *s); 16449ee3590SAnthony Liguori 165490081b2SBin Meng #ifndef _WIN32 16649ee3590SAnthony Liguori /** 16724d5588cSYury Kotov * qtest_qmp_fds: 16824d5588cSYury Kotov * @s: #QTestState instance to operate on. 16924d5588cSYury Kotov * @fds: array of file descriptors 17024d5588cSYury Kotov * @fds_num: number of elements in @fds 17151c778edSEduardo Habkost * @fmt: QMP message to send to qemu, formatted like 172ad57e2b1SPeter Maydell * qobject_from_jsonf_nofail(). See parse_interpolation() for what's 17324d5588cSYury Kotov * supported after '%'. 17424d5588cSYury Kotov * 17524d5588cSYury Kotov * Sends a QMP message to QEMU with fds and returns the response. 17624d5588cSYury Kotov */ 17724d5588cSYury Kotov QDict *qtest_qmp_fds(QTestState *s, int *fds, size_t fds_num, 17824d5588cSYury Kotov const char *fmt, ...) 1799edc6313SMarc-André Lureau G_GNUC_PRINTF(4, 5); 180490081b2SBin Meng #endif /* _WIN32 */ 18124d5588cSYury Kotov 18224d5588cSYury Kotov /** 1830c460dacSStefan Hajnoczi * qtest_qmp: 1840c460dacSStefan Hajnoczi * @s: #QTestState instance to operate on. 18551c778edSEduardo Habkost * @fmt: QMP message to send to qemu, formatted like 186ad57e2b1SPeter Maydell * qobject_from_jsonf_nofail(). See parse_interpolation() for what's 1876ce80fd8SMarkus Armbruster * supported after '%'. 1880c460dacSStefan Hajnoczi * 1890c460dacSStefan Hajnoczi * Sends a QMP message to QEMU and returns the response. 1900c460dacSStefan Hajnoczi */ 191e3dc93beSMarkus Armbruster QDict *qtest_qmp(QTestState *s, const char *fmt, ...) 1929edc6313SMarc-André Lureau G_GNUC_PRINTF(2, 3); 1930c460dacSStefan Hajnoczi 1940c460dacSStefan Hajnoczi /** 1954277f1ebSMarkus Armbruster * qtest_qmp_send: 196ba4ed393SJohn Snow * @s: #QTestState instance to operate on. 19751c778edSEduardo Habkost * @fmt: QMP message to send to qemu, formatted like 198ad57e2b1SPeter Maydell * qobject_from_jsonf_nofail(). See parse_interpolation() for what's 1996ce80fd8SMarkus Armbruster * supported after '%'. 200ba4ed393SJohn Snow * 201ba4ed393SJohn Snow * Sends a QMP message to QEMU and leaves the response in the stream. 202ba4ed393SJohn Snow */ 203e3dc93beSMarkus Armbruster void qtest_qmp_send(QTestState *s, const char *fmt, ...) 2049edc6313SMarc-André Lureau G_GNUC_PRINTF(2, 3); 205ba4ed393SJohn Snow 206ba4ed393SJohn Snow /** 207aed877c5SMarkus Armbruster * qtest_qmp_send_raw: 208aed877c5SMarkus Armbruster * @s: #QTestState instance to operate on. 20951c778edSEduardo Habkost * @fmt: text to send, formatted like sprintf() 210aed877c5SMarkus Armbruster * 211aed877c5SMarkus Armbruster * Sends text to the QMP monitor verbatim. Need not be valid JSON; 212aed877c5SMarkus Armbruster * this is useful for negative tests. 213aed877c5SMarkus Armbruster */ 214aed877c5SMarkus Armbruster void qtest_qmp_send_raw(QTestState *s, const char *fmt, ...) 2159edc6313SMarc-André Lureau G_GNUC_PRINTF(2, 3); 216aed877c5SMarkus Armbruster 217aed877c5SMarkus Armbruster /** 2189fb7bb06SStefan Hajnoczi * qtest_socket_server: 2199fb7bb06SStefan Hajnoczi * @socket_path: the UNIX domain socket path 2209fb7bb06SStefan Hajnoczi * 2219fb7bb06SStefan Hajnoczi * Create and return a listen socket file descriptor, or abort on failure. 2229fb7bb06SStefan Hajnoczi */ 2239fb7bb06SStefan Hajnoczi int qtest_socket_server(const char *socket_path); 2249fb7bb06SStefan Hajnoczi 225490081b2SBin Meng #ifndef _WIN32 2269fb7bb06SStefan Hajnoczi /** 22724d5588cSYury Kotov * qtest_vqmp_fds: 22824d5588cSYury Kotov * @s: #QTestState instance to operate on. 22924d5588cSYury Kotov * @fds: array of file descriptors 23024d5588cSYury Kotov * @fds_num: number of elements in @fds 23124d5588cSYury Kotov * @fmt: QMP message to send to QEMU, formatted like 232ad57e2b1SPeter Maydell * qobject_from_jsonf_nofail(). See parse_interpolation() for what's 23324d5588cSYury Kotov * supported after '%'. 23424d5588cSYury Kotov * @ap: QMP message arguments 23524d5588cSYury Kotov * 23624d5588cSYury Kotov * Sends a QMP message to QEMU with fds and returns the response. 23724d5588cSYury Kotov */ 23824d5588cSYury Kotov QDict *qtest_vqmp_fds(QTestState *s, int *fds, size_t fds_num, 23924d5588cSYury Kotov const char *fmt, va_list ap) 2409edc6313SMarc-André Lureau G_GNUC_PRINTF(4, 0); 241490081b2SBin Meng #endif /* _WIN32 */ 24224d5588cSYury Kotov 24324d5588cSYury Kotov /** 24424d5588cSYury Kotov * qtest_vqmp: 2450c460dacSStefan Hajnoczi * @s: #QTestState instance to operate on. 246bb340eb2SEric Blake * @fmt: QMP message to send to QEMU, formatted like 247ad57e2b1SPeter Maydell * qobject_from_jsonf_nofail(). See parse_interpolation() for what's 2486ce80fd8SMarkus Armbruster * supported after '%'. 2490c460dacSStefan Hajnoczi * @ap: QMP message arguments 2500c460dacSStefan Hajnoczi * 2510c460dacSStefan Hajnoczi * Sends a QMP message to QEMU and returns the response. 2520c460dacSStefan Hajnoczi */ 253248eef02SMarkus Armbruster QDict *qtest_vqmp(QTestState *s, const char *fmt, va_list ap) 2549edc6313SMarc-André Lureau G_GNUC_PRINTF(2, 0); 2550c460dacSStefan Hajnoczi 256490081b2SBin Meng #ifndef _WIN32 2570c460dacSStefan Hajnoczi /** 25824d5588cSYury Kotov * qtest_qmp_vsend_fds: 25924d5588cSYury Kotov * @s: #QTestState instance to operate on. 26024d5588cSYury Kotov * @fds: array of file descriptors 26124d5588cSYury Kotov * @fds_num: number of elements in @fds 26224d5588cSYury Kotov * @fmt: QMP message to send to QEMU, formatted like 263ad57e2b1SPeter Maydell * qobject_from_jsonf_nofail(). See parse_interpolation() for what's 26424d5588cSYury Kotov * supported after '%'. 26524d5588cSYury Kotov * @ap: QMP message arguments 26624d5588cSYury Kotov * 26724d5588cSYury Kotov * Sends a QMP message to QEMU and leaves the response in the stream. 26824d5588cSYury Kotov */ 26924d5588cSYury Kotov void qtest_qmp_vsend_fds(QTestState *s, int *fds, size_t fds_num, 27024d5588cSYury Kotov const char *fmt, va_list ap) 2719edc6313SMarc-André Lureau G_GNUC_PRINTF(4, 0); 272490081b2SBin Meng #endif /* _WIN32 */ 27324d5588cSYury Kotov 27424d5588cSYury Kotov /** 2754277f1ebSMarkus Armbruster * qtest_qmp_vsend: 276ba4ed393SJohn Snow * @s: #QTestState instance to operate on. 277bb340eb2SEric Blake * @fmt: QMP message to send to QEMU, formatted like 278ad57e2b1SPeter Maydell * qobject_from_jsonf_nofail(). See parse_interpolation() for what's 2796ce80fd8SMarkus Armbruster * supported after '%'. 280ba4ed393SJohn Snow * @ap: QMP message arguments 281ba4ed393SJohn Snow * 282ba4ed393SJohn Snow * Sends a QMP message to QEMU and leaves the response in the stream. 283ba4ed393SJohn Snow */ 284e3dc93beSMarkus Armbruster void qtest_qmp_vsend(QTestState *s, const char *fmt, va_list ap) 2859edc6313SMarc-André Lureau G_GNUC_PRINTF(2, 0); 286ba4ed393SJohn Snow 287ba4ed393SJohn Snow /** 2881c3e2a38SMaxim Levitsky * qtest_qmp_receive_dict: 28966e0c7b1SAndreas Färber * @s: #QTestState instance to operate on. 29066e0c7b1SAndreas Färber * 29166e0c7b1SAndreas Färber * Reads a QMP message from QEMU and returns the response. 29266e0c7b1SAndreas Färber */ 2931c3e2a38SMaxim Levitsky QDict *qtest_qmp_receive_dict(QTestState *s); 29466e0c7b1SAndreas Färber 29566e0c7b1SAndreas Färber /** 296c22045bfSMaxim Levitsky * qtest_qmp_receive: 297c22045bfSMaxim Levitsky * @s: #QTestState instance to operate on. 298c22045bfSMaxim Levitsky * 299c22045bfSMaxim Levitsky * Reads a QMP message from QEMU and returns the response. 3000150e75dSDaniel P. Berrangé * 3010150e75dSDaniel P. Berrangé * If a callback is registered with qtest_qmp_set_event_callback, 3020150e75dSDaniel P. Berrangé * it will be invoked for every event seen, otherwise events 3030150e75dSDaniel P. Berrangé * will be buffered until a call to one of the qtest_qmp_eventwait 3040150e75dSDaniel P. Berrangé * family of functions. 305c22045bfSMaxim Levitsky */ 306c22045bfSMaxim Levitsky QDict *qtest_qmp_receive(QTestState *s); 307c22045bfSMaxim Levitsky 3080150e75dSDaniel P. Berrangé /* 3090150e75dSDaniel P. Berrangé * QTestQMPEventCallback: 3100150e75dSDaniel P. Berrangé * @s: #QTestState instance event was received on 3110150e75dSDaniel P. Berrangé * @name: name of the event type 3120150e75dSDaniel P. Berrangé * @event: #QDict for the event details 3130150e75dSDaniel P. Berrangé * @opaque: opaque data from time of callback registration 3140150e75dSDaniel P. Berrangé * 3150150e75dSDaniel P. Berrangé * This callback will be invoked whenever an event is received. 3160150e75dSDaniel P. Berrangé * If the callback returns true the event will be consumed, 3170150e75dSDaniel P. Berrangé * otherwise it will be put on the list of pending events. 3180150e75dSDaniel P. Berrangé * Pending events can be later handled by calling either 3190150e75dSDaniel P. Berrangé * qtest_qmp_eventwait or qtest_qmp_eventwait_ref. 3200150e75dSDaniel P. Berrangé * 3210150e75dSDaniel P. Berrangé * Return: true to consume the event, false to let it be queued 3220150e75dSDaniel P. Berrangé */ 3230150e75dSDaniel P. Berrangé typedef bool (*QTestQMPEventCallback)(QTestState *s, const char *name, 3240150e75dSDaniel P. Berrangé QDict *event, void *opaque); 3250150e75dSDaniel P. Berrangé 3260150e75dSDaniel P. Berrangé /** 3270150e75dSDaniel P. Berrangé * qtest_qmp_set_event_callback: 3280150e75dSDaniel P. Berrangé * @s: #QTestSTate instance to operate on 3290150e75dSDaniel P. Berrangé * @cb: callback to invoke for events 3300150e75dSDaniel P. Berrangé * @opaque: data to pass to @cb 3310150e75dSDaniel P. Berrangé * 3320150e75dSDaniel P. Berrangé * Register a callback to be invoked whenever an event arrives 3330150e75dSDaniel P. Berrangé */ 3340150e75dSDaniel P. Berrangé void qtest_qmp_set_event_callback(QTestState *s, 3350150e75dSDaniel P. Berrangé QTestQMPEventCallback cb, void *opaque); 3360150e75dSDaniel P. Berrangé 337c22045bfSMaxim Levitsky /** 3388fe941f7SJohn Snow * qtest_qmp_eventwait: 3398fe941f7SJohn Snow * @s: #QTestState instance to operate on. 34051c778edSEduardo Habkost * @event: event to wait for. 3418fe941f7SJohn Snow * 342e8ec0117SEric Blake * Continuously polls for QMP responses until it receives the desired event. 3430150e75dSDaniel P. Berrangé * 3440150e75dSDaniel P. Berrangé * Any callback registered with qtest_qmp_set_event_callback will 3450150e75dSDaniel P. Berrangé * be invoked for every event seen. 3468fe941f7SJohn Snow */ 3478fe941f7SJohn Snow void qtest_qmp_eventwait(QTestState *s, const char *event); 3488fe941f7SJohn Snow 3498fe941f7SJohn Snow /** 3507ffe3124SJohn Snow * qtest_qmp_eventwait_ref: 3517ffe3124SJohn Snow * @s: #QTestState instance to operate on. 35251c778edSEduardo Habkost * @event: event to wait for. 3537ffe3124SJohn Snow * 354e8ec0117SEric Blake * Continuously polls for QMP responses until it receives the desired event. 3550150e75dSDaniel P. Berrangé * 3560150e75dSDaniel P. Berrangé * Any callback registered with qtest_qmp_set_event_callback will 3570150e75dSDaniel P. Berrangé * be invoked for every event seen. 3580150e75dSDaniel P. Berrangé * 3597ffe3124SJohn Snow * Returns a copy of the event for further investigation. 3607ffe3124SJohn Snow */ 3617ffe3124SJohn Snow QDict *qtest_qmp_eventwait_ref(QTestState *s, const char *event); 3627ffe3124SJohn Snow 3637ffe3124SJohn Snow /** 364c22045bfSMaxim Levitsky * qtest_qmp_event_ref: 365c22045bfSMaxim Levitsky * @s: #QTestState instance to operate on. 366c22045bfSMaxim Levitsky * @event: event to return. 367c22045bfSMaxim Levitsky * 368c22045bfSMaxim Levitsky * Removes non-matching events from the buffer that was set by 369c22045bfSMaxim Levitsky * qtest_qmp_receive, until an event bearing the given name is found, 370c22045bfSMaxim Levitsky * and returns it. 371c22045bfSMaxim Levitsky * If no event matches, clears the buffer and returns NULL. 372c22045bfSMaxim Levitsky * 373c22045bfSMaxim Levitsky */ 374c22045bfSMaxim Levitsky QDict *qtest_qmp_event_ref(QTestState *s, const char *event); 375c22045bfSMaxim Levitsky 376c22045bfSMaxim Levitsky /** 3776bb87be8SThomas Huth * qtest_hmp: 3785fb48d96SMarkus Armbruster * @s: #QTestState instance to operate on. 37951c778edSEduardo Habkost * @fmt: HMP command to send to QEMU, formats arguments like sprintf(). 3805fb48d96SMarkus Armbruster * 3815fb48d96SMarkus Armbruster * Send HMP command to QEMU via QMP's human-monitor-command. 3826bb87be8SThomas Huth * QMP events are discarded. 3835fb48d96SMarkus Armbruster * 3845fb48d96SMarkus Armbruster * Returns: the command's output. The caller should g_free() it. 3855fb48d96SMarkus Armbruster */ 3869edc6313SMarc-André Lureau char *qtest_hmp(QTestState *s, const char *fmt, ...) G_GNUC_PRINTF(2, 3); 3875fb48d96SMarkus Armbruster 3885fb48d96SMarkus Armbruster /** 38964965b4bSAlex Bennée * qtest_vhmp: 3905fb48d96SMarkus Armbruster * @s: #QTestState instance to operate on. 391bb340eb2SEric Blake * @fmt: HMP command to send to QEMU, formats arguments like vsprintf(). 3925fb48d96SMarkus Armbruster * @ap: HMP command arguments 3935fb48d96SMarkus Armbruster * 3945fb48d96SMarkus Armbruster * Send HMP command to QEMU via QMP's human-monitor-command. 3956bb87be8SThomas Huth * QMP events are discarded. 3965fb48d96SMarkus Armbruster * 3975fb48d96SMarkus Armbruster * Returns: the command's output. The caller should g_free() it. 3985fb48d96SMarkus Armbruster */ 399248eef02SMarkus Armbruster char *qtest_vhmp(QTestState *s, const char *fmt, va_list ap) 4009edc6313SMarc-André Lureau G_GNUC_PRINTF(2, 0); 4015fb48d96SMarkus Armbruster 402eb062cfaSMarc-André Lureau void qtest_module_load(QTestState *s, const char *prefix, const char *libname); 403eb062cfaSMarc-André Lureau 4045fb48d96SMarkus Armbruster /** 40549ee3590SAnthony Liguori * qtest_get_irq: 4066acf801dSAndreas Färber * @s: #QTestState instance to operate on. 40749ee3590SAnthony Liguori * @num: Interrupt to observe. 40849ee3590SAnthony Liguori * 4096acf801dSAndreas Färber * Returns: The level of the @num interrupt. 41049ee3590SAnthony Liguori */ 41149ee3590SAnthony Liguori bool qtest_get_irq(QTestState *s, int num); 41249ee3590SAnthony Liguori 41349ee3590SAnthony Liguori /** 41449ee3590SAnthony Liguori * qtest_irq_intercept_in: 4156acf801dSAndreas Färber * @s: #QTestState instance to operate on. 41649ee3590SAnthony Liguori * @string: QOM path of a device. 41749ee3590SAnthony Liguori * 41849ee3590SAnthony Liguori * Associate qtest irqs with the GPIO-in pins of the device 41949ee3590SAnthony Liguori * whose path is specified by @string. 42049ee3590SAnthony Liguori */ 42149ee3590SAnthony Liguori void qtest_irq_intercept_in(QTestState *s, const char *string); 42249ee3590SAnthony Liguori 42349ee3590SAnthony Liguori /** 42449ee3590SAnthony Liguori * qtest_irq_intercept_out: 4256acf801dSAndreas Färber * @s: #QTestState instance to operate on. 42649ee3590SAnthony Liguori * @string: QOM path of a device. 42749ee3590SAnthony Liguori * 42849ee3590SAnthony Liguori * Associate qtest irqs with the GPIO-out pins of the device 42949ee3590SAnthony Liguori * whose path is specified by @string. 43049ee3590SAnthony Liguori */ 43149ee3590SAnthony Liguori void qtest_irq_intercept_out(QTestState *s, const char *string); 43249ee3590SAnthony Liguori 43349ee3590SAnthony Liguori /** 434a8610f8bSChris Laplante * qtest_irq_intercept_out_named: 435a8610f8bSChris Laplante * @s: #QTestState instance to operate on. 436a8610f8bSChris Laplante * @qom_path: QOM path of a device. 437a8610f8bSChris Laplante * @name: Name of the GPIO out pin 438a8610f8bSChris Laplante * 439a8610f8bSChris Laplante * Associate a qtest irq with the named GPIO-out pin of the device 440a8610f8bSChris Laplante * whose path is specified by @string and whose name is @name. 441a8610f8bSChris Laplante */ 442a8610f8bSChris Laplante void qtest_irq_intercept_out_named(QTestState *s, const char *qom_path, const char *name); 443a8610f8bSChris Laplante 444a8610f8bSChris Laplante /** 4459813dc6aSSteffen Görtz * qtest_set_irq_in: 4469813dc6aSSteffen Görtz * @s: QTestState instance to operate on. 4479813dc6aSSteffen Görtz * @string: QOM path of a device 4489813dc6aSSteffen Görtz * @name: IRQ name 4499813dc6aSSteffen Görtz * @irq: IRQ number 4509813dc6aSSteffen Görtz * @level: IRQ level 4519813dc6aSSteffen Görtz * 4529813dc6aSSteffen Görtz * Force given device/irq GPIO-in pin to the given level. 4539813dc6aSSteffen Görtz */ 4549813dc6aSSteffen Görtz void qtest_set_irq_in(QTestState *s, const char *string, const char *name, 4559813dc6aSSteffen Görtz int irq, int level); 4569813dc6aSSteffen Görtz 4579813dc6aSSteffen Görtz /** 45849ee3590SAnthony Liguori * qtest_outb: 4596acf801dSAndreas Färber * @s: #QTestState instance to operate on. 46049ee3590SAnthony Liguori * @addr: I/O port to write to. 46149ee3590SAnthony Liguori * @value: Value being written. 46249ee3590SAnthony Liguori * 46349ee3590SAnthony Liguori * Write an 8-bit value to an I/O port. 46449ee3590SAnthony Liguori */ 46549ee3590SAnthony Liguori void qtest_outb(QTestState *s, uint16_t addr, uint8_t value); 46649ee3590SAnthony Liguori 46749ee3590SAnthony Liguori /** 46849ee3590SAnthony Liguori * qtest_outw: 4696acf801dSAndreas Färber * @s: #QTestState instance to operate on. 47049ee3590SAnthony Liguori * @addr: I/O port to write to. 47149ee3590SAnthony Liguori * @value: Value being written. 47249ee3590SAnthony Liguori * 47349ee3590SAnthony Liguori * Write a 16-bit value to an I/O port. 47449ee3590SAnthony Liguori */ 47549ee3590SAnthony Liguori void qtest_outw(QTestState *s, uint16_t addr, uint16_t value); 47649ee3590SAnthony Liguori 47749ee3590SAnthony Liguori /** 47849ee3590SAnthony Liguori * qtest_outl: 4796acf801dSAndreas Färber * @s: #QTestState instance to operate on. 48049ee3590SAnthony Liguori * @addr: I/O port to write to. 48149ee3590SAnthony Liguori * @value: Value being written. 48249ee3590SAnthony Liguori * 48349ee3590SAnthony Liguori * Write a 32-bit value to an I/O port. 48449ee3590SAnthony Liguori */ 48549ee3590SAnthony Liguori void qtest_outl(QTestState *s, uint16_t addr, uint32_t value); 48649ee3590SAnthony Liguori 48749ee3590SAnthony Liguori /** 48849ee3590SAnthony Liguori * qtest_inb: 4896acf801dSAndreas Färber * @s: #QTestState instance to operate on. 49049ee3590SAnthony Liguori * @addr: I/O port to read from. 49149ee3590SAnthony Liguori * 49249ee3590SAnthony Liguori * Returns an 8-bit value from an I/O port. 49349ee3590SAnthony Liguori */ 49449ee3590SAnthony Liguori uint8_t qtest_inb(QTestState *s, uint16_t addr); 49549ee3590SAnthony Liguori 49649ee3590SAnthony Liguori /** 49749ee3590SAnthony Liguori * qtest_inw: 4986acf801dSAndreas Färber * @s: #QTestState instance to operate on. 49949ee3590SAnthony Liguori * @addr: I/O port to read from. 50049ee3590SAnthony Liguori * 50149ee3590SAnthony Liguori * Returns a 16-bit value from an I/O port. 50249ee3590SAnthony Liguori */ 50349ee3590SAnthony Liguori uint16_t qtest_inw(QTestState *s, uint16_t addr); 50449ee3590SAnthony Liguori 50549ee3590SAnthony Liguori /** 50649ee3590SAnthony Liguori * qtest_inl: 5076acf801dSAndreas Färber * @s: #QTestState instance to operate on. 50849ee3590SAnthony Liguori * @addr: I/O port to read from. 50949ee3590SAnthony Liguori * 51049ee3590SAnthony Liguori * Returns a 32-bit value from an I/O port. 51149ee3590SAnthony Liguori */ 51249ee3590SAnthony Liguori uint32_t qtest_inl(QTestState *s, uint16_t addr); 51349ee3590SAnthony Liguori 51449ee3590SAnthony Liguori /** 515872536bfSAndreas Färber * qtest_writeb: 516872536bfSAndreas Färber * @s: #QTestState instance to operate on. 517872536bfSAndreas Färber * @addr: Guest address to write to. 518872536bfSAndreas Färber * @value: Value being written. 519872536bfSAndreas Färber * 520872536bfSAndreas Färber * Writes an 8-bit value to memory. 521872536bfSAndreas Färber */ 522872536bfSAndreas Färber void qtest_writeb(QTestState *s, uint64_t addr, uint8_t value); 523872536bfSAndreas Färber 524872536bfSAndreas Färber /** 525872536bfSAndreas Färber * qtest_writew: 526872536bfSAndreas Färber * @s: #QTestState instance to operate on. 527872536bfSAndreas Färber * @addr: Guest address to write to. 528872536bfSAndreas Färber * @value: Value being written. 529872536bfSAndreas Färber * 530872536bfSAndreas Färber * Writes a 16-bit value to memory. 531872536bfSAndreas Färber */ 532872536bfSAndreas Färber void qtest_writew(QTestState *s, uint64_t addr, uint16_t value); 533872536bfSAndreas Färber 534872536bfSAndreas Färber /** 535872536bfSAndreas Färber * qtest_writel: 536872536bfSAndreas Färber * @s: #QTestState instance to operate on. 537872536bfSAndreas Färber * @addr: Guest address to write to. 538872536bfSAndreas Färber * @value: Value being written. 539872536bfSAndreas Färber * 540872536bfSAndreas Färber * Writes a 32-bit value to memory. 541872536bfSAndreas Färber */ 542872536bfSAndreas Färber void qtest_writel(QTestState *s, uint64_t addr, uint32_t value); 543872536bfSAndreas Färber 544872536bfSAndreas Färber /** 545872536bfSAndreas Färber * qtest_writeq: 546872536bfSAndreas Färber * @s: #QTestState instance to operate on. 547872536bfSAndreas Färber * @addr: Guest address to write to. 548872536bfSAndreas Färber * @value: Value being written. 549872536bfSAndreas Färber * 550872536bfSAndreas Färber * Writes a 64-bit value to memory. 551872536bfSAndreas Färber */ 552872536bfSAndreas Färber void qtest_writeq(QTestState *s, uint64_t addr, uint64_t value); 553872536bfSAndreas Färber 554872536bfSAndreas Färber /** 555872536bfSAndreas Färber * qtest_readb: 556872536bfSAndreas Färber * @s: #QTestState instance to operate on. 557872536bfSAndreas Färber * @addr: Guest address to read from. 558872536bfSAndreas Färber * 559872536bfSAndreas Färber * Reads an 8-bit value from memory. 560872536bfSAndreas Färber * 561872536bfSAndreas Färber * Returns: Value read. 562872536bfSAndreas Färber */ 563872536bfSAndreas Färber uint8_t qtest_readb(QTestState *s, uint64_t addr); 564872536bfSAndreas Färber 565872536bfSAndreas Färber /** 566872536bfSAndreas Färber * qtest_readw: 567872536bfSAndreas Färber * @s: #QTestState instance to operate on. 568872536bfSAndreas Färber * @addr: Guest address to read from. 569872536bfSAndreas Färber * 570872536bfSAndreas Färber * Reads a 16-bit value from memory. 571872536bfSAndreas Färber * 572872536bfSAndreas Färber * Returns: Value read. 573872536bfSAndreas Färber */ 574872536bfSAndreas Färber uint16_t qtest_readw(QTestState *s, uint64_t addr); 575872536bfSAndreas Färber 576872536bfSAndreas Färber /** 577872536bfSAndreas Färber * qtest_readl: 578872536bfSAndreas Färber * @s: #QTestState instance to operate on. 579872536bfSAndreas Färber * @addr: Guest address to read from. 580872536bfSAndreas Färber * 581872536bfSAndreas Färber * Reads a 32-bit value from memory. 582872536bfSAndreas Färber * 583872536bfSAndreas Färber * Returns: Value read. 584872536bfSAndreas Färber */ 585872536bfSAndreas Färber uint32_t qtest_readl(QTestState *s, uint64_t addr); 586872536bfSAndreas Färber 587872536bfSAndreas Färber /** 588872536bfSAndreas Färber * qtest_readq: 589872536bfSAndreas Färber * @s: #QTestState instance to operate on. 590872536bfSAndreas Färber * @addr: Guest address to read from. 591872536bfSAndreas Färber * 592872536bfSAndreas Färber * Reads a 64-bit value from memory. 593872536bfSAndreas Färber * 594872536bfSAndreas Färber * Returns: Value read. 595872536bfSAndreas Färber */ 596872536bfSAndreas Färber uint64_t qtest_readq(QTestState *s, uint64_t addr); 597872536bfSAndreas Färber 598872536bfSAndreas Färber /** 59949ee3590SAnthony Liguori * qtest_memread: 6006acf801dSAndreas Färber * @s: #QTestState instance to operate on. 60149ee3590SAnthony Liguori * @addr: Guest address to read from. 60249ee3590SAnthony Liguori * @data: Pointer to where memory contents will be stored. 60349ee3590SAnthony Liguori * @size: Number of bytes to read. 60449ee3590SAnthony Liguori * 60549ee3590SAnthony Liguori * Read guest memory into a buffer. 60649ee3590SAnthony Liguori */ 60749ee3590SAnthony Liguori void qtest_memread(QTestState *s, uint64_t addr, void *data, size_t size); 60849ee3590SAnthony Liguori 60949ee3590SAnthony Liguori /** 610eeddd59fSLaurent Vivier * qtest_rtas_call: 611eeddd59fSLaurent Vivier * @s: #QTestState instance to operate on. 612eeddd59fSLaurent Vivier * @name: name of the command to call. 613eeddd59fSLaurent Vivier * @nargs: Number of args. 614eeddd59fSLaurent Vivier * @args: Guest address to read args from. 615eeddd59fSLaurent Vivier * @nret: Number of return value. 616eeddd59fSLaurent Vivier * @ret: Guest address to write return values to. 617eeddd59fSLaurent Vivier * 618eeddd59fSLaurent Vivier * Call an RTAS function 619eeddd59fSLaurent Vivier */ 620eeddd59fSLaurent Vivier uint64_t qtest_rtas_call(QTestState *s, const char *name, 621eeddd59fSLaurent Vivier uint32_t nargs, uint64_t args, 622eeddd59fSLaurent Vivier uint32_t nret, uint64_t ret); 623eeddd59fSLaurent Vivier 624eeddd59fSLaurent Vivier /** 6251addf571SIvan Klokov * qtest_csr_call: 6261addf571SIvan Klokov * @s: #QTestState instance to operate on. 6271addf571SIvan Klokov * @name: name of the command to call. 6281addf571SIvan Klokov * @cpu: hart number. 6291addf571SIvan Klokov * @csr: CSR number. 6301addf571SIvan Klokov * @val: Value for reading/writing. 6311addf571SIvan Klokov * 6321addf571SIvan Klokov * Call an RISC-V CSR read/write function 6331addf571SIvan Klokov */ 6341addf571SIvan Klokov uint64_t qtest_csr_call(QTestState *s, const char *name, 6351addf571SIvan Klokov uint64_t cpu, int csr, 6361addf571SIvan Klokov uint64_t *val); 6371addf571SIvan Klokov 6381addf571SIvan Klokov /** 6397a6a740dSJohn Snow * qtest_bufread: 6407a6a740dSJohn Snow * @s: #QTestState instance to operate on. 6417a6a740dSJohn Snow * @addr: Guest address to read from. 6427a6a740dSJohn Snow * @data: Pointer to where memory contents will be stored. 6437a6a740dSJohn Snow * @size: Number of bytes to read. 6447a6a740dSJohn Snow * 6457a6a740dSJohn Snow * Read guest memory into a buffer and receive using a base64 encoding. 6467a6a740dSJohn Snow */ 6477a6a740dSJohn Snow void qtest_bufread(QTestState *s, uint64_t addr, void *data, size_t size); 6487a6a740dSJohn Snow 6497a6a740dSJohn Snow /** 65049ee3590SAnthony Liguori * qtest_memwrite: 6516acf801dSAndreas Färber * @s: #QTestState instance to operate on. 65249ee3590SAnthony Liguori * @addr: Guest address to write to. 65349ee3590SAnthony Liguori * @data: Pointer to the bytes that will be written to guest memory. 65449ee3590SAnthony Liguori * @size: Number of bytes to write. 65549ee3590SAnthony Liguori * 65649ee3590SAnthony Liguori * Write a buffer to guest memory. 65749ee3590SAnthony Liguori */ 65849ee3590SAnthony Liguori void qtest_memwrite(QTestState *s, uint64_t addr, const void *data, size_t size); 65949ee3590SAnthony Liguori 66049ee3590SAnthony Liguori /** 6617a6a740dSJohn Snow * qtest_bufwrite: 6627a6a740dSJohn Snow * @s: #QTestState instance to operate on. 6637a6a740dSJohn Snow * @addr: Guest address to write to. 6647a6a740dSJohn Snow * @data: Pointer to the bytes that will be written to guest memory. 6657a6a740dSJohn Snow * @size: Number of bytes to write. 6667a6a740dSJohn Snow * 6677a6a740dSJohn Snow * Write a buffer to guest memory and transmit using a base64 encoding. 6687a6a740dSJohn Snow */ 6697a6a740dSJohn Snow void qtest_bufwrite(QTestState *s, uint64_t addr, 6707a6a740dSJohn Snow const void *data, size_t size); 6717a6a740dSJohn Snow 6727a6a740dSJohn Snow /** 67386298845SJohn Snow * qtest_memset: 67486298845SJohn Snow * @s: #QTestState instance to operate on. 67586298845SJohn Snow * @addr: Guest address to write to. 67686298845SJohn Snow * @patt: Byte pattern to fill the guest memory region with. 67786298845SJohn Snow * @size: Number of bytes to write. 67886298845SJohn Snow * 67986298845SJohn Snow * Write a pattern to guest memory. 68086298845SJohn Snow */ 68186298845SJohn Snow void qtest_memset(QTestState *s, uint64_t addr, uint8_t patt, size_t size); 68286298845SJohn Snow 68386298845SJohn Snow /** 68449ee3590SAnthony Liguori * qtest_clock_step_next: 6856acf801dSAndreas Färber * @s: #QTestState instance to operate on. 68649ee3590SAnthony Liguori * 687bc72ad67SAlex Bligh * Advance the QEMU_CLOCK_VIRTUAL to the next deadline. 6886acf801dSAndreas Färber * 689bc72ad67SAlex Bligh * Returns: The current value of the QEMU_CLOCK_VIRTUAL in nanoseconds. 69049ee3590SAnthony Liguori */ 69149ee3590SAnthony Liguori int64_t qtest_clock_step_next(QTestState *s); 69249ee3590SAnthony Liguori 69349ee3590SAnthony Liguori /** 69449ee3590SAnthony Liguori * qtest_clock_step: 69549ee3590SAnthony Liguori * @s: QTestState instance to operate on. 69649ee3590SAnthony Liguori * @step: Number of nanoseconds to advance the clock by. 69749ee3590SAnthony Liguori * 698bc72ad67SAlex Bligh * Advance the QEMU_CLOCK_VIRTUAL by @step nanoseconds. 6996acf801dSAndreas Färber * 700bc72ad67SAlex Bligh * Returns: The current value of the QEMU_CLOCK_VIRTUAL in nanoseconds. 70149ee3590SAnthony Liguori */ 70249ee3590SAnthony Liguori int64_t qtest_clock_step(QTestState *s, int64_t step); 70349ee3590SAnthony Liguori 70449ee3590SAnthony Liguori /** 70549ee3590SAnthony Liguori * qtest_clock_set: 70649ee3590SAnthony Liguori * @s: QTestState instance to operate on. 70749ee3590SAnthony Liguori * @val: Nanoseconds value to advance the clock to. 70849ee3590SAnthony Liguori * 709bc72ad67SAlex Bligh * Advance the QEMU_CLOCK_VIRTUAL to @val nanoseconds since the VM was launched. 7106acf801dSAndreas Färber * 711bc72ad67SAlex Bligh * Returns: The current value of the QEMU_CLOCK_VIRTUAL in nanoseconds. 71249ee3590SAnthony Liguori */ 71349ee3590SAnthony Liguori int64_t qtest_clock_set(QTestState *s, int64_t val); 71449ee3590SAnthony Liguori 71549ee3590SAnthony Liguori /** 71654ce6f22SLaurent Vivier * qtest_big_endian: 71754ce6f22SLaurent Vivier * @s: QTestState instance to operate on. 71854ce6f22SLaurent Vivier * 71954ce6f22SLaurent Vivier * Returns: True if the architecture under test has a big endian configuration. 72054ce6f22SLaurent Vivier */ 72154ce6f22SLaurent Vivier bool qtest_big_endian(QTestState *s); 72254ce6f22SLaurent Vivier 72354ce6f22SLaurent Vivier /** 72449ee3590SAnthony Liguori * qtest_get_arch: 72549ee3590SAnthony Liguori * 7266acf801dSAndreas Färber * Returns: The architecture for the QEMU executable under test. 72749ee3590SAnthony Liguori */ 72849ee3590SAnthony Liguori const char *qtest_get_arch(void); 72949ee3590SAnthony Liguori 73049ee3590SAnthony Liguori /** 731e741aff0SIgor Mammedov * qtest_has_accel: 732e741aff0SIgor Mammedov * @accel_name: Accelerator name to check for. 733e741aff0SIgor Mammedov * 734e741aff0SIgor Mammedov * Returns: true if the accelerator is built in. 735e741aff0SIgor Mammedov */ 736e741aff0SIgor Mammedov bool qtest_has_accel(const char *accel_name); 737e741aff0SIgor Mammedov 738e741aff0SIgor Mammedov /** 73949ee3590SAnthony Liguori * qtest_add_func: 74049ee3590SAnthony Liguori * @str: Test case path. 74149ee3590SAnthony Liguori * @fn: Test case function 74249ee3590SAnthony Liguori * 74349ee3590SAnthony Liguori * Add a GTester testcase with the given name and function. 74449ee3590SAnthony Liguori * The path is prefixed with the architecture under test, as 7456acf801dSAndreas Färber * returned by qtest_get_arch(). 74649ee3590SAnthony Liguori */ 747041088c7SMarkus Armbruster void qtest_add_func(const char *str, void (*fn)(void)); 74849ee3590SAnthony Liguori 74949ee3590SAnthony Liguori /** 7507949c0e3SAndreas Färber * qtest_add_data_func: 7517949c0e3SAndreas Färber * @str: Test case path. 7527949c0e3SAndreas Färber * @data: Test case data 7537949c0e3SAndreas Färber * @fn: Test case function 7547949c0e3SAndreas Färber * 7557949c0e3SAndreas Färber * Add a GTester testcase with the given name, data and function. 7567949c0e3SAndreas Färber * The path is prefixed with the architecture under test, as 7577949c0e3SAndreas Färber * returned by qtest_get_arch(). 7587949c0e3SAndreas Färber */ 759041088c7SMarkus Armbruster void qtest_add_data_func(const char *str, const void *data, 760041088c7SMarkus Armbruster void (*fn)(const void *)); 7617949c0e3SAndreas Färber 7627949c0e3SAndreas Färber /** 763822e36caSMarc-André Lureau * qtest_add_data_func_full: 764822e36caSMarc-André Lureau * @str: Test case path. 765822e36caSMarc-André Lureau * @data: Test case data 766822e36caSMarc-André Lureau * @fn: Test case function 767822e36caSMarc-André Lureau * @data_free_func: GDestroyNotify for data 768822e36caSMarc-André Lureau * 769822e36caSMarc-André Lureau * Add a GTester testcase with the given name, data and function. 770822e36caSMarc-André Lureau * The path is prefixed with the architecture under test, as 771822e36caSMarc-André Lureau * returned by qtest_get_arch(). 772822e36caSMarc-André Lureau * 773822e36caSMarc-André Lureau * @data is passed to @data_free_func() on test completion. 774822e36caSMarc-André Lureau */ 775822e36caSMarc-André Lureau void qtest_add_data_func_full(const char *str, void *data, 776822e36caSMarc-André Lureau void (*fn)(const void *), 777822e36caSMarc-André Lureau GDestroyNotify data_free_func); 778822e36caSMarc-André Lureau 779822e36caSMarc-André Lureau /** 78045b0f830SAndreas Färber * qtest_add: 78145b0f830SAndreas Färber * @testpath: Test case path 78245b0f830SAndreas Färber * @Fixture: Fixture type 78345b0f830SAndreas Färber * @tdata: Test case data 78445b0f830SAndreas Färber * @fsetup: Test case setup function 78545b0f830SAndreas Färber * @ftest: Test case function 78645b0f830SAndreas Färber * @fteardown: Test case teardown function 78745b0f830SAndreas Färber * 78845b0f830SAndreas Färber * Add a GTester testcase with the given name, data and functions. 78945b0f830SAndreas Färber * The path is prefixed with the architecture under test, as 79045b0f830SAndreas Färber * returned by qtest_get_arch(). 79145b0f830SAndreas Färber */ 79245b0f830SAndreas Färber #define qtest_add(testpath, Fixture, tdata, fsetup, ftest, fteardown) \ 79345b0f830SAndreas Färber do { \ 79445b0f830SAndreas Färber char *path = g_strdup_printf("/%s/%s", qtest_get_arch(), testpath); \ 79545b0f830SAndreas Färber g_test_add(path, Fixture, tdata, fsetup, ftest, fteardown); \ 79645b0f830SAndreas Färber g_free(path); \ 79745b0f830SAndreas Färber } while (0) 79845b0f830SAndreas Färber 799e1fa7f55SStefan Hajnoczi /** 800e1fa7f55SStefan Hajnoczi * qtest_add_abrt_handler: 801e1fa7f55SStefan Hajnoczi * @fn: Handler function 802e1fa7f55SStefan Hajnoczi * @data: Argument that is passed to the handler 803e1fa7f55SStefan Hajnoczi * 804e1fa7f55SStefan Hajnoczi * Add a handler function that is invoked on SIGABRT. This can be used to 805e1fa7f55SStefan Hajnoczi * terminate processes and perform other cleanup. The handler can be removed 806e1fa7f55SStefan Hajnoczi * with qtest_remove_abrt_handler(). 807e1fa7f55SStefan Hajnoczi */ 808041088c7SMarkus Armbruster void qtest_add_abrt_handler(GHookFunc fn, const void *data); 809063c23d9SMarc-André Lureau 81045b0f830SAndreas Färber /** 811e1fa7f55SStefan Hajnoczi * qtest_remove_abrt_handler: 812e1fa7f55SStefan Hajnoczi * @data: Argument previously passed to qtest_add_abrt_handler() 813e1fa7f55SStefan Hajnoczi * 814e1fa7f55SStefan Hajnoczi * Remove an abrt handler that was previously added with 815e1fa7f55SStefan Hajnoczi * qtest_add_abrt_handler(). 816e1fa7f55SStefan Hajnoczi */ 817e1fa7f55SStefan Hajnoczi void qtest_remove_abrt_handler(void *data); 818e1fa7f55SStefan Hajnoczi 819e1fa7f55SStefan Hajnoczi /** 82028760edcSDaniel P. Berrangé * qtest_vqmp_assert_success_ref: 82128760edcSDaniel P. Berrangé * @qts: QTestState instance to operate on 82228760edcSDaniel P. Berrangé * @fmt: QMP message to send to qemu, formatted like 82328760edcSDaniel P. Berrangé * qobject_from_jsonf_nofail(). See parse_interpolation() for what's 82428760edcSDaniel P. Berrangé * supported after '%'. 82528760edcSDaniel P. Berrangé * @args: variable arguments for @fmt 82628760edcSDaniel P. Berrangé * 82728760edcSDaniel P. Berrangé * Sends a QMP message to QEMU, asserts that a 'return' key is present in 82828760edcSDaniel P. Berrangé * the response, and returns the response. 82928760edcSDaniel P. Berrangé */ 83028760edcSDaniel P. Berrangé QDict *qtest_vqmp_assert_success_ref(QTestState *qts, 83128760edcSDaniel P. Berrangé const char *fmt, va_list args) 83228760edcSDaniel P. Berrangé G_GNUC_PRINTF(2, 0); 83328760edcSDaniel P. Berrangé 83428760edcSDaniel P. Berrangé /** 83528760edcSDaniel P. Berrangé * qtest_vqmp_assert_success: 83628760edcSDaniel P. Berrangé * @qts: QTestState instance to operate on 83728760edcSDaniel P. Berrangé * @fmt: QMP message to send to qemu, formatted like 83828760edcSDaniel P. Berrangé * qobject_from_jsonf_nofail(). See parse_interpolation() for what's 83928760edcSDaniel P. Berrangé * supported after '%'. 84028760edcSDaniel P. Berrangé * @args: variable arguments for @fmt 84128760edcSDaniel P. Berrangé * 84228760edcSDaniel P. Berrangé * Sends a QMP message to QEMU and asserts that a 'return' key is present in 84328760edcSDaniel P. Berrangé * the response. 84428760edcSDaniel P. Berrangé */ 84528760edcSDaniel P. Berrangé void qtest_vqmp_assert_success(QTestState *qts, 84628760edcSDaniel P. Berrangé const char *fmt, va_list args) 84728760edcSDaniel P. Berrangé G_GNUC_PRINTF(2, 0); 84828760edcSDaniel P. Berrangé 84928760edcSDaniel P. Berrangé #ifndef _WIN32 85028760edcSDaniel P. Berrangé /** 85128760edcSDaniel P. Berrangé * qtest_vqmp_fds_assert_success_ref: 85228760edcSDaniel P. Berrangé * @qts: QTestState instance to operate on 85328760edcSDaniel P. Berrangé * @fds: the file descriptors to send 85428760edcSDaniel P. Berrangé * @nfds: number of @fds to send 85528760edcSDaniel P. Berrangé * @fmt: QMP message to send to qemu, formatted like 85628760edcSDaniel P. Berrangé * qobject_from_jsonf_nofail(). See parse_interpolation() for what's 85728760edcSDaniel P. Berrangé * supported after '%'. 85828760edcSDaniel P. Berrangé * @args: variable arguments for @fmt 85928760edcSDaniel P. Berrangé * 86028760edcSDaniel P. Berrangé * Sends a QMP message with file descriptors to QEMU, 86128760edcSDaniel P. Berrangé * asserts that a 'return' key is present in the response, 86228760edcSDaniel P. Berrangé * and returns the response. 86328760edcSDaniel P. Berrangé */ 86428760edcSDaniel P. Berrangé QDict *qtest_vqmp_fds_assert_success_ref(QTestState *qts, int *fds, size_t nfds, 86528760edcSDaniel P. Berrangé const char *fmt, va_list args) 86628760edcSDaniel P. Berrangé G_GNUC_PRINTF(4, 0); 86728760edcSDaniel P. Berrangé 86828760edcSDaniel P. Berrangé /** 86928760edcSDaniel P. Berrangé * qtest_vqmp_fds_assert_success: 87028760edcSDaniel P. Berrangé * @qts: QTestState instance to operate on 87128760edcSDaniel P. Berrangé * @fds: the file descriptors to send 87228760edcSDaniel P. Berrangé * @nfds: number of @fds to send 87328760edcSDaniel P. Berrangé * @fmt: QMP message to send to qemu, formatted like 87428760edcSDaniel P. Berrangé * qobject_from_jsonf_nofail(). See parse_interpolation() for what's 87528760edcSDaniel P. Berrangé * supported after '%'. 87628760edcSDaniel P. Berrangé * @args: variable arguments for @fmt 87728760edcSDaniel P. Berrangé * 87828760edcSDaniel P. Berrangé * Sends a QMP message with file descriptors to QEMU and 87928760edcSDaniel P. Berrangé * asserts that a 'return' key is present in the response. 88028760edcSDaniel P. Berrangé */ 88128760edcSDaniel P. Berrangé void qtest_vqmp_fds_assert_success(QTestState *qts, int *fds, size_t nfds, 88228760edcSDaniel P. Berrangé const char *fmt, va_list args) 88328760edcSDaniel P. Berrangé G_GNUC_PRINTF(4, 0); 88428760edcSDaniel P. Berrangé #endif /* !_WIN32 */ 88528760edcSDaniel P. Berrangé 88628760edcSDaniel P. Berrangé /** 8875274274cSFabiano Rosas * qtest_qmp_assert_failure_ref: 8885274274cSFabiano Rosas * @qts: QTestState instance to operate on 8895274274cSFabiano Rosas * @fmt: QMP message to send to qemu, formatted like 8905274274cSFabiano Rosas * qobject_from_jsonf_nofail(). See parse_interpolation() for what's 8915274274cSFabiano Rosas * supported after '%'. 8925274274cSFabiano Rosas * 8935274274cSFabiano Rosas * Sends a QMP message to QEMU, asserts that an 'error' key is present in 8945274274cSFabiano Rosas * the response, and returns the response. 8955274274cSFabiano Rosas */ 8965274274cSFabiano Rosas QDict *qtest_qmp_assert_failure_ref(QTestState *qts, const char *fmt, ...) 8975274274cSFabiano Rosas G_GNUC_PRINTF(2, 3); 8985274274cSFabiano Rosas 8995274274cSFabiano Rosas /** 9005274274cSFabiano Rosas * qtest_vqmp_assert_failure_ref: 9015274274cSFabiano Rosas * @qts: QTestState instance to operate on 9025274274cSFabiano Rosas * @fmt: QMP message to send to qemu, formatted like 9035274274cSFabiano Rosas * qobject_from_jsonf_nofail(). See parse_interpolation() for what's 9045274274cSFabiano Rosas * supported after '%'. 9055274274cSFabiano Rosas * @args: variable arguments for @fmt 9065274274cSFabiano Rosas * 9075274274cSFabiano Rosas * Sends a QMP message to QEMU, asserts that an 'error' key is present in 9085274274cSFabiano Rosas * the response, and returns the response. 9095274274cSFabiano Rosas */ 9105274274cSFabiano Rosas QDict *qtest_vqmp_assert_failure_ref(QTestState *qts, 9115274274cSFabiano Rosas const char *fmt, va_list args) 9125274274cSFabiano Rosas G_GNUC_PRINTF(2, 0); 9135274274cSFabiano Rosas 9145274274cSFabiano Rosas /** 91528760edcSDaniel P. Berrangé * qtest_qmp_assert_success_ref: 91628760edcSDaniel P. Berrangé * @qts: QTestState instance to operate on 91728760edcSDaniel P. Berrangé * @fmt: QMP message to send to qemu, formatted like 91828760edcSDaniel P. Berrangé * qobject_from_jsonf_nofail(). See parse_interpolation() for what's 91928760edcSDaniel P. Berrangé * supported after '%'. 92028760edcSDaniel P. Berrangé * 92128760edcSDaniel P. Berrangé * Sends a QMP message to QEMU, asserts that a 'return' key is present in 92228760edcSDaniel P. Berrangé * the response, and returns the response. 92328760edcSDaniel P. Berrangé */ 92428760edcSDaniel P. Berrangé QDict *qtest_qmp_assert_success_ref(QTestState *qts, const char *fmt, ...) 92528760edcSDaniel P. Berrangé G_GNUC_PRINTF(2, 3); 92628760edcSDaniel P. Berrangé 92728760edcSDaniel P. Berrangé /** 9286fc9f3d3SThomas Huth * qtest_qmp_assert_success: 9296fc9f3d3SThomas Huth * @qts: QTestState instance to operate on 93051c778edSEduardo Habkost * @fmt: QMP message to send to qemu, formatted like 931ad57e2b1SPeter Maydell * qobject_from_jsonf_nofail(). See parse_interpolation() for what's 932edbe36adSKevin Wolf * supported after '%'. 933edbe36adSKevin Wolf * 934edbe36adSKevin Wolf * Sends a QMP message to QEMU and asserts that a 'return' key is present in 935edbe36adSKevin Wolf * the response. 936edbe36adSKevin Wolf */ 9376fc9f3d3SThomas Huth void qtest_qmp_assert_success(QTestState *qts, const char *fmt, ...) 9389edc6313SMarc-André Lureau G_GNUC_PRINTF(2, 3); 939edbe36adSKevin Wolf 94028760edcSDaniel P. Berrangé #ifndef _WIN32 94128760edcSDaniel P. Berrangé /** 94264965b4bSAlex Bennée * qtest_qmp_fds_assert_success_ref: 94328760edcSDaniel P. Berrangé * @qts: QTestState instance to operate on 94428760edcSDaniel P. Berrangé * @fds: the file descriptors to send 94528760edcSDaniel P. Berrangé * @nfds: number of @fds to send 94628760edcSDaniel P. Berrangé * @fmt: QMP message to send to qemu, formatted like 94728760edcSDaniel P. Berrangé * qobject_from_jsonf_nofail(). See parse_interpolation() for what's 94828760edcSDaniel P. Berrangé * supported after '%'. 94928760edcSDaniel P. Berrangé * 95028760edcSDaniel P. Berrangé * Sends a QMP message with file descriptors to QEMU, 95128760edcSDaniel P. Berrangé * asserts that a 'return' key is present in the response, 95228760edcSDaniel P. Berrangé * and returns the response. 95328760edcSDaniel P. Berrangé */ 95428760edcSDaniel P. Berrangé QDict *qtest_qmp_fds_assert_success_ref(QTestState *qts, int *fds, size_t nfds, 95528760edcSDaniel P. Berrangé const char *fmt, ...) 95628760edcSDaniel P. Berrangé G_GNUC_PRINTF(4, 5); 95728760edcSDaniel P. Berrangé 95828760edcSDaniel P. Berrangé /** 95964965b4bSAlex Bennée * qtest_qmp_fds_assert_success: 96028760edcSDaniel P. Berrangé * @qts: QTestState instance to operate on 96128760edcSDaniel P. Berrangé * @fds: the file descriptors to send 96228760edcSDaniel P. Berrangé * @nfds: number of @fds to send 96328760edcSDaniel P. Berrangé * @fmt: QMP message to send to qemu, formatted like 96428760edcSDaniel P. Berrangé * qobject_from_jsonf_nofail(). See parse_interpolation() for what's 96528760edcSDaniel P. Berrangé * supported after '%'. 96628760edcSDaniel P. Berrangé * 96728760edcSDaniel P. Berrangé * Sends a QMP message with file descriptors to QEMU and 96828760edcSDaniel P. Berrangé * asserts that a 'return' key is present in the response. 96928760edcSDaniel P. Berrangé */ 97028760edcSDaniel P. Berrangé void qtest_qmp_fds_assert_success(QTestState *qts, int *fds, size_t nfds, 97128760edcSDaniel P. Berrangé const char *fmt, ...) 97228760edcSDaniel P. Berrangé G_GNUC_PRINTF(4, 5); 97328760edcSDaniel P. Berrangé #endif /* !_WIN32 */ 97428760edcSDaniel P. Berrangé 97502ef6e87SThomas Huth /** 97602ef6e87SThomas Huth * qtest_cb_for_every_machine: 97702ef6e87SThomas Huth * @cb: Pointer to the callback function 9781f4a0d81SThomas Huth * @skip_old_versioned: true if versioned old machine types should be skipped 97902ef6e87SThomas Huth * 98002ef6e87SThomas Huth * Call a callback function for every name of all available machines. 98102ef6e87SThomas Huth */ 9821f4a0d81SThomas Huth void qtest_cb_for_every_machine(void (*cb)(const char *machine), 9831f4a0d81SThomas Huth bool skip_old_versioned); 98402ef6e87SThomas Huth 985acd80015SThomas Huth /** 986a3c0ebc9SFabiano Rosas * qtest_resolve_machine_alias: 987a3c0ebc9SFabiano Rosas * @var: Environment variable from where to take the QEMU binary 988a3c0ebc9SFabiano Rosas * @alias: The alias to resolve 989a3c0ebc9SFabiano Rosas * 990a3c0ebc9SFabiano Rosas * Returns: the machine type corresponding to the alias if any, 991a3c0ebc9SFabiano Rosas * otherwise NULL. 992a3c0ebc9SFabiano Rosas */ 993a3c0ebc9SFabiano Rosas char *qtest_resolve_machine_alias(const char *var, const char *alias); 994a3c0ebc9SFabiano Rosas 995a3c0ebc9SFabiano Rosas /** 996719051caSThomas Huth * qtest_has_machine: 997719051caSThomas Huth * @machine: The machine to look for 998719051caSThomas Huth * 999719051caSThomas Huth * Returns: true if the machine is available in the target binary. 1000719051caSThomas Huth */ 1001719051caSThomas Huth bool qtest_has_machine(const char *machine); 1002719051caSThomas Huth 1003719051caSThomas Huth /** 10041027fc0aSFabiano Rosas * qtest_has_machine_with_env: 10051027fc0aSFabiano Rosas * @var: Environment variable from where to take the QEMU binary 10061027fc0aSFabiano Rosas * @machine: The machine to look for 10071027fc0aSFabiano Rosas * 10081027fc0aSFabiano Rosas * Returns: true if the machine is available in the specified binary. 10091027fc0aSFabiano Rosas */ 10101027fc0aSFabiano Rosas bool qtest_has_machine_with_env(const char *var, const char *machine); 10111027fc0aSFabiano Rosas 10121027fc0aSFabiano Rosas /** 1013f43f8abeSAni Sinha * qtest_has_cpu_model: 1014f43f8abeSAni Sinha * @cpu: The cpu to look for 1015f43f8abeSAni Sinha * 1016f43f8abeSAni Sinha * Returns: true if the cpu is available in the target binary. 1017f43f8abeSAni Sinha */ 1018f43f8abeSAni Sinha bool qtest_has_cpu_model(const char *cpu); 1019f43f8abeSAni Sinha 1020f43f8abeSAni Sinha /** 1021ad9e129bSThomas Huth * qtest_has_device: 1022ad9e129bSThomas Huth * @device: The device to look for 1023ad9e129bSThomas Huth * 1024ad9e129bSThomas Huth * Returns: true if the device is available in the target binary. 1025ad9e129bSThomas Huth */ 1026ad9e129bSThomas Huth bool qtest_has_device(const char *device); 1027ad9e129bSThomas Huth 1028ad9e129bSThomas Huth /** 1029b4510bb4SIgor Mammedov * qtest_qmp_device_add_qdict: 1030b4510bb4SIgor Mammedov * @qts: QTestState instance to operate on 1031b4510bb4SIgor Mammedov * @drv: Name of the device that should be added 10321e458f11SStefan Weil * @arguments: QDict with properties for the device to initialize 1033b4510bb4SIgor Mammedov * 1034b4510bb4SIgor Mammedov * Generic hot-plugging test via the device_add QMP command with properties 1035b4510bb4SIgor Mammedov * supplied in form of QDict. Use NULL for empty properties list. 1036b4510bb4SIgor Mammedov */ 1037b4510bb4SIgor Mammedov void qtest_qmp_device_add_qdict(QTestState *qts, const char *drv, 1038b4510bb4SIgor Mammedov const QDict *arguments); 1039b4510bb4SIgor Mammedov 1040b4510bb4SIgor Mammedov /** 1041acd80015SThomas Huth * qtest_qmp_device_add: 1042e5758de4SThomas Huth * @qts: QTestState instance to operate on 1043acd80015SThomas Huth * @driver: Name of the device that should be added 1044acd80015SThomas Huth * @id: Identification string 104551c778edSEduardo Habkost * @fmt: QMP message to send to qemu, formatted like 1046ad57e2b1SPeter Maydell * qobject_from_jsonf_nofail(). See parse_interpolation() for what's 104782cab70bSMarkus Armbruster * supported after '%'. 1048acd80015SThomas Huth * 1049acd80015SThomas Huth * Generic hot-plugging test via the device_add QMP command. 1050acd80015SThomas Huth */ 1051e5758de4SThomas Huth void qtest_qmp_device_add(QTestState *qts, const char *driver, const char *id, 10529edc6313SMarc-André Lureau const char *fmt, ...) G_GNUC_PRINTF(4, 5); 1053acd80015SThomas Huth 1054acd80015SThomas Huth /** 10552c7294d7SMarc-André Lureau * qtest_qmp_add_client: 10562c7294d7SMarc-André Lureau * @qts: QTestState instance to operate on 10572c7294d7SMarc-André Lureau * @protocol: the protocol to add to 10582c7294d7SMarc-André Lureau * @fd: the client file-descriptor 10592c7294d7SMarc-André Lureau * 106061683d27SMarc-André Lureau * Call QMP ``getfd`` (on Windows ``get-win32-socket``) followed by 106161683d27SMarc-André Lureau * ``add_client`` with the given @fd. 10622c7294d7SMarc-André Lureau */ 10632c7294d7SMarc-André Lureau void qtest_qmp_add_client(QTestState *qts, const char *protocol, int fd); 10642c7294d7SMarc-André Lureau 10652c7294d7SMarc-André Lureau /** 1066ea42a6c4SMichael Labiuk * qtest_qmp_device_del_send: 1067ea42a6c4SMichael Labiuk * @qts: QTestState instance to operate on 1068ea42a6c4SMichael Labiuk * @id: Identification string 1069ea42a6c4SMichael Labiuk * 1070ea42a6c4SMichael Labiuk * Generic hot-unplugging test via the device_del QMP command. 1071ea42a6c4SMichael Labiuk */ 1072ea42a6c4SMichael Labiuk void qtest_qmp_device_del_send(QTestState *qts, const char *id); 1073ea42a6c4SMichael Labiuk 1074ea42a6c4SMichael Labiuk /** 1075acd80015SThomas Huth * qtest_qmp_device_del: 1076e5758de4SThomas Huth * @qts: QTestState instance to operate on 1077acd80015SThomas Huth * @id: Identification string 1078acd80015SThomas Huth * 1079acd80015SThomas Huth * Generic hot-unplugging test via the device_del QMP command. 1080ea42a6c4SMichael Labiuk * Waiting for command completion event. 1081acd80015SThomas Huth */ 1082e5758de4SThomas Huth void qtest_qmp_device_del(QTestState *qts, const char *id); 1083acd80015SThomas Huth 1084c35665e1SIgor Mammedov /** 108521f80286SRichard Henderson * qtest_probe_child: 108621f80286SRichard Henderson * @s: QTestState instance to operate on. 108721f80286SRichard Henderson * 108821f80286SRichard Henderson * Returns: true if the child is still alive. 108921f80286SRichard Henderson */ 109021f80286SRichard Henderson bool qtest_probe_child(QTestState *s); 109121f80286SRichard Henderson 1092d43e59e7SYury Kotov /** 1093d43e59e7SYury Kotov * qtest_set_expected_status: 1094d43e59e7SYury Kotov * @s: QTestState instance to operate on. 1095d43e59e7SYury Kotov * @status: an expected exit status. 1096d43e59e7SYury Kotov * 1097d43e59e7SYury Kotov * Set expected exit status of the child. 1098d43e59e7SYury Kotov */ 1099d43e59e7SYury Kotov void qtest_set_expected_status(QTestState *s, int status); 1100d43e59e7SYury Kotov 1101ca5d4641SAlexander Bulekov QTestState *qtest_inproc_init(QTestState **s, bool log, const char* arch, 1102ca5d4641SAlexander Bulekov void (*send)(void*, const char*)); 1103ca5d4641SAlexander Bulekov 1104ca5d4641SAlexander Bulekov void qtest_client_inproc_recv(void *opaque, const char *str); 1105188052a1SIris Chen 1106188052a1SIris Chen /** 1107188052a1SIris Chen * qtest_qom_set_bool: 1108188052a1SIris Chen * @s: QTestState instance to operate on. 1109188052a1SIris Chen * @path: Path to the property being set. 1110188052a1SIris Chen * @property: Property being set. 1111188052a1SIris Chen * @value: Value to set the property. 1112188052a1SIris Chen * 1113188052a1SIris Chen * Set the property with passed in value. 1114188052a1SIris Chen */ 1115188052a1SIris Chen void qtest_qom_set_bool(QTestState *s, const char *path, const char *property, 1116188052a1SIris Chen bool value); 1117188052a1SIris Chen 1118188052a1SIris Chen /** 1119188052a1SIris Chen * qtest_qom_get_bool: 1120188052a1SIris Chen * @s: QTestState instance to operate on. 1121188052a1SIris Chen * @path: Path to the property being retrieved. 1122188052a1SIris Chen * @property: Property from where the value is being retrieved. 1123188052a1SIris Chen * 1124188052a1SIris Chen * Returns: Value retrieved from property. 1125188052a1SIris Chen */ 1126188052a1SIris Chen bool qtest_qom_get_bool(QTestState *s, const char *path, const char *property); 1127ed097649SMarc-André Lureau 1128ed097649SMarc-André Lureau /** 1129ed097649SMarc-André Lureau * qtest_pid: 1130ed097649SMarc-André Lureau * @s: QTestState instance to operate on. 1131ed097649SMarc-André Lureau * 1132ed097649SMarc-André Lureau * Returns: the PID of the QEMU process, or <= 0 1133ed097649SMarc-André Lureau */ 1134ed097649SMarc-André Lureau pid_t qtest_pid(QTestState *s); 1135ed097649SMarc-André Lureau 113625919c40SThomas Huth /** 113725919c40SThomas Huth * have_qemu_img: 113825919c40SThomas Huth * 113925919c40SThomas Huth * Returns: true if "qemu-img" is available. 114025919c40SThomas Huth */ 114125919c40SThomas Huth bool have_qemu_img(void); 114225919c40SThomas Huth 114325919c40SThomas Huth /** 114425919c40SThomas Huth * mkimg: 114525919c40SThomas Huth * @file: File name of the image that should be created 114625919c40SThomas Huth * @fmt: Format, e.g. "qcow2" or "raw" 114725919c40SThomas Huth * @size_mb: Size of the image in megabytes 114825919c40SThomas Huth * 114925919c40SThomas Huth * Create a disk image with qemu-img. Note that the QTEST_QEMU_IMG 115025919c40SThomas Huth * environment variable must point to the qemu-img file. 115125919c40SThomas Huth * 115225919c40SThomas Huth * Returns: true if the image has been created successfully. 115325919c40SThomas Huth */ 115425919c40SThomas Huth bool mkimg(const char *file, const char *fmt, unsigned size_mb); 115525919c40SThomas Huth 115649ee3590SAnthony Liguori #endif 1157