cachepc-qemu

Fork of AMDESE/qemu with changes for cachepc side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-qemu
Log | Files | Refs | Submodules | LICENSE | sfeed.txt

libqtest.h (22177B)


      1/*
      2 * QTest
      3 *
      4 * Copyright IBM, Corp. 2012
      5 * Copyright Red Hat, Inc. 2012
      6 * Copyright SUSE LINUX Products GmbH 2013
      7 *
      8 * Authors:
      9 *  Anthony Liguori   <aliguori@us.ibm.com>
     10 *  Paolo Bonzini     <pbonzini@redhat.com>
     11 *  Andreas Färber    <afaerber@suse.de>
     12 *
     13 * This work is licensed under the terms of the GNU GPL, version 2 or later.
     14 * See the COPYING file in the top-level directory.
     15 *
     16 */
     17#ifndef LIBQTEST_H
     18#define LIBQTEST_H
     19
     20#include "qapi/qmp/qobject.h"
     21#include "qapi/qmp/qdict.h"
     22
     23typedef struct QTestState QTestState;
     24
     25/**
     26 * qtest_initf:
     27 * @fmt: Format for creating other arguments to pass to QEMU, formatted
     28 * like sprintf().
     29 *
     30 * Convenience wrapper around qtest_init().
     31 *
     32 * Returns: #QTestState instance.
     33 */
     34QTestState *qtest_initf(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
     35
     36/**
     37 * qtest_vinitf:
     38 * @fmt: Format for creating other arguments to pass to QEMU, formatted
     39 * like vsprintf().
     40 * @ap: Format arguments.
     41 *
     42 * Convenience wrapper around qtest_init().
     43 *
     44 * Returns: #QTestState instance.
     45 */
     46QTestState *qtest_vinitf(const char *fmt, va_list ap) GCC_FMT_ATTR(1, 0);
     47
     48/**
     49 * qtest_init:
     50 * @extra_args: other arguments to pass to QEMU.  CAUTION: these
     51 * arguments are subject to word splitting and shell evaluation.
     52 *
     53 * Returns: #QTestState instance.
     54 */
     55QTestState *qtest_init(const char *extra_args);
     56
     57/**
     58 * qtest_init_without_qmp_handshake:
     59 * @extra_args: other arguments to pass to QEMU.  CAUTION: these
     60 * arguments are subject to word splitting and shell evaluation.
     61 *
     62 * Returns: #QTestState instance.
     63 */
     64QTestState *qtest_init_without_qmp_handshake(const char *extra_args);
     65
     66/**
     67 * qtest_init_with_serial:
     68 * @extra_args: other arguments to pass to QEMU.  CAUTION: these
     69 * arguments are subject to word splitting and shell evaluation.
     70 * @sock_fd: pointer to store the socket file descriptor for
     71 * connection with serial.
     72 *
     73 * Returns: #QTestState instance.
     74 */
     75QTestState *qtest_init_with_serial(const char *extra_args, int *sock_fd);
     76
     77/**
     78 * qtest_kill_qemu:
     79 * @s: #QTestState instance to operate on.
     80 *
     81 * Kill the QEMU process and wait for it to terminate. It is safe to call this
     82 * function multiple times. Normally qtest_quit() is used instead because it
     83 * also frees QTestState. Use qtest_kill_qemu() when you just want to kill QEMU
     84 * and qtest_quit() will be called later.
     85 */
     86void qtest_kill_qemu(QTestState *s);
     87
     88/**
     89 * qtest_quit:
     90 * @s: #QTestState instance to operate on.
     91 *
     92 * Shut down the QEMU process associated to @s.
     93 */
     94void qtest_quit(QTestState *s);
     95
     96/**
     97 * qtest_qmp_fds:
     98 * @s: #QTestState instance to operate on.
     99 * @fds: array of file descriptors
    100 * @fds_num: number of elements in @fds
    101 * @fmt: QMP message to send to qemu, formatted like
    102 * qobject_from_jsonf_nofail().  See parse_interpolation() for what's
    103 * supported after '%'.
    104 *
    105 * Sends a QMP message to QEMU with fds and returns the response.
    106 */
    107QDict *qtest_qmp_fds(QTestState *s, int *fds, size_t fds_num,
    108                     const char *fmt, ...)
    109    GCC_FMT_ATTR(4, 5);
    110
    111/**
    112 * qtest_qmp:
    113 * @s: #QTestState instance to operate on.
    114 * @fmt: QMP message to send to qemu, formatted like
    115 * qobject_from_jsonf_nofail().  See parse_interpolation() for what's
    116 * supported after '%'.
    117 *
    118 * Sends a QMP message to QEMU and returns the response.
    119 */
    120QDict *qtest_qmp(QTestState *s, const char *fmt, ...)
    121    GCC_FMT_ATTR(2, 3);
    122
    123/**
    124 * qtest_qmp_send:
    125 * @s: #QTestState instance to operate on.
    126 * @fmt: QMP message to send to qemu, formatted like
    127 * qobject_from_jsonf_nofail().  See parse_interpolation() for what's
    128 * supported after '%'.
    129 *
    130 * Sends a QMP message to QEMU and leaves the response in the stream.
    131 */
    132void qtest_qmp_send(QTestState *s, const char *fmt, ...)
    133    GCC_FMT_ATTR(2, 3);
    134
    135/**
    136 * qtest_qmp_send_raw:
    137 * @s: #QTestState instance to operate on.
    138 * @fmt: text to send, formatted like sprintf()
    139 *
    140 * Sends text to the QMP monitor verbatim.  Need not be valid JSON;
    141 * this is useful for negative tests.
    142 */
    143void qtest_qmp_send_raw(QTestState *s, const char *fmt, ...)
    144    GCC_FMT_ATTR(2, 3);
    145
    146/**
    147 * qtest_socket_server:
    148 * @socket_path: the UNIX domain socket path
    149 *
    150 * Create and return a listen socket file descriptor, or abort on failure.
    151 */
    152int qtest_socket_server(const char *socket_path);
    153
    154/**
    155 * qtest_vqmp_fds:
    156 * @s: #QTestState instance to operate on.
    157 * @fds: array of file descriptors
    158 * @fds_num: number of elements in @fds
    159 * @fmt: QMP message to send to QEMU, formatted like
    160 * qobject_from_jsonf_nofail().  See parse_interpolation() for what's
    161 * supported after '%'.
    162 * @ap: QMP message arguments
    163 *
    164 * Sends a QMP message to QEMU with fds and returns the response.
    165 */
    166QDict *qtest_vqmp_fds(QTestState *s, int *fds, size_t fds_num,
    167                      const char *fmt, va_list ap)
    168    GCC_FMT_ATTR(4, 0);
    169
    170/**
    171 * qtest_vqmp:
    172 * @s: #QTestState instance to operate on.
    173 * @fmt: QMP message to send to QEMU, formatted like
    174 * qobject_from_jsonf_nofail().  See parse_interpolation() for what's
    175 * supported after '%'.
    176 * @ap: QMP message arguments
    177 *
    178 * Sends a QMP message to QEMU and returns the response.
    179 */
    180QDict *qtest_vqmp(QTestState *s, const char *fmt, va_list ap)
    181    GCC_FMT_ATTR(2, 0);
    182
    183/**
    184 * qtest_qmp_vsend_fds:
    185 * @s: #QTestState instance to operate on.
    186 * @fds: array of file descriptors
    187 * @fds_num: number of elements in @fds
    188 * @fmt: QMP message to send to QEMU, formatted like
    189 * qobject_from_jsonf_nofail().  See parse_interpolation() for what's
    190 * supported after '%'.
    191 * @ap: QMP message arguments
    192 *
    193 * Sends a QMP message to QEMU and leaves the response in the stream.
    194 */
    195void qtest_qmp_vsend_fds(QTestState *s, int *fds, size_t fds_num,
    196                         const char *fmt, va_list ap)
    197    GCC_FMT_ATTR(4, 0);
    198
    199/**
    200 * qtest_qmp_vsend:
    201 * @s: #QTestState instance to operate on.
    202 * @fmt: QMP message to send to QEMU, formatted like
    203 * qobject_from_jsonf_nofail().  See parse_interpolation() for what's
    204 * supported after '%'.
    205 * @ap: QMP message arguments
    206 *
    207 * Sends a QMP message to QEMU and leaves the response in the stream.
    208 */
    209void qtest_qmp_vsend(QTestState *s, const char *fmt, va_list ap)
    210    GCC_FMT_ATTR(2, 0);
    211
    212/**
    213 * qtest_qmp_receive_dict:
    214 * @s: #QTestState instance to operate on.
    215 *
    216 * Reads a QMP message from QEMU and returns the response.
    217 */
    218QDict *qtest_qmp_receive_dict(QTestState *s);
    219
    220/**
    221 * qtest_qmp_receive:
    222 * @s: #QTestState instance to operate on.
    223 *
    224 * Reads a QMP message from QEMU and returns the response.
    225 * Buffers all the events received meanwhile, until a
    226 * call to qtest_qmp_eventwait
    227 */
    228QDict *qtest_qmp_receive(QTestState *s);
    229
    230/**
    231 * qtest_qmp_eventwait:
    232 * @s: #QTestState instance to operate on.
    233 * @event: event to wait for.
    234 *
    235 * Continuously polls for QMP responses until it receives the desired event.
    236 */
    237void qtest_qmp_eventwait(QTestState *s, const char *event);
    238
    239/**
    240 * qtest_qmp_eventwait_ref:
    241 * @s: #QTestState instance to operate on.
    242 * @event: event to wait for.
    243 *
    244 * Continuously polls for QMP responses until it receives the desired event.
    245 * Returns a copy of the event for further investigation.
    246 */
    247QDict *qtest_qmp_eventwait_ref(QTestState *s, const char *event);
    248
    249/**
    250 * qtest_qmp_event_ref:
    251 * @s: #QTestState instance to operate on.
    252 * @event: event to return.
    253 *
    254 * Removes non-matching events from the buffer that was set by
    255 * qtest_qmp_receive, until an event bearing the given name is found,
    256 * and returns it.
    257 * If no event matches, clears the buffer and returns NULL.
    258 *
    259 */
    260QDict *qtest_qmp_event_ref(QTestState *s, const char *event);
    261
    262/**
    263 * qtest_hmp:
    264 * @s: #QTestState instance to operate on.
    265 * @fmt: HMP command to send to QEMU, formats arguments like sprintf().
    266 *
    267 * Send HMP command to QEMU via QMP's human-monitor-command.
    268 * QMP events are discarded.
    269 *
    270 * Returns: the command's output.  The caller should g_free() it.
    271 */
    272char *qtest_hmp(QTestState *s, const char *fmt, ...) GCC_FMT_ATTR(2, 3);
    273
    274/**
    275 * qtest_hmpv:
    276 * @s: #QTestState instance to operate on.
    277 * @fmt: HMP command to send to QEMU, formats arguments like vsprintf().
    278 * @ap: HMP command arguments
    279 *
    280 * Send HMP command to QEMU via QMP's human-monitor-command.
    281 * QMP events are discarded.
    282 *
    283 * Returns: the command's output.  The caller should g_free() it.
    284 */
    285char *qtest_vhmp(QTestState *s, const char *fmt, va_list ap)
    286    GCC_FMT_ATTR(2, 0);
    287
    288void qtest_module_load(QTestState *s, const char *prefix, const char *libname);
    289
    290/**
    291 * qtest_get_irq:
    292 * @s: #QTestState instance to operate on.
    293 * @num: Interrupt to observe.
    294 *
    295 * Returns: The level of the @num interrupt.
    296 */
    297bool qtest_get_irq(QTestState *s, int num);
    298
    299/**
    300 * qtest_irq_intercept_in:
    301 * @s: #QTestState instance to operate on.
    302 * @string: QOM path of a device.
    303 *
    304 * Associate qtest irqs with the GPIO-in pins of the device
    305 * whose path is specified by @string.
    306 */
    307void qtest_irq_intercept_in(QTestState *s, const char *string);
    308
    309/**
    310 * qtest_irq_intercept_out:
    311 * @s: #QTestState instance to operate on.
    312 * @string: QOM path of a device.
    313 *
    314 * Associate qtest irqs with the GPIO-out pins of the device
    315 * whose path is specified by @string.
    316 */
    317void qtest_irq_intercept_out(QTestState *s, const char *string);
    318
    319/**
    320 * qtest_set_irq_in:
    321 * @s: QTestState instance to operate on.
    322 * @string: QOM path of a device
    323 * @name: IRQ name
    324 * @irq: IRQ number
    325 * @level: IRQ level
    326 *
    327 * Force given device/irq GPIO-in pin to the given level.
    328 */
    329void qtest_set_irq_in(QTestState *s, const char *string, const char *name,
    330                      int irq, int level);
    331
    332/**
    333 * qtest_outb:
    334 * @s: #QTestState instance to operate on.
    335 * @addr: I/O port to write to.
    336 * @value: Value being written.
    337 *
    338 * Write an 8-bit value to an I/O port.
    339 */
    340void qtest_outb(QTestState *s, uint16_t addr, uint8_t value);
    341
    342/**
    343 * qtest_outw:
    344 * @s: #QTestState instance to operate on.
    345 * @addr: I/O port to write to.
    346 * @value: Value being written.
    347 *
    348 * Write a 16-bit value to an I/O port.
    349 */
    350void qtest_outw(QTestState *s, uint16_t addr, uint16_t value);
    351
    352/**
    353 * qtest_outl:
    354 * @s: #QTestState instance to operate on.
    355 * @addr: I/O port to write to.
    356 * @value: Value being written.
    357 *
    358 * Write a 32-bit value to an I/O port.
    359 */
    360void qtest_outl(QTestState *s, uint16_t addr, uint32_t value);
    361
    362/**
    363 * qtest_inb:
    364 * @s: #QTestState instance to operate on.
    365 * @addr: I/O port to read from.
    366 *
    367 * Returns an 8-bit value from an I/O port.
    368 */
    369uint8_t qtest_inb(QTestState *s, uint16_t addr);
    370
    371/**
    372 * qtest_inw:
    373 * @s: #QTestState instance to operate on.
    374 * @addr: I/O port to read from.
    375 *
    376 * Returns a 16-bit value from an I/O port.
    377 */
    378uint16_t qtest_inw(QTestState *s, uint16_t addr);
    379
    380/**
    381 * qtest_inl:
    382 * @s: #QTestState instance to operate on.
    383 * @addr: I/O port to read from.
    384 *
    385 * Returns a 32-bit value from an I/O port.
    386 */
    387uint32_t qtest_inl(QTestState *s, uint16_t addr);
    388
    389/**
    390 * qtest_writeb:
    391 * @s: #QTestState instance to operate on.
    392 * @addr: Guest address to write to.
    393 * @value: Value being written.
    394 *
    395 * Writes an 8-bit value to memory.
    396 */
    397void qtest_writeb(QTestState *s, uint64_t addr, uint8_t value);
    398
    399/**
    400 * qtest_writew:
    401 * @s: #QTestState instance to operate on.
    402 * @addr: Guest address to write to.
    403 * @value: Value being written.
    404 *
    405 * Writes a 16-bit value to memory.
    406 */
    407void qtest_writew(QTestState *s, uint64_t addr, uint16_t value);
    408
    409/**
    410 * qtest_writel:
    411 * @s: #QTestState instance to operate on.
    412 * @addr: Guest address to write to.
    413 * @value: Value being written.
    414 *
    415 * Writes a 32-bit value to memory.
    416 */
    417void qtest_writel(QTestState *s, uint64_t addr, uint32_t value);
    418
    419/**
    420 * qtest_writeq:
    421 * @s: #QTestState instance to operate on.
    422 * @addr: Guest address to write to.
    423 * @value: Value being written.
    424 *
    425 * Writes a 64-bit value to memory.
    426 */
    427void qtest_writeq(QTestState *s, uint64_t addr, uint64_t value);
    428
    429/**
    430 * qtest_readb:
    431 * @s: #QTestState instance to operate on.
    432 * @addr: Guest address to read from.
    433 *
    434 * Reads an 8-bit value from memory.
    435 *
    436 * Returns: Value read.
    437 */
    438uint8_t qtest_readb(QTestState *s, uint64_t addr);
    439
    440/**
    441 * qtest_readw:
    442 * @s: #QTestState instance to operate on.
    443 * @addr: Guest address to read from.
    444 *
    445 * Reads a 16-bit value from memory.
    446 *
    447 * Returns: Value read.
    448 */
    449uint16_t qtest_readw(QTestState *s, uint64_t addr);
    450
    451/**
    452 * qtest_readl:
    453 * @s: #QTestState instance to operate on.
    454 * @addr: Guest address to read from.
    455 *
    456 * Reads a 32-bit value from memory.
    457 *
    458 * Returns: Value read.
    459 */
    460uint32_t qtest_readl(QTestState *s, uint64_t addr);
    461
    462/**
    463 * qtest_readq:
    464 * @s: #QTestState instance to operate on.
    465 * @addr: Guest address to read from.
    466 *
    467 * Reads a 64-bit value from memory.
    468 *
    469 * Returns: Value read.
    470 */
    471uint64_t qtest_readq(QTestState *s, uint64_t addr);
    472
    473/**
    474 * qtest_memread:
    475 * @s: #QTestState instance to operate on.
    476 * @addr: Guest address to read from.
    477 * @data: Pointer to where memory contents will be stored.
    478 * @size: Number of bytes to read.
    479 *
    480 * Read guest memory into a buffer.
    481 */
    482void qtest_memread(QTestState *s, uint64_t addr, void *data, size_t size);
    483
    484/**
    485 * qtest_rtas_call:
    486 * @s: #QTestState instance to operate on.
    487 * @name: name of the command to call.
    488 * @nargs: Number of args.
    489 * @args: Guest address to read args from.
    490 * @nret: Number of return value.
    491 * @ret: Guest address to write return values to.
    492 *
    493 * Call an RTAS function
    494 */
    495uint64_t qtest_rtas_call(QTestState *s, const char *name,
    496                         uint32_t nargs, uint64_t args,
    497                         uint32_t nret, uint64_t ret);
    498
    499/**
    500 * qtest_bufread:
    501 * @s: #QTestState instance to operate on.
    502 * @addr: Guest address to read from.
    503 * @data: Pointer to where memory contents will be stored.
    504 * @size: Number of bytes to read.
    505 *
    506 * Read guest memory into a buffer and receive using a base64 encoding.
    507 */
    508void qtest_bufread(QTestState *s, uint64_t addr, void *data, size_t size);
    509
    510/**
    511 * qtest_memwrite:
    512 * @s: #QTestState instance to operate on.
    513 * @addr: Guest address to write to.
    514 * @data: Pointer to the bytes that will be written to guest memory.
    515 * @size: Number of bytes to write.
    516 *
    517 * Write a buffer to guest memory.
    518 */
    519void qtest_memwrite(QTestState *s, uint64_t addr, const void *data, size_t size);
    520
    521/**
    522 * qtest_bufwrite:
    523 * @s: #QTestState instance to operate on.
    524 * @addr: Guest address to write to.
    525 * @data: Pointer to the bytes that will be written to guest memory.
    526 * @size: Number of bytes to write.
    527 *
    528 * Write a buffer to guest memory and transmit using a base64 encoding.
    529 */
    530void qtest_bufwrite(QTestState *s, uint64_t addr,
    531                    const void *data, size_t size);
    532
    533/**
    534 * qtest_memset:
    535 * @s: #QTestState instance to operate on.
    536 * @addr: Guest address to write to.
    537 * @patt: Byte pattern to fill the guest memory region with.
    538 * @size: Number of bytes to write.
    539 *
    540 * Write a pattern to guest memory.
    541 */
    542void qtest_memset(QTestState *s, uint64_t addr, uint8_t patt, size_t size);
    543
    544/**
    545 * qtest_clock_step_next:
    546 * @s: #QTestState instance to operate on.
    547 *
    548 * Advance the QEMU_CLOCK_VIRTUAL to the next deadline.
    549 *
    550 * Returns: The current value of the QEMU_CLOCK_VIRTUAL in nanoseconds.
    551 */
    552int64_t qtest_clock_step_next(QTestState *s);
    553
    554/**
    555 * qtest_clock_step:
    556 * @s: QTestState instance to operate on.
    557 * @step: Number of nanoseconds to advance the clock by.
    558 *
    559 * Advance the QEMU_CLOCK_VIRTUAL by @step nanoseconds.
    560 *
    561 * Returns: The current value of the QEMU_CLOCK_VIRTUAL in nanoseconds.
    562 */
    563int64_t qtest_clock_step(QTestState *s, int64_t step);
    564
    565/**
    566 * qtest_clock_set:
    567 * @s: QTestState instance to operate on.
    568 * @val: Nanoseconds value to advance the clock to.
    569 *
    570 * Advance the QEMU_CLOCK_VIRTUAL to @val nanoseconds since the VM was launched.
    571 *
    572 * Returns: The current value of the QEMU_CLOCK_VIRTUAL in nanoseconds.
    573 */
    574int64_t qtest_clock_set(QTestState *s, int64_t val);
    575
    576/**
    577 * qtest_big_endian:
    578 * @s: QTestState instance to operate on.
    579 *
    580 * Returns: True if the architecture under test has a big endian configuration.
    581 */
    582bool qtest_big_endian(QTestState *s);
    583
    584/**
    585 * qtest_get_arch:
    586 *
    587 * Returns: The architecture for the QEMU executable under test.
    588 */
    589const char *qtest_get_arch(void);
    590
    591/**
    592 * qtest_add_func:
    593 * @str: Test case path.
    594 * @fn: Test case function
    595 *
    596 * Add a GTester testcase with the given name and function.
    597 * The path is prefixed with the architecture under test, as
    598 * returned by qtest_get_arch().
    599 */
    600void qtest_add_func(const char *str, void (*fn)(void));
    601
    602/**
    603 * qtest_add_data_func:
    604 * @str: Test case path.
    605 * @data: Test case data
    606 * @fn: Test case function
    607 *
    608 * Add a GTester testcase with the given name, data and function.
    609 * The path is prefixed with the architecture under test, as
    610 * returned by qtest_get_arch().
    611 */
    612void qtest_add_data_func(const char *str, const void *data,
    613                         void (*fn)(const void *));
    614
    615/**
    616 * qtest_add_data_func_full:
    617 * @str: Test case path.
    618 * @data: Test case data
    619 * @fn: Test case function
    620 * @data_free_func: GDestroyNotify for data
    621 *
    622 * Add a GTester testcase with the given name, data and function.
    623 * The path is prefixed with the architecture under test, as
    624 * returned by qtest_get_arch().
    625 *
    626 * @data is passed to @data_free_func() on test completion.
    627 */
    628void qtest_add_data_func_full(const char *str, void *data,
    629                              void (*fn)(const void *),
    630                              GDestroyNotify data_free_func);
    631
    632/**
    633 * qtest_add:
    634 * @testpath: Test case path
    635 * @Fixture: Fixture type
    636 * @tdata: Test case data
    637 * @fsetup: Test case setup function
    638 * @ftest: Test case function
    639 * @fteardown: Test case teardown function
    640 *
    641 * Add a GTester testcase with the given name, data and functions.
    642 * The path is prefixed with the architecture under test, as
    643 * returned by qtest_get_arch().
    644 */
    645#define qtest_add(testpath, Fixture, tdata, fsetup, ftest, fteardown) \
    646    do { \
    647        char *path = g_strdup_printf("/%s/%s", qtest_get_arch(), testpath); \
    648        g_test_add(path, Fixture, tdata, fsetup, ftest, fteardown); \
    649        g_free(path); \
    650    } while (0)
    651
    652/**
    653 * qtest_add_abrt_handler:
    654 * @fn: Handler function
    655 * @data: Argument that is passed to the handler
    656 *
    657 * Add a handler function that is invoked on SIGABRT. This can be used to
    658 * terminate processes and perform other cleanup. The handler can be removed
    659 * with qtest_remove_abrt_handler().
    660 */
    661void qtest_add_abrt_handler(GHookFunc fn, const void *data);
    662
    663/**
    664 * qtest_remove_abrt_handler:
    665 * @data: Argument previously passed to qtest_add_abrt_handler()
    666 *
    667 * Remove an abrt handler that was previously added with
    668 * qtest_add_abrt_handler().
    669 */
    670void qtest_remove_abrt_handler(void *data);
    671
    672/**
    673 * qtest_qmp_assert_success:
    674 * @qts: QTestState instance to operate on
    675 * @fmt: QMP message to send to qemu, formatted like
    676 * qobject_from_jsonf_nofail().  See parse_interpolation() for what's
    677 * supported after '%'.
    678 *
    679 * Sends a QMP message to QEMU and asserts that a 'return' key is present in
    680 * the response.
    681 */
    682void qtest_qmp_assert_success(QTestState *qts, const char *fmt, ...)
    683    GCC_FMT_ATTR(2, 3);
    684
    685QDict *qmp_fd_receive(int fd);
    686void qmp_fd_vsend_fds(int fd, int *fds, size_t fds_num,
    687                      const char *fmt, va_list ap) GCC_FMT_ATTR(4, 0);
    688void qmp_fd_vsend(int fd, const char *fmt, va_list ap) GCC_FMT_ATTR(2, 0);
    689void qmp_fd_send(int fd, const char *fmt, ...) GCC_FMT_ATTR(2, 3);
    690void qmp_fd_send_raw(int fd, const char *fmt, ...) GCC_FMT_ATTR(2, 3);
    691void qmp_fd_vsend_raw(int fd, const char *fmt, va_list ap) GCC_FMT_ATTR(2, 0);
    692QDict *qmp_fdv(int fd, const char *fmt, va_list ap) GCC_FMT_ATTR(2, 0);
    693QDict *qmp_fd(int fd, const char *fmt, ...) GCC_FMT_ATTR(2, 3);
    694
    695/**
    696 * qtest_cb_for_every_machine:
    697 * @cb: Pointer to the callback function
    698 * @skip_old_versioned: true if versioned old machine types should be skipped
    699 *
    700 *  Call a callback function for every name of all available machines.
    701 */
    702void qtest_cb_for_every_machine(void (*cb)(const char *machine),
    703                                bool skip_old_versioned);
    704
    705/**
    706 * qtest_qmp_device_add_qdict:
    707 * @qts: QTestState instance to operate on
    708 * @drv: Name of the device that should be added
    709 * @arguments: QDict with properties for the device to intialize
    710 *
    711 * Generic hot-plugging test via the device_add QMP command with properties
    712 * supplied in form of QDict. Use NULL for empty properties list.
    713 */
    714void qtest_qmp_device_add_qdict(QTestState *qts, const char *drv,
    715                                const QDict *arguments);
    716
    717/**
    718 * qtest_qmp_device_add:
    719 * @qts: QTestState instance to operate on
    720 * @driver: Name of the device that should be added
    721 * @id: Identification string
    722 * @fmt: QMP message to send to qemu, formatted like
    723 * qobject_from_jsonf_nofail().  See parse_interpolation() for what's
    724 * supported after '%'.
    725 *
    726 * Generic hot-plugging test via the device_add QMP command.
    727 */
    728void qtest_qmp_device_add(QTestState *qts, const char *driver, const char *id,
    729                          const char *fmt, ...) GCC_FMT_ATTR(4, 5);
    730
    731/**
    732 * qtest_qmp_device_del:
    733 * @qts: QTestState instance to operate on
    734 * @id: Identification string
    735 *
    736 * Generic hot-unplugging test via the device_del QMP command.
    737 */
    738void qtest_qmp_device_del(QTestState *qts, const char *id);
    739
    740/**
    741 * qmp_rsp_is_err:
    742 * @rsp: QMP response to check for error
    743 *
    744 * Test @rsp for error and discard @rsp.
    745 * Returns 'true' if there is error in @rsp and 'false' otherwise.
    746 */
    747bool qmp_rsp_is_err(QDict *rsp);
    748
    749/**
    750 * qmp_expect_error_and_unref:
    751 * @rsp: QMP response to check for error
    752 * @class: an error class
    753 *
    754 * Assert the response has the given error class and discard @rsp.
    755 */
    756void qmp_expect_error_and_unref(QDict *rsp, const char *class);
    757
    758/**
    759 * qtest_probe_child:
    760 * @s: QTestState instance to operate on.
    761 *
    762 * Returns: true if the child is still alive.
    763 */
    764bool qtest_probe_child(QTestState *s);
    765
    766/**
    767 * qtest_set_expected_status:
    768 * @s: QTestState instance to operate on.
    769 * @status: an expected exit status.
    770 *
    771 * Set expected exit status of the child.
    772 */
    773void qtest_set_expected_status(QTestState *s, int status);
    774
    775QTestState *qtest_inproc_init(QTestState **s, bool log, const char* arch,
    776                    void (*send)(void*, const char*));
    777
    778void qtest_client_inproc_recv(void *opaque, const char *str);
    779#endif