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
);
66 * qtest_init_with_serial:
67 * @extra_args: other arguments to pass to QEMU. CAUTION: these
68 * arguments are subject to word splitting and shell evaluation.
69 * @sock_fd: pointer to store the socket file descriptor for
70 * connection with serial.
72 * Returns: #QTestState instance.
74 QTestState
*qtest_init_with_serial(const char *extra_args
, int *sock_fd
);
78 * @s: #QTestState instance to operate on.
80 * Shut down the QEMU process associated to @s.
82 void qtest_quit(QTestState
*s
);
86 * @s: #QTestState instance to operate on.
87 * @fmt...: QMP message to send to qemu, formatted like
88 * qobject_from_jsonf_nofail(). See parse_escape() for what's
89 * supported after '%'.
91 * Sends a QMP message to QEMU and returns the response.
93 QDict
*qtest_qmp(QTestState
*s
, const char *fmt
, ...)
98 * @s: #QTestState instance to operate on.
99 * @fmt...: QMP message to send to qemu, formatted like
100 * qobject_from_jsonf_nofail(). See parse_escape() for what's
101 * supported after '%'.
103 * Sends a QMP message to QEMU and leaves the response in the stream.
105 void qtest_qmp_send(QTestState
*s
, const char *fmt
, ...)
109 * qtest_qmp_send_raw:
110 * @s: #QTestState instance to operate on.
111 * @fmt...: text to send, formatted like sprintf()
113 * Sends text to the QMP monitor verbatim. Need not be valid JSON;
114 * this is useful for negative tests.
116 void qtest_qmp_send_raw(QTestState
*s
, const char *fmt
, ...)
121 * @s: #QTestState instance to operate on.
122 * @fmt: QMP message to send to QEMU, formatted like
123 * qobject_from_jsonf_nofail(). See parse_escape() for what's
124 * supported after '%'.
125 * @ap: QMP message arguments
127 * Sends a QMP message to QEMU and returns the response.
129 QDict
*qtest_vqmp(QTestState
*s
, const char *fmt
, va_list ap
)
134 * @s: #QTestState instance to operate on.
135 * @fmt: QMP message to send to QEMU, formatted like
136 * qobject_from_jsonf_nofail(). See parse_escape() for what's
137 * supported after '%'.
138 * @ap: QMP message arguments
140 * Sends a QMP message to QEMU and leaves the response in the stream.
142 void qtest_qmp_vsend(QTestState
*s
, const char *fmt
, va_list ap
)
147 * @s: #QTestState instance to operate on.
149 * Reads a QMP message from QEMU and returns the response.
151 QDict
*qtest_qmp_receive(QTestState
*s
);
154 * qtest_qmp_eventwait:
155 * @s: #QTestState instance to operate on.
156 * @s: #event event to wait for.
158 * Continuously polls for QMP responses until it receives the desired event.
160 void qtest_qmp_eventwait(QTestState
*s
, const char *event
);
163 * qtest_qmp_eventwait_ref:
164 * @s: #QTestState instance to operate on.
165 * @s: #event event to wait for.
167 * Continuously polls for QMP responses until it receives the desired event.
168 * Returns a copy of the event for further investigation.
170 QDict
*qtest_qmp_eventwait_ref(QTestState
*s
, const char *event
);
173 * qtest_qmp_receive_success:
174 * @s: #QTestState instance to operate on
175 * @event_cb: Event callback
176 * @opaque: Argument for @event_cb
178 * Poll QMP messages until a command success response is received.
179 * If @event_cb, call it for each event received, passing @opaque,
180 * the event's name and data.
181 * Return the success response's "return" member.
183 QDict
*qtest_qmp_receive_success(QTestState
*s
,
184 void (*event_cb
)(void *opaque
,
191 * @s: #QTestState instance to operate on.
192 * @fmt...: HMP command to send to QEMU, formats arguments like sprintf().
194 * Send HMP command to QEMU via QMP's human-monitor-command.
195 * QMP events are discarded.
197 * Returns: the command's output. The caller should g_free() it.
199 char *qtest_hmp(QTestState
*s
, const char *fmt
, ...) GCC_FMT_ATTR(2, 3);
203 * @s: #QTestState instance to operate on.
204 * @fmt: HMP command to send to QEMU, formats arguments like vsprintf().
205 * @ap: HMP command arguments
207 * Send HMP command to QEMU via QMP's human-monitor-command.
208 * QMP events are discarded.
210 * Returns: the command's output. The caller should g_free() it.
212 char *qtest_vhmp(QTestState
*s
, const char *fmt
, va_list ap
)
217 * @s: #QTestState instance to operate on.
218 * @num: Interrupt to observe.
220 * Returns: The level of the @num interrupt.
222 bool qtest_get_irq(QTestState
*s
, int num
);
225 * qtest_irq_intercept_in:
226 * @s: #QTestState instance to operate on.
227 * @string: QOM path of a device.
229 * Associate qtest irqs with the GPIO-in pins of the device
230 * whose path is specified by @string.
232 void qtest_irq_intercept_in(QTestState
*s
, const char *string
);
235 * qtest_irq_intercept_out:
236 * @s: #QTestState instance to operate on.
237 * @string: QOM path of a device.
239 * Associate qtest irqs with the GPIO-out pins of the device
240 * whose path is specified by @string.
242 void qtest_irq_intercept_out(QTestState
*s
, const char *string
);
246 * @s: QTestState instance to operate on.
247 * @string: QOM path of a device
252 * Force given device/irq GPIO-in pin to the given level.
254 void qtest_set_irq_in(QTestState
*s
, const char *string
, const char *name
,
259 * @s: #QTestState instance to operate on.
260 * @addr: I/O port to write to.
261 * @value: Value being written.
263 * Write an 8-bit value to an I/O port.
265 void qtest_outb(QTestState
*s
, uint16_t addr
, uint8_t value
);
269 * @s: #QTestState instance to operate on.
270 * @addr: I/O port to write to.
271 * @value: Value being written.
273 * Write a 16-bit value to an I/O port.
275 void qtest_outw(QTestState
*s
, uint16_t addr
, uint16_t value
);
279 * @s: #QTestState instance to operate on.
280 * @addr: I/O port to write to.
281 * @value: Value being written.
283 * Write a 32-bit value to an I/O port.
285 void qtest_outl(QTestState
*s
, uint16_t addr
, uint32_t value
);
289 * @s: #QTestState instance to operate on.
290 * @addr: I/O port to read from.
292 * Returns an 8-bit value from an I/O port.
294 uint8_t qtest_inb(QTestState
*s
, uint16_t addr
);
298 * @s: #QTestState instance to operate on.
299 * @addr: I/O port to read from.
301 * Returns a 16-bit value from an I/O port.
303 uint16_t qtest_inw(QTestState
*s
, uint16_t addr
);
307 * @s: #QTestState instance to operate on.
308 * @addr: I/O port to read from.
310 * Returns a 32-bit value from an I/O port.
312 uint32_t qtest_inl(QTestState
*s
, uint16_t addr
);
316 * @s: #QTestState instance to operate on.
317 * @addr: Guest address to write to.
318 * @value: Value being written.
320 * Writes an 8-bit value to memory.
322 void qtest_writeb(QTestState
*s
, uint64_t addr
, uint8_t value
);
326 * @s: #QTestState instance to operate on.
327 * @addr: Guest address to write to.
328 * @value: Value being written.
330 * Writes a 16-bit value to memory.
332 void qtest_writew(QTestState
*s
, uint64_t addr
, uint16_t value
);
336 * @s: #QTestState instance to operate on.
337 * @addr: Guest address to write to.
338 * @value: Value being written.
340 * Writes a 32-bit value to memory.
342 void qtest_writel(QTestState
*s
, uint64_t addr
, uint32_t value
);
346 * @s: #QTestState instance to operate on.
347 * @addr: Guest address to write to.
348 * @value: Value being written.
350 * Writes a 64-bit value to memory.
352 void qtest_writeq(QTestState
*s
, uint64_t addr
, uint64_t value
);
356 * @s: #QTestState instance to operate on.
357 * @addr: Guest address to read from.
359 * Reads an 8-bit value from memory.
361 * Returns: Value read.
363 uint8_t qtest_readb(QTestState
*s
, uint64_t addr
);
367 * @s: #QTestState instance to operate on.
368 * @addr: Guest address to read from.
370 * Reads a 16-bit value from memory.
372 * Returns: Value read.
374 uint16_t qtest_readw(QTestState
*s
, uint64_t addr
);
378 * @s: #QTestState instance to operate on.
379 * @addr: Guest address to read from.
381 * Reads a 32-bit value from memory.
383 * Returns: Value read.
385 uint32_t qtest_readl(QTestState
*s
, uint64_t addr
);
389 * @s: #QTestState instance to operate on.
390 * @addr: Guest address to read from.
392 * Reads a 64-bit value from memory.
394 * Returns: Value read.
396 uint64_t qtest_readq(QTestState
*s
, uint64_t addr
);
400 * @s: #QTestState instance to operate on.
401 * @addr: Guest address to read from.
402 * @data: Pointer to where memory contents will be stored.
403 * @size: Number of bytes to read.
405 * Read guest memory into a buffer.
407 void qtest_memread(QTestState
*s
, uint64_t addr
, void *data
, size_t size
);
411 * @s: #QTestState instance to operate on.
412 * @name: name of the command to call.
413 * @nargs: Number of args.
414 * @args: Guest address to read args from.
415 * @nret: Number of return value.
416 * @ret: Guest address to write return values to.
418 * Call an RTAS function
420 uint64_t qtest_rtas_call(QTestState
*s
, const char *name
,
421 uint32_t nargs
, uint64_t args
,
422 uint32_t nret
, uint64_t ret
);
426 * @s: #QTestState instance to operate on.
427 * @addr: Guest address to read from.
428 * @data: Pointer to where memory contents will be stored.
429 * @size: Number of bytes to read.
431 * Read guest memory into a buffer and receive using a base64 encoding.
433 void qtest_bufread(QTestState
*s
, uint64_t addr
, 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.
444 void qtest_memwrite(QTestState
*s
, uint64_t addr
, const void *data
, size_t size
);
448 * @s: #QTestState instance to operate on.
449 * @addr: Guest address to write to.
450 * @data: Pointer to the bytes that will be written to guest memory.
451 * @size: Number of bytes to write.
453 * Write a buffer to guest memory and transmit using a base64 encoding.
455 void qtest_bufwrite(QTestState
*s
, uint64_t addr
,
456 const void *data
, size_t size
);
460 * @s: #QTestState instance to operate on.
461 * @addr: Guest address to write to.
462 * @patt: Byte pattern to fill the guest memory region with.
463 * @size: Number of bytes to write.
465 * Write a pattern to guest memory.
467 void qtest_memset(QTestState
*s
, uint64_t addr
, uint8_t patt
, size_t size
);
470 * qtest_clock_step_next:
471 * @s: #QTestState instance to operate on.
473 * Advance the QEMU_CLOCK_VIRTUAL to the next deadline.
475 * Returns: The current value of the QEMU_CLOCK_VIRTUAL in nanoseconds.
477 int64_t qtest_clock_step_next(QTestState
*s
);
481 * @s: QTestState instance to operate on.
482 * @step: Number of nanoseconds to advance the clock by.
484 * Advance the QEMU_CLOCK_VIRTUAL by @step nanoseconds.
486 * Returns: The current value of the QEMU_CLOCK_VIRTUAL in nanoseconds.
488 int64_t qtest_clock_step(QTestState
*s
, int64_t step
);
492 * @s: QTestState instance to operate on.
493 * @val: Nanoseconds value to advance the clock to.
495 * Advance the QEMU_CLOCK_VIRTUAL to @val nanoseconds since the VM was launched.
497 * Returns: The current value of the QEMU_CLOCK_VIRTUAL in nanoseconds.
499 int64_t qtest_clock_set(QTestState
*s
, int64_t val
);
503 * @s: QTestState instance to operate on.
505 * Returns: True if the architecture under test has a big endian configuration.
507 bool qtest_big_endian(QTestState
*s
);
512 * Returns: The architecture for the QEMU executable under test.
514 const char *qtest_get_arch(void);
518 * @str: Test case path.
519 * @fn: Test case function
521 * Add a GTester testcase with the given name and function.
522 * The path is prefixed with the architecture under test, as
523 * returned by qtest_get_arch().
525 void qtest_add_func(const char *str
, void (*fn
)(void));
528 * qtest_add_data_func:
529 * @str: Test case path.
530 * @data: Test case data
531 * @fn: Test case function
533 * Add a GTester testcase with the given name, data and function.
534 * The path is prefixed with the architecture under test, as
535 * returned by qtest_get_arch().
537 void qtest_add_data_func(const char *str
, const void *data
,
538 void (*fn
)(const void *));
541 * qtest_add_data_func_full:
542 * @str: Test case path.
543 * @data: Test case data
544 * @fn: Test case function
545 * @data_free_func: GDestroyNotify for data
547 * Add a GTester testcase with the given name, data and function.
548 * The path is prefixed with the architecture under test, as
549 * returned by qtest_get_arch().
551 * @data is passed to @data_free_func() on test completion.
553 void qtest_add_data_func_full(const char *str
, void *data
,
554 void (*fn
)(const void *),
555 GDestroyNotify data_free_func
);
559 * @testpath: Test case path
560 * @Fixture: Fixture type
561 * @tdata: Test case data
562 * @fsetup: Test case setup function
563 * @ftest: Test case function
564 * @fteardown: Test case teardown function
566 * Add a GTester testcase with the given name, data and functions.
567 * The path is prefixed with the architecture under test, as
568 * returned by qtest_get_arch().
570 #define qtest_add(testpath, Fixture, tdata, fsetup, ftest, fteardown) \
572 char *path = g_strdup_printf("/%s/%s", qtest_get_arch(), testpath); \
573 g_test_add(path, Fixture, tdata, fsetup, ftest, fteardown); \
577 void qtest_add_abrt_handler(GHookFunc fn
, const void *data
);
581 * @args: other arguments to pass to QEMU
583 * Start QEMU and assign the resulting #QTestState to a global variable.
584 * The global variable is used by "shortcut" functions documented below.
586 * Returns: #QTestState instance.
588 static inline QTestState
*qtest_start(const char *args
)
590 global_qtest
= qtest_init(args
);
597 * Shut down the QEMU process started by qtest_start().
599 static inline void qtest_end(void)
601 qtest_quit(global_qtest
);
607 * @fmt...: QMP message to send to qemu, formatted like
608 * qobject_from_jsonf_nofail(). See parse_escape() for what's
609 * supported after '%'.
611 * Sends a QMP message to QEMU and returns the response.
613 QDict
*qmp(const char *fmt
, ...) GCC_FMT_ATTR(1, 2);
617 * @fmt...: QMP message to send to qemu, formatted like
618 * qobject_from_jsonf_nofail(). See parse_escape() for what's
619 * supported after '%'.
621 * Sends a QMP message to QEMU and leaves the response in the stream.
623 void qmp_send(const char *fmt
, ...) GCC_FMT_ATTR(1, 2);
628 * Reads a QMP message from QEMU and returns the response.
630 static inline QDict
*qmp_receive(void)
632 return qtest_qmp_receive(global_qtest
);
637 * @s: #event event to wait for.
639 * Continuously polls for QMP responses until it receives the desired event.
641 static inline void qmp_eventwait(const char *event
)
643 return qtest_qmp_eventwait(global_qtest
, event
);
648 * @s: #event event to wait for.
650 * Continuously polls for QMP responses until it receives the desired event.
651 * Returns a copy of the event for further investigation.
653 static inline QDict
*qmp_eventwait_ref(const char *event
)
655 return qtest_qmp_eventwait_ref(global_qtest
, event
);
660 * @fmt...: HMP command to send to QEMU, formats arguments like sprintf().
662 * Send HMP command to QEMU via QMP's human-monitor-command.
664 * Returns: the command's output. The caller should g_free() it.
666 char *hmp(const char *fmt
, ...) GCC_FMT_ATTR(1, 2);
670 * @num: Interrupt to observe.
672 * Returns: The level of the @num interrupt.
674 static inline bool get_irq(int num
)
676 return qtest_get_irq(global_qtest
, num
);
681 * @string: QOM path of a device.
683 * Associate qtest irqs with the GPIO-in pins of the device
684 * whose path is specified by @string.
686 static inline void irq_intercept_in(const char *string
)
688 qtest_irq_intercept_in(global_qtest
, string
);
692 * qtest_irq_intercept_out:
693 * @string: QOM path of a device.
695 * Associate qtest irqs with the GPIO-out pins of the device
696 * whose path is specified by @string.
698 static inline void irq_intercept_out(const char *string
)
700 qtest_irq_intercept_out(global_qtest
, string
);
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 read from.
894 * @data: Pointer to where memory contents will be stored.
895 * @size: Number of bytes to read.
897 * Read guest memory into a buffer, receive using a base64 encoding.
899 static inline void bufread(uint64_t addr
, void *data
, size_t size
)
901 qtest_bufread(global_qtest
, addr
, data
, size
);
906 * @addr: Guest address to write to.
907 * @data: Pointer to the bytes that will be written to guest memory.
908 * @size: Number of bytes to write.
910 * Write a buffer to guest memory.
912 static inline void memwrite(uint64_t addr
, const void *data
, size_t size
)
914 qtest_memwrite(global_qtest
, addr
, data
, size
);
919 * @addr: Guest address to write to.
920 * @data: Pointer to the bytes that will be written to guest memory.
921 * @size: Number of bytes to write.
923 * Write a buffer to guest memory, transmit using a base64 encoding.
925 static inline void bufwrite(uint64_t addr
, const void *data
, size_t size
)
927 qtest_bufwrite(global_qtest
, addr
, data
, size
);
932 * @addr: Guest address to write to.
933 * @patt: Byte pattern to fill the guest memory region with.
934 * @size: Number of bytes to write.
936 * Write a pattern to guest memory.
938 static inline void qmemset(uint64_t addr
, uint8_t patt
, size_t size
)
940 qtest_memset(global_qtest
, addr
, patt
, size
);
946 * Advance the QEMU_CLOCK_VIRTUAL to the next deadline.
948 * Returns: The current value of the QEMU_CLOCK_VIRTUAL in nanoseconds.
950 static inline int64_t clock_step_next(void)
952 return qtest_clock_step_next(global_qtest
);
957 * @step: Number of nanoseconds to advance the clock by.
959 * Advance the QEMU_CLOCK_VIRTUAL by @step nanoseconds.
961 * Returns: The current value of the QEMU_CLOCK_VIRTUAL in nanoseconds.
963 static inline int64_t clock_step(int64_t step
)
965 return qtest_clock_step(global_qtest
, step
);
970 * @val: Nanoseconds value to advance the clock to.
972 * Advance the QEMU_CLOCK_VIRTUAL to @val nanoseconds since the VM was launched.
974 * Returns: The current value of the QEMU_CLOCK_VIRTUAL in nanoseconds.
976 static inline int64_t clock_set(int64_t val
)
978 return qtest_clock_set(global_qtest
, val
);
981 QDict
*qmp_fd_receive(int fd
);
982 void qmp_fd_vsend(int fd
, const char *fmt
, va_list ap
) GCC_FMT_ATTR(2, 0);
983 void qmp_fd_send(int fd
, const char *fmt
, ...) GCC_FMT_ATTR(2, 3);
984 void qmp_fd_send_raw(int fd
, const char *fmt
, ...) GCC_FMT_ATTR(2, 3);
985 void qmp_fd_vsend_raw(int fd
, const char *fmt
, va_list ap
) GCC_FMT_ATTR(2, 0);
986 QDict
*qmp_fdv(int fd
, const char *fmt
, va_list ap
) GCC_FMT_ATTR(2, 0);
987 QDict
*qmp_fd(int fd
, const char *fmt
, ...) GCC_FMT_ATTR(2, 3);
990 * qtest_cb_for_every_machine:
991 * @cb: Pointer to the callback function
992 * @skip_old_versioned: true if versioned old machine types should be skipped
994 * Call a callback function for every name of all available machines.
996 void qtest_cb_for_every_machine(void (*cb
)(const char *machine
),
997 bool skip_old_versioned
);
1000 * qtest_qmp_device_add:
1001 * @driver: Name of the device that should be added
1002 * @id: Identification string
1003 * @fmt...: QMP message to send to qemu, formatted like
1004 * qobject_from_jsonf_nofail(). See parse_escape() for what's
1005 * supported after '%'.
1007 * Generic hot-plugging test via the device_add QMP command.
1009 void qtest_qmp_device_add(const char *driver
, const char *id
, const char *fmt
,
1010 ...) GCC_FMT_ATTR(3, 4);
1013 * qtest_qmp_device_del:
1014 * @id: Identification string
1016 * Generic hot-unplugging test via the device_del QMP command.
1018 void qtest_qmp_device_del(const char *id
);
1022 * @rsp: QMP response to check for error
1024 * Test @rsp for error and discard @rsp.
1025 * Returns 'true' if there is error in @rsp and 'false' otherwise.
1027 bool qmp_rsp_is_err(QDict
*rsp
);
1030 * qmp_assert_error_class:
1031 * @rsp: QMP response to check for error
1032 * @class: an error class
1034 * Assert the response has the given error class and discard @rsp.
1036 void qmp_assert_error_class(QDict
*rsp
, const char *class);
1039 * qtest_probe_child:
1040 * @s: QTestState instance to operate on.
1042 * Returns: true if the child is still alive.
1044 bool qtest_probe_child(QTestState
*s
);