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 typedef struct QTestState QTestState
;
22 extern QTestState
*global_qtest
;
26 * @fmt...: Format for creating other arguments to pass to QEMU, formatted
29 * Convenience wrapper around qtest_start().
31 * Returns: #QTestState instance.
33 QTestState
*qtest_initf(const char *fmt
, ...) GCC_FMT_ATTR(1, 2);
37 * @fmt: Format for creating other arguments to pass to QEMU, formatted
39 * @ap: Format arguments.
41 * Convenience wrapper around qtest_start().
43 * Returns: #QTestState instance.
45 QTestState
*qtest_vinitf(const char *fmt
, va_list ap
) GCC_FMT_ATTR(1, 0);
49 * @extra_args: other arguments to pass to QEMU. CAUTION: these
50 * arguments are subject to word splitting and shell evaluation.
52 * Returns: #QTestState instance.
54 QTestState
*qtest_init(const char *extra_args
);
57 * qtest_init_without_qmp_handshake:
58 * @extra_args: other arguments to pass to QEMU. CAUTION: these
59 * arguments are subject to word splitting and shell evaluation.
61 * Returns: #QTestState instance.
63 QTestState
*qtest_init_without_qmp_handshake(const char *extra_args
);
67 * @s: #QTestState instance to operate on.
69 * Shut down the QEMU process associated to @s.
71 void qtest_quit(QTestState
*s
);
75 * @s: #QTestState instance to operate on.
76 * @fmt...: QMP message to send to qemu, formatted like
77 * qobject_from_jsonf_nofail(). See parse_escape() for what's
78 * supported after '%'.
80 * Sends a QMP message to QEMU and returns the response.
82 QDict
*qtest_qmp(QTestState
*s
, const char *fmt
, ...)
87 * @s: #QTestState instance to operate on.
88 * @fmt...: QMP message to send to qemu, formatted like
89 * qobject_from_jsonf_nofail(). See parse_escape() for what's
90 * supported after '%'.
92 * Sends a QMP message to QEMU and leaves the response in the stream.
94 void qtest_qmp_send(QTestState
*s
, const char *fmt
, ...)
99 * @s: #QTestState instance to operate on.
100 * @fmt...: text to send, formatted like sprintf()
102 * Sends text to the QMP monitor verbatim. Need not be valid JSON;
103 * this is useful for negative tests.
105 void qtest_qmp_send_raw(QTestState
*s
, const char *fmt
, ...)
110 * @s: #QTestState instance to operate on.
111 * @fmt: QMP message to send to QEMU, formatted like
112 * qobject_from_jsonf_nofail(). See parse_escape() for what's
113 * supported after '%'.
114 * @ap: QMP message arguments
116 * Sends a QMP message to QEMU and returns the response.
118 QDict
*qtest_vqmp(QTestState
*s
, const char *fmt
, va_list ap
)
123 * @s: #QTestState instance to operate on.
124 * @fmt: QMP message to send to QEMU, formatted like
125 * qobject_from_jsonf_nofail(). See parse_escape() for what's
126 * supported after '%'.
127 * @ap: QMP message arguments
129 * Sends a QMP message to QEMU and leaves the response in the stream.
131 void qtest_qmp_vsend(QTestState
*s
, const char *fmt
, va_list ap
)
136 * @s: #QTestState instance to operate on.
138 * Reads a QMP message from QEMU and returns the response.
140 QDict
*qtest_qmp_receive(QTestState
*s
);
143 * qtest_qmp_eventwait:
144 * @s: #QTestState instance to operate on.
145 * @s: #event event to wait for.
147 * Continuously polls for QMP responses until it receives the desired event.
149 void qtest_qmp_eventwait(QTestState
*s
, const char *event
);
152 * qtest_qmp_eventwait_ref:
153 * @s: #QTestState instance to operate on.
154 * @s: #event event to wait for.
156 * Continuously polls for QMP responses until it receives the desired event.
157 * Returns a copy of the event for further investigation.
159 QDict
*qtest_qmp_eventwait_ref(QTestState
*s
, const char *event
);
162 * qtest_qmp_receive_success:
163 * @s: #QTestState instance to operate on
164 * @event_cb: Event callback
165 * @opaque: Argument for @event_cb
167 * Poll QMP messages until a command success response is received.
168 * If @event_cb, call it for each event received, passing @opaque,
169 * the event's name and data.
170 * Return the success response's "return" member.
172 QDict
*qtest_qmp_receive_success(QTestState
*s
,
173 void (*event_cb
)(void *opaque
,
180 * @s: #QTestState instance to operate on.
181 * @fmt...: HMP command to send to QEMU, formats arguments like sprintf().
183 * Send HMP command to QEMU via QMP's human-monitor-command.
184 * QMP events are discarded.
186 * Returns: the command's output. The caller should g_free() it.
188 char *qtest_hmp(QTestState
*s
, const char *fmt
, ...) GCC_FMT_ATTR(2, 3);
192 * @s: #QTestState instance to operate on.
193 * @fmt: HMP command to send to QEMU, formats arguments like vsprintf().
194 * @ap: HMP command arguments
196 * Send HMP command to QEMU via QMP's human-monitor-command.
197 * QMP events are discarded.
199 * Returns: the command's output. The caller should g_free() it.
201 char *qtest_vhmp(QTestState
*s
, const char *fmt
, va_list ap
)
206 * @s: #QTestState instance to operate on.
207 * @num: Interrupt to observe.
209 * Returns: The level of the @num interrupt.
211 bool qtest_get_irq(QTestState
*s
, int num
);
214 * qtest_irq_intercept_in:
215 * @s: #QTestState instance to operate on.
216 * @string: QOM path of a device.
218 * Associate qtest irqs with the GPIO-in pins of the device
219 * whose path is specified by @string.
221 void qtest_irq_intercept_in(QTestState
*s
, const char *string
);
224 * qtest_irq_intercept_out:
225 * @s: #QTestState instance to operate on.
226 * @string: QOM path of a device.
228 * Associate qtest irqs with the GPIO-out pins of the device
229 * whose path is specified by @string.
231 void qtest_irq_intercept_out(QTestState
*s
, const char *string
);
235 * @s: QTestState instance to operate on.
236 * @string: QOM path of a device
241 * Force given device/irq GPIO-in pin to the given level.
243 void qtest_set_irq_in(QTestState
*s
, const char *string
, const char *name
,
248 * @s: #QTestState instance to operate on.
249 * @addr: I/O port to write to.
250 * @value: Value being written.
252 * Write an 8-bit value to an I/O port.
254 void qtest_outb(QTestState
*s
, uint16_t addr
, uint8_t value
);
258 * @s: #QTestState instance to operate on.
259 * @addr: I/O port to write to.
260 * @value: Value being written.
262 * Write a 16-bit value to an I/O port.
264 void qtest_outw(QTestState
*s
, uint16_t addr
, uint16_t value
);
268 * @s: #QTestState instance to operate on.
269 * @addr: I/O port to write to.
270 * @value: Value being written.
272 * Write a 32-bit value to an I/O port.
274 void qtest_outl(QTestState
*s
, uint16_t addr
, uint32_t value
);
278 * @s: #QTestState instance to operate on.
279 * @addr: I/O port to read from.
281 * Returns an 8-bit value from an I/O port.
283 uint8_t qtest_inb(QTestState
*s
, uint16_t addr
);
287 * @s: #QTestState instance to operate on.
288 * @addr: I/O port to read from.
290 * Returns a 16-bit value from an I/O port.
292 uint16_t qtest_inw(QTestState
*s
, uint16_t addr
);
296 * @s: #QTestState instance to operate on.
297 * @addr: I/O port to read from.
299 * Returns a 32-bit value from an I/O port.
301 uint32_t qtest_inl(QTestState
*s
, uint16_t addr
);
305 * @s: #QTestState instance to operate on.
306 * @addr: Guest address to write to.
307 * @value: Value being written.
309 * Writes an 8-bit value to memory.
311 void qtest_writeb(QTestState
*s
, uint64_t addr
, uint8_t value
);
315 * @s: #QTestState instance to operate on.
316 * @addr: Guest address to write to.
317 * @value: Value being written.
319 * Writes a 16-bit value to memory.
321 void qtest_writew(QTestState
*s
, uint64_t addr
, uint16_t value
);
325 * @s: #QTestState instance to operate on.
326 * @addr: Guest address to write to.
327 * @value: Value being written.
329 * Writes a 32-bit value to memory.
331 void qtest_writel(QTestState
*s
, uint64_t addr
, uint32_t value
);
335 * @s: #QTestState instance to operate on.
336 * @addr: Guest address to write to.
337 * @value: Value being written.
339 * Writes a 64-bit value to memory.
341 void qtest_writeq(QTestState
*s
, uint64_t addr
, uint64_t value
);
345 * @s: #QTestState instance to operate on.
346 * @addr: Guest address to read from.
348 * Reads an 8-bit value from memory.
350 * Returns: Value read.
352 uint8_t qtest_readb(QTestState
*s
, uint64_t addr
);
356 * @s: #QTestState instance to operate on.
357 * @addr: Guest address to read from.
359 * Reads a 16-bit value from memory.
361 * Returns: Value read.
363 uint16_t qtest_readw(QTestState
*s
, uint64_t addr
);
367 * @s: #QTestState instance to operate on.
368 * @addr: Guest address to read from.
370 * Reads a 32-bit value from memory.
372 * Returns: Value read.
374 uint32_t qtest_readl(QTestState
*s
, uint64_t addr
);
378 * @s: #QTestState instance to operate on.
379 * @addr: Guest address to read from.
381 * Reads a 64-bit value from memory.
383 * Returns: Value read.
385 uint64_t qtest_readq(QTestState
*s
, uint64_t addr
);
389 * @s: #QTestState instance to operate on.
390 * @addr: Guest address to read from.
391 * @data: Pointer to where memory contents will be stored.
392 * @size: Number of bytes to read.
394 * Read guest memory into a buffer.
396 void qtest_memread(QTestState
*s
, uint64_t addr
, void *data
, size_t size
);
400 * @s: #QTestState instance to operate on.
401 * @name: name of the command to call.
402 * @nargs: Number of args.
403 * @args: Guest address to read args from.
404 * @nret: Number of return value.
405 * @ret: Guest address to write return values to.
407 * Call an RTAS function
409 uint64_t qtest_rtas_call(QTestState
*s
, const char *name
,
410 uint32_t nargs
, uint64_t args
,
411 uint32_t nret
, uint64_t ret
);
415 * @s: #QTestState instance to operate on.
416 * @addr: Guest address to read from.
417 * @data: Pointer to where memory contents will be stored.
418 * @size: Number of bytes to read.
420 * Read guest memory into a buffer and receive using a base64 encoding.
422 void qtest_bufread(QTestState
*s
, uint64_t addr
, void *data
, size_t size
);
426 * @s: #QTestState instance to operate on.
427 * @addr: Guest address to write to.
428 * @data: Pointer to the bytes that will be written to guest memory.
429 * @size: Number of bytes to write.
431 * Write a buffer to guest memory.
433 void qtest_memwrite(QTestState
*s
, uint64_t addr
, const void *data
, size_t size
);
437 * @s: #QTestState instance to operate on.
438 * @addr: Guest address to write to.
439 * @data: Pointer to the bytes that will be written to guest memory.
440 * @size: Number of bytes to write.
442 * Write a buffer to guest memory and transmit using a base64 encoding.
444 void qtest_bufwrite(QTestState
*s
, uint64_t addr
,
445 const void *data
, size_t size
);
449 * @s: #QTestState instance to operate on.
450 * @addr: Guest address to write to.
451 * @patt: Byte pattern to fill the guest memory region with.
452 * @size: Number of bytes to write.
454 * Write a pattern to guest memory.
456 void qtest_memset(QTestState
*s
, uint64_t addr
, uint8_t patt
, size_t size
);
459 * qtest_clock_step_next:
460 * @s: #QTestState instance to operate on.
462 * Advance the QEMU_CLOCK_VIRTUAL to the next deadline.
464 * Returns: The current value of the QEMU_CLOCK_VIRTUAL in nanoseconds.
466 int64_t qtest_clock_step_next(QTestState
*s
);
470 * @s: QTestState instance to operate on.
471 * @step: Number of nanoseconds to advance the clock by.
473 * Advance the QEMU_CLOCK_VIRTUAL by @step nanoseconds.
475 * Returns: The current value of the QEMU_CLOCK_VIRTUAL in nanoseconds.
477 int64_t qtest_clock_step(QTestState
*s
, int64_t step
);
481 * @s: QTestState instance to operate on.
482 * @val: Nanoseconds value to advance the clock to.
484 * Advance the QEMU_CLOCK_VIRTUAL to @val nanoseconds since the VM was launched.
486 * Returns: The current value of the QEMU_CLOCK_VIRTUAL in nanoseconds.
488 int64_t qtest_clock_set(QTestState
*s
, int64_t val
);
492 * @s: QTestState instance to operate on.
494 * Returns: True if the architecture under test has a big endian configuration.
496 bool qtest_big_endian(QTestState
*s
);
501 * Returns: The architecture for the QEMU executable under test.
503 const char *qtest_get_arch(void);
507 * @str: Test case path.
508 * @fn: Test case function
510 * Add a GTester testcase with the given name and function.
511 * The path is prefixed with the architecture under test, as
512 * returned by qtest_get_arch().
514 void qtest_add_func(const char *str
, void (*fn
)(void));
517 * qtest_add_data_func:
518 * @str: Test case path.
519 * @data: Test case data
520 * @fn: Test case function
522 * Add a GTester testcase with the given name, data and function.
523 * The path is prefixed with the architecture under test, as
524 * returned by qtest_get_arch().
526 void qtest_add_data_func(const char *str
, const void *data
,
527 void (*fn
)(const void *));
530 * qtest_add_data_func_full:
531 * @str: Test case path.
532 * @data: Test case data
533 * @fn: Test case function
534 * @data_free_func: GDestroyNotify for data
536 * Add a GTester testcase with the given name, data and function.
537 * The path is prefixed with the architecture under test, as
538 * returned by qtest_get_arch().
540 * @data is passed to @data_free_func() on test completion.
542 void qtest_add_data_func_full(const char *str
, void *data
,
543 void (*fn
)(const void *),
544 GDestroyNotify data_free_func
);
548 * @testpath: Test case path
549 * @Fixture: Fixture type
550 * @tdata: Test case data
551 * @fsetup: Test case setup function
552 * @ftest: Test case function
553 * @fteardown: Test case teardown function
555 * Add a GTester testcase with the given name, data and functions.
556 * The path is prefixed with the architecture under test, as
557 * returned by qtest_get_arch().
559 #define qtest_add(testpath, Fixture, tdata, fsetup, ftest, fteardown) \
561 char *path = g_strdup_printf("/%s/%s", qtest_get_arch(), testpath); \
562 g_test_add(path, Fixture, tdata, fsetup, ftest, fteardown); \
566 void qtest_add_abrt_handler(GHookFunc fn
, const void *data
);
570 * @args: other arguments to pass to QEMU
572 * Start QEMU and assign the resulting #QTestState to a global variable.
573 * The global variable is used by "shortcut" functions documented below.
575 * Returns: #QTestState instance.
577 static inline QTestState
*qtest_start(const char *args
)
579 global_qtest
= qtest_init(args
);
586 * Shut down the QEMU process started by qtest_start().
588 static inline void qtest_end(void)
590 qtest_quit(global_qtest
);
596 * @fmt...: QMP message to send to qemu, formatted like
597 * qobject_from_jsonf_nofail(). See parse_escape() for what's
598 * supported after '%'.
600 * Sends a QMP message to QEMU and returns the response.
602 QDict
*qmp(const char *fmt
, ...) GCC_FMT_ATTR(1, 2);
606 * @fmt...: QMP message to send to qemu, formatted like
607 * qobject_from_jsonf_nofail(). See parse_escape() for what's
608 * supported after '%'.
610 * Sends a QMP message to QEMU and leaves the response in the stream.
612 void qmp_send(const char *fmt
, ...) GCC_FMT_ATTR(1, 2);
617 * Reads a QMP message from QEMU and returns the response.
619 static inline QDict
*qmp_receive(void)
621 return qtest_qmp_receive(global_qtest
);
626 * @s: #event event to wait for.
628 * Continuously polls for QMP responses until it receives the desired event.
630 static inline void qmp_eventwait(const char *event
)
632 return qtest_qmp_eventwait(global_qtest
, event
);
637 * @s: #event event to wait for.
639 * Continuously polls for QMP responses until it receives the desired event.
640 * Returns a copy of the event for further investigation.
642 static inline QDict
*qmp_eventwait_ref(const char *event
)
644 return qtest_qmp_eventwait_ref(global_qtest
, event
);
649 * @fmt...: HMP command to send to QEMU, formats arguments like sprintf().
651 * Send HMP command to QEMU via QMP's human-monitor-command.
653 * Returns: the command's output. The caller should g_free() it.
655 char *hmp(const char *fmt
, ...) GCC_FMT_ATTR(1, 2);
659 * @num: Interrupt to observe.
661 * Returns: The level of the @num interrupt.
663 static inline bool get_irq(int num
)
665 return qtest_get_irq(global_qtest
, num
);
670 * @string: QOM path of a device.
672 * Associate qtest irqs with the GPIO-in pins of the device
673 * whose path is specified by @string.
675 static inline void irq_intercept_in(const char *string
)
677 qtest_irq_intercept_in(global_qtest
, string
);
681 * qtest_irq_intercept_out:
682 * @string: QOM path of a device.
684 * Associate qtest irqs with the GPIO-out pins of the device
685 * whose path is specified by @string.
687 static inline void irq_intercept_out(const char *string
)
689 qtest_irq_intercept_out(global_qtest
, string
);
694 * @addr: I/O port to write to.
695 * @value: Value being written.
697 * Write an 8-bit value to an I/O port.
699 static inline void outb(uint16_t addr
, uint8_t value
)
701 qtest_outb(global_qtest
, addr
, value
);
706 * @addr: I/O port to write to.
707 * @value: Value being written.
709 * Write a 16-bit value to an I/O port.
711 static inline void outw(uint16_t addr
, uint16_t value
)
713 qtest_outw(global_qtest
, addr
, value
);
718 * @addr: I/O port to write to.
719 * @value: Value being written.
721 * Write a 32-bit value to an I/O port.
723 static inline void outl(uint16_t addr
, uint32_t value
)
725 qtest_outl(global_qtest
, addr
, value
);
730 * @addr: I/O port to read from.
732 * Reads an 8-bit value from an I/O port.
734 * Returns: Value read.
736 static inline uint8_t inb(uint16_t addr
)
738 return qtest_inb(global_qtest
, addr
);
743 * @addr: I/O port to read from.
745 * Reads a 16-bit value from an I/O port.
747 * Returns: Value read.
749 static inline uint16_t inw(uint16_t addr
)
751 return qtest_inw(global_qtest
, addr
);
756 * @addr: I/O port to read from.
758 * Reads a 32-bit value from an I/O port.
760 * Returns: Value read.
762 static inline uint32_t inl(uint16_t addr
)
764 return qtest_inl(global_qtest
, addr
);
769 * @addr: Guest address to write to.
770 * @value: Value being written.
772 * Writes an 8-bit value to guest memory.
774 static inline void writeb(uint64_t addr
, uint8_t value
)
776 qtest_writeb(global_qtest
, addr
, value
);
781 * @addr: Guest address to write to.
782 * @value: Value being written.
784 * Writes a 16-bit value to guest memory.
786 static inline void writew(uint64_t addr
, uint16_t value
)
788 qtest_writew(global_qtest
, addr
, value
);
793 * @addr: Guest address to write to.
794 * @value: Value being written.
796 * Writes a 32-bit value to guest memory.
798 static inline void writel(uint64_t addr
, uint32_t value
)
800 qtest_writel(global_qtest
, addr
, value
);
805 * @addr: Guest address to write to.
806 * @value: Value being written.
808 * Writes a 64-bit value to guest memory.
810 static inline void writeq(uint64_t addr
, uint64_t value
)
812 qtest_writeq(global_qtest
, addr
, value
);
817 * @addr: Guest address to read from.
819 * Reads an 8-bit value from guest memory.
821 * Returns: Value read.
823 static inline uint8_t readb(uint64_t addr
)
825 return qtest_readb(global_qtest
, addr
);
830 * @addr: Guest address to read from.
832 * Reads a 16-bit value from guest memory.
834 * Returns: Value read.
836 static inline uint16_t readw(uint64_t addr
)
838 return qtest_readw(global_qtest
, addr
);
843 * @addr: Guest address to read from.
845 * Reads a 32-bit value from guest memory.
847 * Returns: Value read.
849 static inline uint32_t readl(uint64_t addr
)
851 return qtest_readl(global_qtest
, addr
);
856 * @addr: Guest address to read from.
858 * Reads a 64-bit value from guest memory.
860 * Returns: Value read.
862 static inline uint64_t readq(uint64_t addr
)
864 return qtest_readq(global_qtest
, addr
);
869 * @addr: Guest address to read from.
870 * @data: Pointer to where memory contents will be stored.
871 * @size: Number of bytes to read.
873 * Read guest memory into a buffer.
875 static inline void memread(uint64_t addr
, void *data
, size_t size
)
877 qtest_memread(global_qtest
, addr
, data
, size
);
882 * @addr: Guest address to read from.
883 * @data: Pointer to where memory contents will be stored.
884 * @size: Number of bytes to read.
886 * Read guest memory into a buffer, receive using a base64 encoding.
888 static inline void bufread(uint64_t addr
, void *data
, size_t size
)
890 qtest_bufread(global_qtest
, addr
, data
, size
);
895 * @addr: Guest address to write to.
896 * @data: Pointer to the bytes that will be written to guest memory.
897 * @size: Number of bytes to write.
899 * Write a buffer to guest memory.
901 static inline void memwrite(uint64_t addr
, const void *data
, size_t size
)
903 qtest_memwrite(global_qtest
, addr
, data
, size
);
908 * @addr: Guest address to write to.
909 * @data: Pointer to the bytes that will be written to guest memory.
910 * @size: Number of bytes to write.
912 * Write a buffer to guest memory, transmit using a base64 encoding.
914 static inline void bufwrite(uint64_t addr
, const void *data
, size_t size
)
916 qtest_bufwrite(global_qtest
, addr
, data
, size
);
921 * @addr: Guest address to write to.
922 * @patt: Byte pattern to fill the guest memory region with.
923 * @size: Number of bytes to write.
925 * Write a pattern to guest memory.
927 static inline void qmemset(uint64_t addr
, uint8_t patt
, size_t size
)
929 qtest_memset(global_qtest
, addr
, patt
, size
);
935 * Advance the QEMU_CLOCK_VIRTUAL to the next deadline.
937 * Returns: The current value of the QEMU_CLOCK_VIRTUAL in nanoseconds.
939 static inline int64_t clock_step_next(void)
941 return qtest_clock_step_next(global_qtest
);
946 * @step: Number of nanoseconds to advance the clock by.
948 * Advance the QEMU_CLOCK_VIRTUAL by @step nanoseconds.
950 * Returns: The current value of the QEMU_CLOCK_VIRTUAL in nanoseconds.
952 static inline int64_t clock_step(int64_t step
)
954 return qtest_clock_step(global_qtest
, step
);
959 * @val: Nanoseconds value to advance the clock to.
961 * Advance the QEMU_CLOCK_VIRTUAL to @val nanoseconds since the VM was launched.
963 * Returns: The current value of the QEMU_CLOCK_VIRTUAL in nanoseconds.
965 static inline int64_t clock_set(int64_t val
)
967 return qtest_clock_set(global_qtest
, val
);
970 QDict
*qmp_fd_receive(int fd
);
971 void qmp_fd_vsend(int fd
, const char *fmt
, va_list ap
) GCC_FMT_ATTR(2, 0);
972 void qmp_fd_send(int fd
, const char *fmt
, ...) GCC_FMT_ATTR(2, 3);
973 void qmp_fd_send_raw(int fd
, const char *fmt
, ...) GCC_FMT_ATTR(2, 3);
974 void qmp_fd_vsend_raw(int fd
, const char *fmt
, va_list ap
) GCC_FMT_ATTR(2, 0);
975 QDict
*qmp_fdv(int fd
, const char *fmt
, va_list ap
) GCC_FMT_ATTR(2, 0);
976 QDict
*qmp_fd(int fd
, const char *fmt
, ...) GCC_FMT_ATTR(2, 3);
979 * qtest_cb_for_every_machine:
980 * @cb: Pointer to the callback function
981 * @skip_old_versioned: true if versioned old machine types should be skipped
983 * Call a callback function for every name of all available machines.
985 void qtest_cb_for_every_machine(void (*cb
)(const char *machine
),
986 bool skip_old_versioned
);
989 * qtest_qmp_device_add:
990 * @driver: Name of the device that should be added
991 * @id: Identification string
992 * @fmt...: QMP message to send to qemu, formatted like
993 * qobject_from_jsonf_nofail(). See parse_escape() for what's
994 * supported after '%'.
996 * Generic hot-plugging test via the device_add QMP command.
998 void qtest_qmp_device_add(const char *driver
, const char *id
, const char *fmt
,
999 ...) GCC_FMT_ATTR(3, 4);
1002 * qtest_qmp_device_del:
1003 * @id: Identification string
1005 * Generic hot-unplugging test via the device_del QMP command.
1007 void qtest_qmp_device_del(const char *id
);
1011 * @rsp: QMP response to check for error
1013 * Test @rsp for error and discard @rsp.
1014 * Returns 'true' if there is error in @rsp and 'false' otherwise.
1016 bool qmp_rsp_is_err(QDict
*rsp
);
1019 * qmp_assert_error_class:
1020 * @rsp: QMP response to check for error
1021 * @class: an error class
1023 * Assert the response has the given error class and discard @rsp.
1025 void qmp_assert_error_class(QDict
*rsp
, const char *class);
1028 * qtest_probe_child:
1029 * @s: QTestState instance to operate on.
1031 * Returns: true if the child is still alive.
1033 bool qtest_probe_child(QTestState
*s
);