4 * Copyright IBM, Corp. 2012
5 * Copyright Red Hat, Inc. 2012
6 * Copyright SUSE LINUX Products GmbH 2013
9 * Anthony Liguori <aliguori@us.ibm.com>
10 * Paolo Bonzini <pbonzini@redhat.com>
11 * Andreas Färber <afaerber@suse.de>
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.
20 #include "qapi/qmp/qobject.h"
21 #include "qapi/qmp/qdict.h"
23 typedef struct QTestState QTestState
;
25 extern QTestState
*global_qtest
;
29 * @fmt...: Format for creating other arguments to pass to QEMU, formatted
32 * Convenience wrapper around qtest_init().
34 * Returns: #QTestState instance.
36 QTestState
*qtest_initf(const char *fmt
, ...) GCC_FMT_ATTR(1, 2);
40 * @fmt: Format for creating other arguments to pass to QEMU, formatted
42 * @ap: Format arguments.
44 * Convenience wrapper around qtest_init().
46 * Returns: #QTestState instance.
48 QTestState
*qtest_vinitf(const char *fmt
, va_list ap
) GCC_FMT_ATTR(1, 0);
52 * @extra_args: other arguments to pass to QEMU. CAUTION: these
53 * arguments are subject to word splitting and shell evaluation.
55 * Returns: #QTestState instance.
57 QTestState
*qtest_init(const char *extra_args
);
60 * qtest_init_without_qmp_handshake:
61 * @extra_args: other arguments to pass to QEMU. CAUTION: these
62 * arguments are subject to word splitting and shell evaluation.
64 * Returns: #QTestState instance.
66 QTestState
*qtest_init_without_qmp_handshake(const char *extra_args
);
69 * qtest_init_with_serial:
70 * @extra_args: other arguments to pass to QEMU. CAUTION: these
71 * arguments are subject to word splitting and shell evaluation.
72 * @sock_fd: pointer to store the socket file descriptor for
73 * connection with serial.
75 * Returns: #QTestState instance.
77 QTestState
*qtest_init_with_serial(const char *extra_args
, int *sock_fd
);
81 * @s: #QTestState instance to operate on.
83 * Shut down the QEMU process associated to @s.
85 void qtest_quit(QTestState
*s
);
89 * @s: #QTestState instance to operate on.
90 * @fds: array of file descriptors
91 * @fds_num: number of elements in @fds
92 * @fmt...: QMP message to send to qemu, formatted like
93 * qobject_from_jsonf_nofail(). See parse_escape() for what's
94 * supported after '%'.
96 * Sends a QMP message to QEMU with fds and returns the response.
98 QDict
*qtest_qmp_fds(QTestState
*s
, int *fds
, size_t fds_num
,
104 * @s: #QTestState instance to operate on.
105 * @fmt...: QMP message to send to qemu, formatted like
106 * qobject_from_jsonf_nofail(). See parse_escape() for what's
107 * supported after '%'.
109 * Sends a QMP message to QEMU and returns the response.
111 QDict
*qtest_qmp(QTestState
*s
, const char *fmt
, ...)
116 * @s: #QTestState instance to operate on.
117 * @fmt...: QMP message to send to qemu, formatted like
118 * qobject_from_jsonf_nofail(). See parse_escape() for what's
119 * supported after '%'.
121 * Sends a QMP message to QEMU and leaves the response in the stream.
123 void qtest_qmp_send(QTestState
*s
, const char *fmt
, ...)
127 * qtest_qmp_send_raw:
128 * @s: #QTestState instance to operate on.
129 * @fmt...: text to send, formatted like sprintf()
131 * Sends text to the QMP monitor verbatim. Need not be valid JSON;
132 * this is useful for negative tests.
134 void qtest_qmp_send_raw(QTestState
*s
, const char *fmt
, ...)
139 * @s: #QTestState instance to operate on.
140 * @fds: array of file descriptors
141 * @fds_num: number of elements in @fds
142 * @fmt: QMP message to send to QEMU, formatted like
143 * qobject_from_jsonf_nofail(). See parse_escape() for what's
144 * supported after '%'.
145 * @ap: QMP message arguments
147 * Sends a QMP message to QEMU with fds and returns the response.
149 QDict
*qtest_vqmp_fds(QTestState
*s
, int *fds
, size_t fds_num
,
150 const char *fmt
, va_list ap
)
155 * @s: #QTestState instance to operate on.
156 * @fmt: QMP message to send to QEMU, formatted like
157 * qobject_from_jsonf_nofail(). See parse_escape() for what's
158 * supported after '%'.
159 * @ap: QMP message arguments
161 * Sends a QMP message to QEMU and returns the response.
163 QDict
*qtest_vqmp(QTestState
*s
, const char *fmt
, va_list ap
)
167 * qtest_qmp_vsend_fds:
168 * @s: #QTestState instance to operate on.
169 * @fds: array of file descriptors
170 * @fds_num: number of elements in @fds
171 * @fmt: QMP message to send to QEMU, formatted like
172 * qobject_from_jsonf_nofail(). See parse_escape() for what's
173 * supported after '%'.
174 * @ap: QMP message arguments
176 * Sends a QMP message to QEMU and leaves the response in the stream.
178 void qtest_qmp_vsend_fds(QTestState
*s
, int *fds
, size_t fds_num
,
179 const char *fmt
, va_list ap
)
184 * @s: #QTestState instance to operate on.
185 * @fmt: QMP message to send to QEMU, formatted like
186 * qobject_from_jsonf_nofail(). See parse_escape() for what's
187 * supported after '%'.
188 * @ap: QMP message arguments
190 * Sends a QMP message to QEMU and leaves the response in the stream.
192 void qtest_qmp_vsend(QTestState
*s
, const char *fmt
, va_list ap
)
197 * @s: #QTestState instance to operate on.
199 * Reads a QMP message from QEMU and returns the response.
201 QDict
*qtest_qmp_receive(QTestState
*s
);
204 * qtest_qmp_eventwait:
205 * @s: #QTestState instance to operate on.
206 * @s: #event event to wait for.
208 * Continuously polls for QMP responses until it receives the desired event.
210 void qtest_qmp_eventwait(QTestState
*s
, const char *event
);
213 * qtest_qmp_eventwait_ref:
214 * @s: #QTestState instance to operate on.
215 * @s: #event event to wait for.
217 * Continuously polls for QMP responses until it receives the desired event.
218 * Returns a copy of the event for further investigation.
220 QDict
*qtest_qmp_eventwait_ref(QTestState
*s
, const char *event
);
223 * qtest_qmp_receive_success:
224 * @s: #QTestState instance to operate on
225 * @event_cb: Event callback
226 * @opaque: Argument for @event_cb
228 * Poll QMP messages until a command success response is received.
229 * If @event_cb, call it for each event received, passing @opaque,
230 * the event's name and data.
231 * Return the success response's "return" member.
233 QDict
*qtest_qmp_receive_success(QTestState
*s
,
234 void (*event_cb
)(void *opaque
,
241 * @s: #QTestState instance to operate on.
242 * @fmt...: HMP command to send to QEMU, formats arguments like sprintf().
244 * Send HMP command to QEMU via QMP's human-monitor-command.
245 * QMP events are discarded.
247 * Returns: the command's output. The caller should g_free() it.
249 char *qtest_hmp(QTestState
*s
, const char *fmt
, ...) GCC_FMT_ATTR(2, 3);
253 * @s: #QTestState instance to operate on.
254 * @fmt: HMP command to send to QEMU, formats arguments like vsprintf().
255 * @ap: HMP command arguments
257 * Send HMP command to QEMU via QMP's human-monitor-command.
258 * QMP events are discarded.
260 * Returns: the command's output. The caller should g_free() it.
262 char *qtest_vhmp(QTestState
*s
, const char *fmt
, va_list ap
)
267 * @s: #QTestState instance to operate on.
268 * @num: Interrupt to observe.
270 * Returns: The level of the @num interrupt.
272 bool qtest_get_irq(QTestState
*s
, int num
);
275 * qtest_irq_intercept_in:
276 * @s: #QTestState instance to operate on.
277 * @string: QOM path of a device.
279 * Associate qtest irqs with the GPIO-in pins of the device
280 * whose path is specified by @string.
282 void qtest_irq_intercept_in(QTestState
*s
, const char *string
);
285 * qtest_irq_intercept_out:
286 * @s: #QTestState instance to operate on.
287 * @string: QOM path of a device.
289 * Associate qtest irqs with the GPIO-out pins of the device
290 * whose path is specified by @string.
292 void qtest_irq_intercept_out(QTestState
*s
, const char *string
);
296 * @s: QTestState instance to operate on.
297 * @string: QOM path of a device
302 * Force given device/irq GPIO-in pin to the given level.
304 void qtest_set_irq_in(QTestState
*s
, const char *string
, const char *name
,
309 * @s: #QTestState instance to operate on.
310 * @addr: I/O port to write to.
311 * @value: Value being written.
313 * Write an 8-bit value to an I/O port.
315 void qtest_outb(QTestState
*s
, uint16_t addr
, uint8_t value
);
319 * @s: #QTestState instance to operate on.
320 * @addr: I/O port to write to.
321 * @value: Value being written.
323 * Write a 16-bit value to an I/O port.
325 void qtest_outw(QTestState
*s
, uint16_t addr
, uint16_t value
);
329 * @s: #QTestState instance to operate on.
330 * @addr: I/O port to write to.
331 * @value: Value being written.
333 * Write a 32-bit value to an I/O port.
335 void qtest_outl(QTestState
*s
, uint16_t addr
, uint32_t value
);
339 * @s: #QTestState instance to operate on.
340 * @addr: I/O port to read from.
342 * Returns an 8-bit value from an I/O port.
344 uint8_t qtest_inb(QTestState
*s
, uint16_t addr
);
348 * @s: #QTestState instance to operate on.
349 * @addr: I/O port to read from.
351 * Returns a 16-bit value from an I/O port.
353 uint16_t qtest_inw(QTestState
*s
, uint16_t addr
);
357 * @s: #QTestState instance to operate on.
358 * @addr: I/O port to read from.
360 * Returns a 32-bit value from an I/O port.
362 uint32_t qtest_inl(QTestState
*s
, uint16_t addr
);
366 * @s: #QTestState instance to operate on.
367 * @addr: Guest address to write to.
368 * @value: Value being written.
370 * Writes an 8-bit value to memory.
372 void qtest_writeb(QTestState
*s
, uint64_t addr
, uint8_t value
);
376 * @s: #QTestState instance to operate on.
377 * @addr: Guest address to write to.
378 * @value: Value being written.
380 * Writes a 16-bit value to memory.
382 void qtest_writew(QTestState
*s
, uint64_t addr
, uint16_t value
);
386 * @s: #QTestState instance to operate on.
387 * @addr: Guest address to write to.
388 * @value: Value being written.
390 * Writes a 32-bit value to memory.
392 void qtest_writel(QTestState
*s
, uint64_t addr
, uint32_t value
);
396 * @s: #QTestState instance to operate on.
397 * @addr: Guest address to write to.
398 * @value: Value being written.
400 * Writes a 64-bit value to memory.
402 void qtest_writeq(QTestState
*s
, uint64_t addr
, uint64_t value
);
406 * @s: #QTestState instance to operate on.
407 * @addr: Guest address to read from.
409 * Reads an 8-bit value from memory.
411 * Returns: Value read.
413 uint8_t qtest_readb(QTestState
*s
, uint64_t addr
);
417 * @s: #QTestState instance to operate on.
418 * @addr: Guest address to read from.
420 * Reads a 16-bit value from memory.
422 * Returns: Value read.
424 uint16_t qtest_readw(QTestState
*s
, uint64_t addr
);
428 * @s: #QTestState instance to operate on.
429 * @addr: Guest address to read from.
431 * Reads a 32-bit value from memory.
433 * Returns: Value read.
435 uint32_t qtest_readl(QTestState
*s
, uint64_t addr
);
439 * @s: #QTestState instance to operate on.
440 * @addr: Guest address to read from.
442 * Reads a 64-bit value from memory.
444 * Returns: Value read.
446 uint64_t qtest_readq(QTestState
*s
, uint64_t addr
);
450 * @s: #QTestState instance to operate on.
451 * @addr: Guest address to read from.
452 * @data: Pointer to where memory contents will be stored.
453 * @size: Number of bytes to read.
455 * Read guest memory into a buffer.
457 void qtest_memread(QTestState
*s
, uint64_t addr
, void *data
, size_t size
);
461 * @s: #QTestState instance to operate on.
462 * @name: name of the command to call.
463 * @nargs: Number of args.
464 * @args: Guest address to read args from.
465 * @nret: Number of return value.
466 * @ret: Guest address to write return values to.
468 * Call an RTAS function
470 uint64_t qtest_rtas_call(QTestState
*s
, const char *name
,
471 uint32_t nargs
, uint64_t args
,
472 uint32_t nret
, uint64_t ret
);
476 * @s: #QTestState instance to operate on.
477 * @addr: Guest address to read from.
478 * @data: Pointer to where memory contents will be stored.
479 * @size: Number of bytes to read.
481 * Read guest memory into a buffer and receive using a base64 encoding.
483 void qtest_bufread(QTestState
*s
, uint64_t addr
, void *data
, size_t size
);
487 * @s: #QTestState instance to operate on.
488 * @addr: Guest address to write to.
489 * @data: Pointer to the bytes that will be written to guest memory.
490 * @size: Number of bytes to write.
492 * Write a buffer to guest memory.
494 void qtest_memwrite(QTestState
*s
, uint64_t addr
, const void *data
, size_t size
);
498 * @s: #QTestState instance to operate on.
499 * @addr: Guest address to write to.
500 * @data: Pointer to the bytes that will be written to guest memory.
501 * @size: Number of bytes to write.
503 * Write a buffer to guest memory and transmit using a base64 encoding.
505 void qtest_bufwrite(QTestState
*s
, uint64_t addr
,
506 const void *data
, size_t size
);
510 * @s: #QTestState instance to operate on.
511 * @addr: Guest address to write to.
512 * @patt: Byte pattern to fill the guest memory region with.
513 * @size: Number of bytes to write.
515 * Write a pattern to guest memory.
517 void qtest_memset(QTestState
*s
, uint64_t addr
, uint8_t patt
, size_t size
);
520 * qtest_clock_step_next:
521 * @s: #QTestState instance to operate on.
523 * Advance the QEMU_CLOCK_VIRTUAL to the next deadline.
525 * Returns: The current value of the QEMU_CLOCK_VIRTUAL in nanoseconds.
527 int64_t qtest_clock_step_next(QTestState
*s
);
531 * @s: QTestState instance to operate on.
532 * @step: Number of nanoseconds to advance the clock by.
534 * Advance the QEMU_CLOCK_VIRTUAL by @step nanoseconds.
536 * Returns: The current value of the QEMU_CLOCK_VIRTUAL in nanoseconds.
538 int64_t qtest_clock_step(QTestState
*s
, int64_t step
);
542 * @s: QTestState instance to operate on.
543 * @val: Nanoseconds value to advance the clock to.
545 * Advance the QEMU_CLOCK_VIRTUAL to @val nanoseconds since the VM was launched.
547 * Returns: The current value of the QEMU_CLOCK_VIRTUAL in nanoseconds.
549 int64_t qtest_clock_set(QTestState
*s
, int64_t val
);
553 * @s: QTestState instance to operate on.
555 * Returns: True if the architecture under test has a big endian configuration.
557 bool qtest_big_endian(QTestState
*s
);
562 * Returns: The architecture for the QEMU executable under test.
564 const char *qtest_get_arch(void);
568 * @str: Test case path.
569 * @fn: Test case function
571 * Add a GTester testcase with the given name and function.
572 * The path is prefixed with the architecture under test, as
573 * returned by qtest_get_arch().
575 void qtest_add_func(const char *str
, void (*fn
)(void));
578 * qtest_add_data_func:
579 * @str: Test case path.
580 * @data: Test case data
581 * @fn: Test case function
583 * Add a GTester testcase with the given name, data and function.
584 * The path is prefixed with the architecture under test, as
585 * returned by qtest_get_arch().
587 void qtest_add_data_func(const char *str
, const void *data
,
588 void (*fn
)(const void *));
591 * qtest_add_data_func_full:
592 * @str: Test case path.
593 * @data: Test case data
594 * @fn: Test case function
595 * @data_free_func: GDestroyNotify for data
597 * Add a GTester testcase with the given name, data and function.
598 * The path is prefixed with the architecture under test, as
599 * returned by qtest_get_arch().
601 * @data is passed to @data_free_func() on test completion.
603 void qtest_add_data_func_full(const char *str
, void *data
,
604 void (*fn
)(const void *),
605 GDestroyNotify data_free_func
);
609 * @testpath: Test case path
610 * @Fixture: Fixture type
611 * @tdata: Test case data
612 * @fsetup: Test case setup function
613 * @ftest: Test case function
614 * @fteardown: Test case teardown function
616 * Add a GTester testcase with the given name, data and functions.
617 * The path is prefixed with the architecture under test, as
618 * returned by qtest_get_arch().
620 #define qtest_add(testpath, Fixture, tdata, fsetup, ftest, fteardown) \
622 char *path = g_strdup_printf("/%s/%s", qtest_get_arch(), testpath); \
623 g_test_add(path, Fixture, tdata, fsetup, ftest, fteardown); \
627 void qtest_add_abrt_handler(GHookFunc fn
, const void *data
);
631 * @args: other arguments to pass to QEMU
633 * Start QEMU and assign the resulting #QTestState to a global variable.
634 * The global variable is used by "shortcut" functions documented below.
636 * Returns: #QTestState instance.
638 static inline QTestState
*qtest_start(const char *args
)
640 global_qtest
= qtest_init(args
);
647 * Shut down the QEMU process started by qtest_start().
649 static inline void qtest_end(void)
654 qtest_quit(global_qtest
);
660 * @fmt...: QMP message to send to qemu, formatted like
661 * qobject_from_jsonf_nofail(). See parse_escape() for what's
662 * supported after '%'.
664 * Sends a QMP message to QEMU and returns the response.
666 QDict
*qmp(const char *fmt
, ...) GCC_FMT_ATTR(1, 2);
669 * qtest_qmp_assert_success:
670 * @qts: QTestState instance to operate on
671 * @fmt...: QMP message to send to qemu, formatted like
672 * qobject_from_jsonf_nofail(). See parse_escape() for what's
673 * supported after '%'.
675 * Sends a QMP message to QEMU and asserts that a 'return' key is present in
678 void qtest_qmp_assert_success(QTestState
*qts
, const char *fmt
, ...)
683 * @s: #event event to wait for.
685 * Continuously polls for QMP responses until it receives the desired event.
687 static inline void qmp_eventwait(const char *event
)
689 return qtest_qmp_eventwait(global_qtest
, event
);
694 * @num: Interrupt to observe.
696 * Returns: The level of the @num interrupt.
698 static inline bool get_irq(int num
)
700 return qtest_get_irq(global_qtest
, num
);
705 * @addr: I/O port to write to.
706 * @value: Value being written.
708 * Write an 8-bit value to an I/O port.
710 static inline void outb(uint16_t addr
, uint8_t value
)
712 qtest_outb(global_qtest
, addr
, value
);
717 * @addr: I/O port to write to.
718 * @value: Value being written.
720 * Write a 16-bit value to an I/O port.
722 static inline void outw(uint16_t addr
, uint16_t value
)
724 qtest_outw(global_qtest
, addr
, value
);
729 * @addr: I/O port to write to.
730 * @value: Value being written.
732 * Write a 32-bit value to an I/O port.
734 static inline void outl(uint16_t addr
, uint32_t value
)
736 qtest_outl(global_qtest
, addr
, value
);
741 * @addr: I/O port to read from.
743 * Reads an 8-bit value from an I/O port.
745 * Returns: Value read.
747 static inline uint8_t inb(uint16_t addr
)
749 return qtest_inb(global_qtest
, addr
);
754 * @addr: I/O port to read from.
756 * Reads a 16-bit value from an I/O port.
758 * Returns: Value read.
760 static inline uint16_t inw(uint16_t addr
)
762 return qtest_inw(global_qtest
, addr
);
767 * @addr: I/O port to read from.
769 * Reads a 32-bit value from an I/O port.
771 * Returns: Value read.
773 static inline uint32_t inl(uint16_t addr
)
775 return qtest_inl(global_qtest
, addr
);
780 * @addr: Guest address to write to.
781 * @value: Value being written.
783 * Writes an 8-bit value to guest memory.
785 static inline void writeb(uint64_t addr
, uint8_t value
)
787 qtest_writeb(global_qtest
, addr
, value
);
792 * @addr: Guest address to write to.
793 * @value: Value being written.
795 * Writes a 16-bit value to guest memory.
797 static inline void writew(uint64_t addr
, uint16_t value
)
799 qtest_writew(global_qtest
, addr
, value
);
804 * @addr: Guest address to write to.
805 * @value: Value being written.
807 * Writes a 32-bit value to guest memory.
809 static inline void writel(uint64_t addr
, uint32_t value
)
811 qtest_writel(global_qtest
, addr
, value
);
816 * @addr: Guest address to write to.
817 * @value: Value being written.
819 * Writes a 64-bit value to guest memory.
821 static inline void writeq(uint64_t addr
, uint64_t value
)
823 qtest_writeq(global_qtest
, addr
, value
);
828 * @addr: Guest address to read from.
830 * Reads an 8-bit value from guest memory.
832 * Returns: Value read.
834 static inline uint8_t readb(uint64_t addr
)
836 return qtest_readb(global_qtest
, addr
);
841 * @addr: Guest address to read from.
843 * Reads a 16-bit value from guest memory.
845 * Returns: Value read.
847 static inline uint16_t readw(uint64_t addr
)
849 return qtest_readw(global_qtest
, addr
);
854 * @addr: Guest address to read from.
856 * Reads a 32-bit value from guest memory.
858 * Returns: Value read.
860 static inline uint32_t readl(uint64_t addr
)
862 return qtest_readl(global_qtest
, addr
);
867 * @addr: Guest address to read from.
869 * Reads a 64-bit value from guest memory.
871 * Returns: Value read.
873 static inline uint64_t readq(uint64_t addr
)
875 return qtest_readq(global_qtest
, addr
);
880 * @addr: Guest address to read from.
881 * @data: Pointer to where memory contents will be stored.
882 * @size: Number of bytes to read.
884 * Read guest memory into a buffer.
886 static inline void memread(uint64_t addr
, void *data
, size_t size
)
888 qtest_memread(global_qtest
, addr
, data
, size
);
893 * @addr: Guest address to write to.
894 * @data: Pointer to the bytes that will be written to guest memory.
895 * @size: Number of bytes to write.
897 * Write a buffer to guest memory.
899 static inline void memwrite(uint64_t addr
, const void *data
, size_t size
)
901 qtest_memwrite(global_qtest
, addr
, data
, size
);
907 * Advance the QEMU_CLOCK_VIRTUAL to the next deadline.
909 * Returns: The current value of the QEMU_CLOCK_VIRTUAL in nanoseconds.
911 static inline int64_t clock_step_next(void)
913 return qtest_clock_step_next(global_qtest
);
918 * @step: Number of nanoseconds to advance the clock by.
920 * Advance the QEMU_CLOCK_VIRTUAL by @step nanoseconds.
922 * Returns: The current value of the QEMU_CLOCK_VIRTUAL in nanoseconds.
924 static inline int64_t clock_step(int64_t step
)
926 return qtest_clock_step(global_qtest
, step
);
929 QDict
*qmp_fd_receive(int fd
);
930 void qmp_fd_vsend_fds(int fd
, int *fds
, size_t fds_num
,
931 const char *fmt
, va_list ap
) GCC_FMT_ATTR(4, 0);
932 void qmp_fd_vsend(int fd
, const char *fmt
, va_list ap
) GCC_FMT_ATTR(2, 0);
933 void qmp_fd_send(int fd
, const char *fmt
, ...) GCC_FMT_ATTR(2, 3);
934 void qmp_fd_send_raw(int fd
, const char *fmt
, ...) GCC_FMT_ATTR(2, 3);
935 void qmp_fd_vsend_raw(int fd
, const char *fmt
, va_list ap
) GCC_FMT_ATTR(2, 0);
936 QDict
*qmp_fdv(int fd
, const char *fmt
, va_list ap
) GCC_FMT_ATTR(2, 0);
937 QDict
*qmp_fd(int fd
, const char *fmt
, ...) GCC_FMT_ATTR(2, 3);
940 * qtest_cb_for_every_machine:
941 * @cb: Pointer to the callback function
942 * @skip_old_versioned: true if versioned old machine types should be skipped
944 * Call a callback function for every name of all available machines.
946 void qtest_cb_for_every_machine(void (*cb
)(const char *machine
),
947 bool skip_old_versioned
);
950 * qtest_qmp_device_add:
951 * @qts: QTestState instance to operate on
952 * @driver: Name of the device that should be added
953 * @id: Identification string
954 * @fmt...: QMP message to send to qemu, formatted like
955 * qobject_from_jsonf_nofail(). See parse_escape() for what's
956 * supported after '%'.
958 * Generic hot-plugging test via the device_add QMP command.
960 void qtest_qmp_device_add(QTestState
*qts
, const char *driver
, const char *id
,
961 const char *fmt
, ...) GCC_FMT_ATTR(4, 5);
964 * qtest_qmp_device_del:
965 * @qts: QTestState instance to operate on
966 * @id: Identification string
968 * Generic hot-unplugging test via the device_del QMP command.
970 void qtest_qmp_device_del(QTestState
*qts
, const char *id
);
974 * @rsp: QMP response to check for error
976 * Test @rsp for error and discard @rsp.
977 * Returns 'true' if there is error in @rsp and 'false' otherwise.
979 bool qmp_rsp_is_err(QDict
*rsp
);
982 * qmp_assert_error_class:
983 * @rsp: QMP response to check for error
984 * @class: an error class
986 * Assert the response has the given error class and discard @rsp.
988 void qmp_assert_error_class(QDict
*rsp
, const char *class);
992 * @s: QTestState instance to operate on.
994 * Returns: true if the child is still alive.
996 bool qtest_probe_child(QTestState
*s
);