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_start().
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_start().
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 * @fmt...: QMP message to send to qemu, formatted like
91 * qobject_from_jsonf_nofail(). See parse_escape() for what's
92 * supported after '%'.
94 * Sends a QMP message to QEMU and returns the response.
96 QDict
*qtest_qmp(QTestState
*s
, const char *fmt
, ...)
101 * @s: #QTestState instance to operate on.
102 * @fmt...: QMP message to send to qemu, formatted like
103 * qobject_from_jsonf_nofail(). See parse_escape() for what's
104 * supported after '%'.
106 * Sends a QMP message to QEMU and leaves the response in the stream.
108 void qtest_qmp_send(QTestState
*s
, const char *fmt
, ...)
112 * qtest_qmp_send_raw:
113 * @s: #QTestState instance to operate on.
114 * @fmt...: text to send, formatted like sprintf()
116 * Sends text to the QMP monitor verbatim. Need not be valid JSON;
117 * this is useful for negative tests.
119 void qtest_qmp_send_raw(QTestState
*s
, const char *fmt
, ...)
124 * @s: #QTestState instance to operate on.
125 * @fmt: QMP message to send to QEMU, formatted like
126 * qobject_from_jsonf_nofail(). See parse_escape() for what's
127 * supported after '%'.
128 * @ap: QMP message arguments
130 * Sends a QMP message to QEMU and returns the response.
132 QDict
*qtest_vqmp(QTestState
*s
, const char *fmt
, va_list ap
)
137 * @s: #QTestState instance to operate on.
138 * @fmt: QMP message to send to QEMU, formatted like
139 * qobject_from_jsonf_nofail(). See parse_escape() for what's
140 * supported after '%'.
141 * @ap: QMP message arguments
143 * Sends a QMP message to QEMU and leaves the response in the stream.
145 void qtest_qmp_vsend(QTestState
*s
, const char *fmt
, va_list ap
)
150 * @s: #QTestState instance to operate on.
152 * Reads a QMP message from QEMU and returns the response.
154 QDict
*qtest_qmp_receive(QTestState
*s
);
157 * qtest_qmp_eventwait:
158 * @s: #QTestState instance to operate on.
159 * @s: #event event to wait for.
161 * Continuously polls for QMP responses until it receives the desired event.
163 void qtest_qmp_eventwait(QTestState
*s
, const char *event
);
166 * qtest_qmp_eventwait_ref:
167 * @s: #QTestState instance to operate on.
168 * @s: #event event to wait for.
170 * Continuously polls for QMP responses until it receives the desired event.
171 * Returns a copy of the event for further investigation.
173 QDict
*qtest_qmp_eventwait_ref(QTestState
*s
, const char *event
);
176 * qtest_qmp_receive_success:
177 * @s: #QTestState instance to operate on
178 * @event_cb: Event callback
179 * @opaque: Argument for @event_cb
181 * Poll QMP messages until a command success response is received.
182 * If @event_cb, call it for each event received, passing @opaque,
183 * the event's name and data.
184 * Return the success response's "return" member.
186 QDict
*qtest_qmp_receive_success(QTestState
*s
,
187 void (*event_cb
)(void *opaque
,
194 * @s: #QTestState instance to operate on.
195 * @fmt...: HMP command to send to QEMU, formats arguments like sprintf().
197 * Send HMP command to QEMU via QMP's human-monitor-command.
198 * QMP events are discarded.
200 * Returns: the command's output. The caller should g_free() it.
202 char *qtest_hmp(QTestState
*s
, const char *fmt
, ...) GCC_FMT_ATTR(2, 3);
206 * @s: #QTestState instance to operate on.
207 * @fmt: HMP command to send to QEMU, formats arguments like vsprintf().
208 * @ap: HMP command arguments
210 * Send HMP command to QEMU via QMP's human-monitor-command.
211 * QMP events are discarded.
213 * Returns: the command's output. The caller should g_free() it.
215 char *qtest_vhmp(QTestState
*s
, const char *fmt
, va_list ap
)
220 * @s: #QTestState instance to operate on.
221 * @num: Interrupt to observe.
223 * Returns: The level of the @num interrupt.
225 bool qtest_get_irq(QTestState
*s
, int num
);
228 * qtest_irq_intercept_in:
229 * @s: #QTestState instance to operate on.
230 * @string: QOM path of a device.
232 * Associate qtest irqs with the GPIO-in pins of the device
233 * whose path is specified by @string.
235 void qtest_irq_intercept_in(QTestState
*s
, const char *string
);
238 * qtest_irq_intercept_out:
239 * @s: #QTestState instance to operate on.
240 * @string: QOM path of a device.
242 * Associate qtest irqs with the GPIO-out pins of the device
243 * whose path is specified by @string.
245 void qtest_irq_intercept_out(QTestState
*s
, const char *string
);
249 * @s: QTestState instance to operate on.
250 * @string: QOM path of a device
255 * Force given device/irq GPIO-in pin to the given level.
257 void qtest_set_irq_in(QTestState
*s
, const char *string
, const char *name
,
262 * @s: #QTestState instance to operate on.
263 * @addr: I/O port to write to.
264 * @value: Value being written.
266 * Write an 8-bit value to an I/O port.
268 void qtest_outb(QTestState
*s
, uint16_t addr
, uint8_t value
);
272 * @s: #QTestState instance to operate on.
273 * @addr: I/O port to write to.
274 * @value: Value being written.
276 * Write a 16-bit value to an I/O port.
278 void qtest_outw(QTestState
*s
, uint16_t addr
, uint16_t value
);
282 * @s: #QTestState instance to operate on.
283 * @addr: I/O port to write to.
284 * @value: Value being written.
286 * Write a 32-bit value to an I/O port.
288 void qtest_outl(QTestState
*s
, uint16_t addr
, uint32_t value
);
292 * @s: #QTestState instance to operate on.
293 * @addr: I/O port to read from.
295 * Returns an 8-bit value from an I/O port.
297 uint8_t qtest_inb(QTestState
*s
, uint16_t addr
);
301 * @s: #QTestState instance to operate on.
302 * @addr: I/O port to read from.
304 * Returns a 16-bit value from an I/O port.
306 uint16_t qtest_inw(QTestState
*s
, uint16_t addr
);
310 * @s: #QTestState instance to operate on.
311 * @addr: I/O port to read from.
313 * Returns a 32-bit value from an I/O port.
315 uint32_t qtest_inl(QTestState
*s
, uint16_t addr
);
319 * @s: #QTestState instance to operate on.
320 * @addr: Guest address to write to.
321 * @value: Value being written.
323 * Writes an 8-bit value to memory.
325 void qtest_writeb(QTestState
*s
, uint64_t addr
, uint8_t value
);
329 * @s: #QTestState instance to operate on.
330 * @addr: Guest address to write to.
331 * @value: Value being written.
333 * Writes a 16-bit value to memory.
335 void qtest_writew(QTestState
*s
, uint64_t addr
, uint16_t value
);
339 * @s: #QTestState instance to operate on.
340 * @addr: Guest address to write to.
341 * @value: Value being written.
343 * Writes a 32-bit value to memory.
345 void qtest_writel(QTestState
*s
, uint64_t addr
, uint32_t value
);
349 * @s: #QTestState instance to operate on.
350 * @addr: Guest address to write to.
351 * @value: Value being written.
353 * Writes a 64-bit value to memory.
355 void qtest_writeq(QTestState
*s
, uint64_t addr
, uint64_t value
);
359 * @s: #QTestState instance to operate on.
360 * @addr: Guest address to read from.
362 * Reads an 8-bit value from memory.
364 * Returns: Value read.
366 uint8_t qtest_readb(QTestState
*s
, uint64_t addr
);
370 * @s: #QTestState instance to operate on.
371 * @addr: Guest address to read from.
373 * Reads a 16-bit value from memory.
375 * Returns: Value read.
377 uint16_t qtest_readw(QTestState
*s
, uint64_t addr
);
381 * @s: #QTestState instance to operate on.
382 * @addr: Guest address to read from.
384 * Reads a 32-bit value from memory.
386 * Returns: Value read.
388 uint32_t qtest_readl(QTestState
*s
, uint64_t addr
);
392 * @s: #QTestState instance to operate on.
393 * @addr: Guest address to read from.
395 * Reads a 64-bit value from memory.
397 * Returns: Value read.
399 uint64_t qtest_readq(QTestState
*s
, uint64_t addr
);
403 * @s: #QTestState instance to operate on.
404 * @addr: Guest address to read from.
405 * @data: Pointer to where memory contents will be stored.
406 * @size: Number of bytes to read.
408 * Read guest memory into a buffer.
410 void qtest_memread(QTestState
*s
, uint64_t addr
, void *data
, size_t size
);
414 * @s: #QTestState instance to operate on.
415 * @name: name of the command to call.
416 * @nargs: Number of args.
417 * @args: Guest address to read args from.
418 * @nret: Number of return value.
419 * @ret: Guest address to write return values to.
421 * Call an RTAS function
423 uint64_t qtest_rtas_call(QTestState
*s
, const char *name
,
424 uint32_t nargs
, uint64_t args
,
425 uint32_t nret
, uint64_t ret
);
429 * @s: #QTestState instance to operate on.
430 * @addr: Guest address to read from.
431 * @data: Pointer to where memory contents will be stored.
432 * @size: Number of bytes to read.
434 * Read guest memory into a buffer and receive using a base64 encoding.
436 void qtest_bufread(QTestState
*s
, uint64_t addr
, void *data
, size_t size
);
440 * @s: #QTestState instance to operate on.
441 * @addr: Guest address to write to.
442 * @data: Pointer to the bytes that will be written to guest memory.
443 * @size: Number of bytes to write.
445 * Write a buffer to guest memory.
447 void qtest_memwrite(QTestState
*s
, uint64_t addr
, const void *data
, size_t size
);
451 * @s: #QTestState instance to operate on.
452 * @addr: Guest address to write to.
453 * @data: Pointer to the bytes that will be written to guest memory.
454 * @size: Number of bytes to write.
456 * Write a buffer to guest memory and transmit using a base64 encoding.
458 void qtest_bufwrite(QTestState
*s
, uint64_t addr
,
459 const void *data
, size_t size
);
463 * @s: #QTestState instance to operate on.
464 * @addr: Guest address to write to.
465 * @patt: Byte pattern to fill the guest memory region with.
466 * @size: Number of bytes to write.
468 * Write a pattern to guest memory.
470 void qtest_memset(QTestState
*s
, uint64_t addr
, uint8_t patt
, size_t size
);
473 * qtest_clock_step_next:
474 * @s: #QTestState instance to operate on.
476 * Advance the QEMU_CLOCK_VIRTUAL to the next deadline.
478 * Returns: The current value of the QEMU_CLOCK_VIRTUAL in nanoseconds.
480 int64_t qtest_clock_step_next(QTestState
*s
);
484 * @s: QTestState instance to operate on.
485 * @step: Number of nanoseconds to advance the clock by.
487 * Advance the QEMU_CLOCK_VIRTUAL by @step nanoseconds.
489 * Returns: The current value of the QEMU_CLOCK_VIRTUAL in nanoseconds.
491 int64_t qtest_clock_step(QTestState
*s
, int64_t step
);
495 * @s: QTestState instance to operate on.
496 * @val: Nanoseconds value to advance the clock to.
498 * Advance the QEMU_CLOCK_VIRTUAL to @val nanoseconds since the VM was launched.
500 * Returns: The current value of the QEMU_CLOCK_VIRTUAL in nanoseconds.
502 int64_t qtest_clock_set(QTestState
*s
, int64_t val
);
506 * @s: QTestState instance to operate on.
508 * Returns: True if the architecture under test has a big endian configuration.
510 bool qtest_big_endian(QTestState
*s
);
515 * Returns: The architecture for the QEMU executable under test.
517 const char *qtest_get_arch(void);
521 * @str: Test case path.
522 * @fn: Test case function
524 * Add a GTester testcase with the given name and function.
525 * The path is prefixed with the architecture under test, as
526 * returned by qtest_get_arch().
528 void qtest_add_func(const char *str
, void (*fn
)(void));
531 * qtest_add_data_func:
532 * @str: Test case path.
533 * @data: Test case data
534 * @fn: Test case function
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 void qtest_add_data_func(const char *str
, const void *data
,
541 void (*fn
)(const void *));
544 * qtest_add_data_func_full:
545 * @str: Test case path.
546 * @data: Test case data
547 * @fn: Test case function
548 * @data_free_func: GDestroyNotify for data
550 * Add a GTester testcase with the given name, data and function.
551 * The path is prefixed with the architecture under test, as
552 * returned by qtest_get_arch().
554 * @data is passed to @data_free_func() on test completion.
556 void qtest_add_data_func_full(const char *str
, void *data
,
557 void (*fn
)(const void *),
558 GDestroyNotify data_free_func
);
562 * @testpath: Test case path
563 * @Fixture: Fixture type
564 * @tdata: Test case data
565 * @fsetup: Test case setup function
566 * @ftest: Test case function
567 * @fteardown: Test case teardown function
569 * Add a GTester testcase with the given name, data and functions.
570 * The path is prefixed with the architecture under test, as
571 * returned by qtest_get_arch().
573 #define qtest_add(testpath, Fixture, tdata, fsetup, ftest, fteardown) \
575 char *path = g_strdup_printf("/%s/%s", qtest_get_arch(), testpath); \
576 g_test_add(path, Fixture, tdata, fsetup, ftest, fteardown); \
580 void qtest_add_abrt_handler(GHookFunc fn
, const void *data
);
584 * @args: other arguments to pass to QEMU
586 * Start QEMU and assign the resulting #QTestState to a global variable.
587 * The global variable is used by "shortcut" functions documented below.
589 * Returns: #QTestState instance.
591 static inline QTestState
*qtest_start(const char *args
)
593 global_qtest
= qtest_init(args
);
600 * Shut down the QEMU process started by qtest_start().
602 static inline void qtest_end(void)
607 qtest_quit(global_qtest
);
613 * @fmt...: QMP message to send to qemu, formatted like
614 * qobject_from_jsonf_nofail(). See parse_escape() for what's
615 * supported after '%'.
617 * Sends a QMP message to QEMU and returns the response.
619 QDict
*qmp(const char *fmt
, ...) GCC_FMT_ATTR(1, 2);
623 * @fmt...: QMP message to send to qemu, formatted like
624 * qobject_from_jsonf_nofail(). See parse_escape() for what's
625 * supported after '%'.
627 * Sends a QMP message to QEMU and leaves the response in the stream.
629 void qmp_send(const char *fmt
, ...) GCC_FMT_ATTR(1, 2);
634 * Reads a QMP message from QEMU and returns the response.
636 static inline QDict
*qmp_receive(void)
638 return qtest_qmp_receive(global_qtest
);
643 * @s: #event event to wait for.
645 * Continuously polls for QMP responses until it receives the desired event.
647 static inline void qmp_eventwait(const char *event
)
649 return qtest_qmp_eventwait(global_qtest
, event
);
654 * @s: #event event to wait for.
656 * Continuously polls for QMP responses until it receives the desired event.
657 * Returns a copy of the event for further investigation.
659 static inline QDict
*qmp_eventwait_ref(const char *event
)
661 return qtest_qmp_eventwait_ref(global_qtest
, event
);
666 * @fmt...: HMP command to send to QEMU, formats arguments like sprintf().
668 * Send HMP command to QEMU via QMP's human-monitor-command.
670 * Returns: the command's output. The caller should g_free() it.
672 char *hmp(const char *fmt
, ...) GCC_FMT_ATTR(1, 2);
676 * @num: Interrupt to observe.
678 * Returns: The level of the @num interrupt.
680 static inline bool get_irq(int num
)
682 return qtest_get_irq(global_qtest
, num
);
687 * @string: QOM path of a device.
689 * Associate qtest irqs with the GPIO-in pins of the device
690 * whose path is specified by @string.
692 static inline void irq_intercept_in(const char *string
)
694 qtest_irq_intercept_in(global_qtest
, string
);
698 * qtest_irq_intercept_out:
699 * @string: QOM path of a device.
701 * Associate qtest irqs with the GPIO-out pins of the device
702 * whose path is specified by @string.
704 static inline void irq_intercept_out(const char *string
)
706 qtest_irq_intercept_out(global_qtest
, string
);
711 * @addr: I/O port to write to.
712 * @value: Value being written.
714 * Write an 8-bit value to an I/O port.
716 static inline void outb(uint16_t addr
, uint8_t value
)
718 qtest_outb(global_qtest
, addr
, value
);
723 * @addr: I/O port to write to.
724 * @value: Value being written.
726 * Write a 16-bit value to an I/O port.
728 static inline void outw(uint16_t addr
, uint16_t value
)
730 qtest_outw(global_qtest
, addr
, value
);
735 * @addr: I/O port to write to.
736 * @value: Value being written.
738 * Write a 32-bit value to an I/O port.
740 static inline void outl(uint16_t addr
, uint32_t value
)
742 qtest_outl(global_qtest
, addr
, value
);
747 * @addr: I/O port to read from.
749 * Reads an 8-bit value from an I/O port.
751 * Returns: Value read.
753 static inline uint8_t inb(uint16_t addr
)
755 return qtest_inb(global_qtest
, addr
);
760 * @addr: I/O port to read from.
762 * Reads a 16-bit value from an I/O port.
764 * Returns: Value read.
766 static inline uint16_t inw(uint16_t addr
)
768 return qtest_inw(global_qtest
, addr
);
773 * @addr: I/O port to read from.
775 * Reads a 32-bit value from an I/O port.
777 * Returns: Value read.
779 static inline uint32_t inl(uint16_t addr
)
781 return qtest_inl(global_qtest
, addr
);
786 * @addr: Guest address to write to.
787 * @value: Value being written.
789 * Writes an 8-bit value to guest memory.
791 static inline void writeb(uint64_t addr
, uint8_t value
)
793 qtest_writeb(global_qtest
, addr
, value
);
798 * @addr: Guest address to write to.
799 * @value: Value being written.
801 * Writes a 16-bit value to guest memory.
803 static inline void writew(uint64_t addr
, uint16_t value
)
805 qtest_writew(global_qtest
, addr
, value
);
810 * @addr: Guest address to write to.
811 * @value: Value being written.
813 * Writes a 32-bit value to guest memory.
815 static inline void writel(uint64_t addr
, uint32_t value
)
817 qtest_writel(global_qtest
, addr
, value
);
822 * @addr: Guest address to write to.
823 * @value: Value being written.
825 * Writes a 64-bit value to guest memory.
827 static inline void writeq(uint64_t addr
, uint64_t value
)
829 qtest_writeq(global_qtest
, addr
, value
);
834 * @addr: Guest address to read from.
836 * Reads an 8-bit value from guest memory.
838 * Returns: Value read.
840 static inline uint8_t readb(uint64_t addr
)
842 return qtest_readb(global_qtest
, addr
);
847 * @addr: Guest address to read from.
849 * Reads a 16-bit value from guest memory.
851 * Returns: Value read.
853 static inline uint16_t readw(uint64_t addr
)
855 return qtest_readw(global_qtest
, addr
);
860 * @addr: Guest address to read from.
862 * Reads a 32-bit value from guest memory.
864 * Returns: Value read.
866 static inline uint32_t readl(uint64_t addr
)
868 return qtest_readl(global_qtest
, addr
);
873 * @addr: Guest address to read from.
875 * Reads a 64-bit value from guest memory.
877 * Returns: Value read.
879 static inline uint64_t readq(uint64_t addr
)
881 return qtest_readq(global_qtest
, addr
);
886 * @addr: Guest address to read from.
887 * @data: Pointer to where memory contents will be stored.
888 * @size: Number of bytes to read.
890 * Read guest memory into a buffer.
892 static inline void memread(uint64_t addr
, void *data
, size_t size
)
894 qtest_memread(global_qtest
, addr
, data
, size
);
899 * @addr: Guest address to read from.
900 * @data: Pointer to where memory contents will be stored.
901 * @size: Number of bytes to read.
903 * Read guest memory into a buffer, receive using a base64 encoding.
905 static inline void bufread(uint64_t addr
, void *data
, size_t size
)
907 qtest_bufread(global_qtest
, addr
, data
, size
);
912 * @addr: Guest address to write to.
913 * @data: Pointer to the bytes that will be written to guest memory.
914 * @size: Number of bytes to write.
916 * Write a buffer to guest memory.
918 static inline void memwrite(uint64_t addr
, const void *data
, size_t size
)
920 qtest_memwrite(global_qtest
, addr
, data
, size
);
925 * @addr: Guest address to write to.
926 * @data: Pointer to the bytes that will be written to guest memory.
927 * @size: Number of bytes to write.
929 * Write a buffer to guest memory, transmit using a base64 encoding.
931 static inline void bufwrite(uint64_t addr
, const void *data
, size_t size
)
933 qtest_bufwrite(global_qtest
, addr
, data
, size
);
938 * @addr: Guest address to write to.
939 * @patt: Byte pattern to fill the guest memory region with.
940 * @size: Number of bytes to write.
942 * Write a pattern to guest memory.
944 static inline void qmemset(uint64_t addr
, uint8_t patt
, size_t size
)
946 qtest_memset(global_qtest
, addr
, patt
, size
);
952 * Advance the QEMU_CLOCK_VIRTUAL to the next deadline.
954 * Returns: The current value of the QEMU_CLOCK_VIRTUAL in nanoseconds.
956 static inline int64_t clock_step_next(void)
958 return qtest_clock_step_next(global_qtest
);
963 * @step: Number of nanoseconds to advance the clock by.
965 * Advance the QEMU_CLOCK_VIRTUAL by @step nanoseconds.
967 * Returns: The current value of the QEMU_CLOCK_VIRTUAL in nanoseconds.
969 static inline int64_t clock_step(int64_t step
)
971 return qtest_clock_step(global_qtest
, step
);
976 * @val: Nanoseconds value to advance the clock to.
978 * Advance the QEMU_CLOCK_VIRTUAL to @val nanoseconds since the VM was launched.
980 * Returns: The current value of the QEMU_CLOCK_VIRTUAL in nanoseconds.
982 static inline int64_t clock_set(int64_t val
)
984 return qtest_clock_set(global_qtest
, val
);
987 QDict
*qmp_fd_receive(int fd
);
988 void qmp_fd_vsend(int fd
, const char *fmt
, va_list ap
) GCC_FMT_ATTR(2, 0);
989 void qmp_fd_send(int fd
, const char *fmt
, ...) GCC_FMT_ATTR(2, 3);
990 void qmp_fd_send_raw(int fd
, const char *fmt
, ...) GCC_FMT_ATTR(2, 3);
991 void qmp_fd_vsend_raw(int fd
, const char *fmt
, va_list ap
) GCC_FMT_ATTR(2, 0);
992 QDict
*qmp_fdv(int fd
, const char *fmt
, va_list ap
) GCC_FMT_ATTR(2, 0);
993 QDict
*qmp_fd(int fd
, const char *fmt
, ...) GCC_FMT_ATTR(2, 3);
996 * qtest_cb_for_every_machine:
997 * @cb: Pointer to the callback function
998 * @skip_old_versioned: true if versioned old machine types should be skipped
1000 * Call a callback function for every name of all available machines.
1002 void qtest_cb_for_every_machine(void (*cb
)(const char *machine
),
1003 bool skip_old_versioned
);
1006 * qtest_qmp_device_add:
1007 * @driver: Name of the device that should be added
1008 * @id: Identification string
1009 * @fmt...: QMP message to send to qemu, formatted like
1010 * qobject_from_jsonf_nofail(). See parse_escape() for what's
1011 * supported after '%'.
1013 * Generic hot-plugging test via the device_add QMP command.
1015 void qtest_qmp_device_add(const char *driver
, const char *id
, const char *fmt
,
1016 ...) GCC_FMT_ATTR(3, 4);
1019 * qtest_qmp_device_del:
1020 * @id: Identification string
1022 * Generic hot-unplugging test via the device_del QMP command.
1024 void qtest_qmp_device_del(const char *id
);
1028 * @rsp: QMP response to check for error
1030 * Test @rsp for error and discard @rsp.
1031 * Returns 'true' if there is error in @rsp and 'false' otherwise.
1033 bool qmp_rsp_is_err(QDict
*rsp
);
1036 * qmp_assert_error_class:
1037 * @rsp: QMP response to check for error
1038 * @class: an error class
1040 * Assert the response has the given error class and discard @rsp.
1042 void qmp_assert_error_class(QDict
*rsp
, const char *class);
1045 * qtest_probe_child:
1046 * @s: QTestState instance to operate on.
1048 * Returns: true if the child is still alive.
1050 bool qtest_probe_child(QTestState
*s
);