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"
24 typedef struct QTestState QTestState
;
28 * @fmt: Format for creating other arguments to pass to QEMU, formatted
31 * Convenience wrapper around qtest_init().
33 * Returns: #QTestState instance.
35 QTestState
*qtest_initf(const char *fmt
, ...) G_GNUC_PRINTF(1, 2);
39 * @fmt: Format for creating other arguments to pass to QEMU, formatted
41 * @ap: Format arguments.
43 * Convenience wrapper around qtest_init().
45 * Returns: #QTestState instance.
47 QTestState
*qtest_vinitf(const char *fmt
, va_list ap
) G_GNUC_PRINTF(1, 0);
51 * @extra_args: other arguments to pass to QEMU. CAUTION: these
52 * arguments are subject to word splitting and shell evaluation.
54 * Returns: #QTestState instance.
56 QTestState
*qtest_init(const char *extra_args
);
59 * qtest_init_without_qmp_handshake:
60 * @extra_args: other arguments to pass to QEMU. CAUTION: these
61 * arguments are subject to word splitting and shell evaluation.
63 * Returns: #QTestState instance.
65 QTestState
*qtest_init_without_qmp_handshake(const char *extra_args
);
68 * qtest_init_with_serial:
69 * @extra_args: other arguments to pass to QEMU. CAUTION: these
70 * arguments are subject to word splitting and shell evaluation.
71 * @sock_fd: pointer to store the socket file descriptor for
72 * connection with serial.
74 * Returns: #QTestState instance.
76 QTestState
*qtest_init_with_serial(const char *extra_args
, int *sock_fd
);
80 * @s: #QTestState instance to operate on.
82 * Wait for the QEMU process to terminate. It is safe to call this function
85 void qtest_wait_qemu(QTestState
*s
);
89 * @s: #QTestState instance to operate on.
91 * Kill the QEMU process and wait for it to terminate. It is safe to call this
92 * function multiple times. Normally qtest_quit() is used instead because it
93 * also frees QTestState. Use qtest_kill_qemu() when you just want to kill QEMU
94 * and qtest_quit() will be called later.
96 void qtest_kill_qemu(QTestState
*s
);
100 * @s: #QTestState instance to operate on.
102 * Shut down the QEMU process associated to @s.
104 void qtest_quit(QTestState
*s
);
109 * @s: #QTestState instance to operate on.
110 * @fds: array of file descriptors
111 * @fds_num: number of elements in @fds
112 * @fmt: QMP message to send to qemu, formatted like
113 * qobject_from_jsonf_nofail(). See parse_interpolation() for what's
114 * supported after '%'.
116 * Sends a QMP message to QEMU with fds and returns the response.
118 QDict
*qtest_qmp_fds(QTestState
*s
, int *fds
, size_t fds_num
,
119 const char *fmt
, ...)
125 * @s: #QTestState instance to operate on.
126 * @fmt: QMP message to send to qemu, formatted like
127 * qobject_from_jsonf_nofail(). See parse_interpolation() for what's
128 * supported after '%'.
130 * Sends a QMP message to QEMU and returns the response.
132 QDict
*qtest_qmp(QTestState
*s
, const char *fmt
, ...)
137 * @s: #QTestState instance to operate on.
138 * @fmt: QMP message to send to qemu, formatted like
139 * qobject_from_jsonf_nofail(). See parse_interpolation() for what's
140 * supported after '%'.
142 * Sends a QMP message to QEMU and leaves the response in the stream.
144 void qtest_qmp_send(QTestState
*s
, const char *fmt
, ...)
148 * qtest_qmp_send_raw:
149 * @s: #QTestState instance to operate on.
150 * @fmt: text to send, formatted like sprintf()
152 * Sends text to the QMP monitor verbatim. Need not be valid JSON;
153 * this is useful for negative tests.
155 void qtest_qmp_send_raw(QTestState
*s
, const char *fmt
, ...)
159 * qtest_socket_server:
160 * @socket_path: the UNIX domain socket path
162 * Create and return a listen socket file descriptor, or abort on failure.
164 int qtest_socket_server(const char *socket_path
);
169 * @s: #QTestState instance to operate on.
170 * @fds: array of file descriptors
171 * @fds_num: number of elements in @fds
172 * @fmt: QMP message to send to QEMU, formatted like
173 * qobject_from_jsonf_nofail(). See parse_interpolation() for what's
174 * supported after '%'.
175 * @ap: QMP message arguments
177 * Sends a QMP message to QEMU with fds and returns the response.
179 QDict
*qtest_vqmp_fds(QTestState
*s
, int *fds
, size_t fds_num
,
180 const char *fmt
, va_list ap
)
186 * @s: #QTestState instance to operate on.
187 * @fmt: QMP message to send to QEMU, formatted like
188 * qobject_from_jsonf_nofail(). See parse_interpolation() for what's
189 * supported after '%'.
190 * @ap: QMP message arguments
192 * Sends a QMP message to QEMU and returns the response.
194 QDict
*qtest_vqmp(QTestState
*s
, const char *fmt
, va_list ap
)
199 * qtest_qmp_vsend_fds:
200 * @s: #QTestState instance to operate on.
201 * @fds: array of file descriptors
202 * @fds_num: number of elements in @fds
203 * @fmt: QMP message to send to QEMU, formatted like
204 * qobject_from_jsonf_nofail(). See parse_interpolation() for what's
205 * supported after '%'.
206 * @ap: QMP message arguments
208 * Sends a QMP message to QEMU and leaves the response in the stream.
210 void qtest_qmp_vsend_fds(QTestState
*s
, int *fds
, size_t fds_num
,
211 const char *fmt
, va_list ap
)
217 * @s: #QTestState instance to operate on.
218 * @fmt: QMP message to send to QEMU, formatted like
219 * qobject_from_jsonf_nofail(). See parse_interpolation() for what's
220 * supported after '%'.
221 * @ap: QMP message arguments
223 * Sends a QMP message to QEMU and leaves the response in the stream.
225 void qtest_qmp_vsend(QTestState
*s
, const char *fmt
, va_list ap
)
229 * qtest_qmp_receive_dict:
230 * @s: #QTestState instance to operate on.
232 * Reads a QMP message from QEMU and returns the response.
234 QDict
*qtest_qmp_receive_dict(QTestState
*s
);
238 * @s: #QTestState instance to operate on.
240 * Reads a QMP message from QEMU and returns the response.
242 * If a callback is registered with qtest_qmp_set_event_callback,
243 * it will be invoked for every event seen, otherwise events
244 * will be buffered until a call to one of the qtest_qmp_eventwait
245 * family of functions.
247 QDict
*qtest_qmp_receive(QTestState
*s
);
250 * QTestQMPEventCallback:
251 * @s: #QTestState instance event was received on
252 * @name: name of the event type
253 * @event: #QDict for the event details
254 * @opaque: opaque data from time of callback registration
256 * This callback will be invoked whenever an event is received.
257 * If the callback returns true the event will be consumed,
258 * otherwise it will be put on the list of pending events.
259 * Pending events can be later handled by calling either
260 * qtest_qmp_eventwait or qtest_qmp_eventwait_ref.
262 * Return: true to consume the event, false to let it be queued
264 typedef bool (*QTestQMPEventCallback
)(QTestState
*s
, const char *name
,
265 QDict
*event
, void *opaque
);
268 * qtest_qmp_set_event_callback:
269 * @s: #QTestSTate instance to operate on
270 * @cb: callback to invoke for events
271 * @opaque: data to pass to @cb
273 * Register a callback to be invoked whenever an event arrives
275 void qtest_qmp_set_event_callback(QTestState
*s
,
276 QTestQMPEventCallback cb
, void *opaque
);
279 * qtest_qmp_eventwait:
280 * @s: #QTestState instance to operate on.
281 * @event: event to wait for.
283 * Continuously polls for QMP responses until it receives the desired event.
285 * Any callback registered with qtest_qmp_set_event_callback will
286 * be invoked for every event seen.
288 void qtest_qmp_eventwait(QTestState
*s
, const char *event
);
291 * qtest_qmp_eventwait_ref:
292 * @s: #QTestState instance to operate on.
293 * @event: event to wait for.
295 * Continuously polls for QMP responses until it receives the desired event.
297 * Any callback registered with qtest_qmp_set_event_callback will
298 * be invoked for every event seen.
300 * Returns a copy of the event for further investigation.
302 QDict
*qtest_qmp_eventwait_ref(QTestState
*s
, const char *event
);
305 * qtest_qmp_event_ref:
306 * @s: #QTestState instance to operate on.
307 * @event: event to return.
309 * Removes non-matching events from the buffer that was set by
310 * qtest_qmp_receive, until an event bearing the given name is found,
312 * If no event matches, clears the buffer and returns NULL.
315 QDict
*qtest_qmp_event_ref(QTestState
*s
, const char *event
);
319 * @s: #QTestState instance to operate on.
320 * @fmt: HMP command to send to QEMU, formats arguments like sprintf().
322 * Send HMP command to QEMU via QMP's human-monitor-command.
323 * QMP events are discarded.
325 * Returns: the command's output. The caller should g_free() it.
327 char *qtest_hmp(QTestState
*s
, const char *fmt
, ...) G_GNUC_PRINTF(2, 3);
331 * @s: #QTestState instance to operate on.
332 * @fmt: HMP command to send to QEMU, formats arguments like vsprintf().
333 * @ap: HMP command arguments
335 * Send HMP command to QEMU via QMP's human-monitor-command.
336 * QMP events are discarded.
338 * Returns: the command's output. The caller should g_free() it.
340 char *qtest_vhmp(QTestState
*s
, const char *fmt
, va_list ap
)
343 void qtest_module_load(QTestState
*s
, const char *prefix
, const char *libname
);
347 * @s: #QTestState instance to operate on.
348 * @num: Interrupt to observe.
350 * Returns: The level of the @num interrupt.
352 bool qtest_get_irq(QTestState
*s
, int num
);
355 * qtest_irq_intercept_in:
356 * @s: #QTestState instance to operate on.
357 * @string: QOM path of a device.
359 * Associate qtest irqs with the GPIO-in pins of the device
360 * whose path is specified by @string.
362 void qtest_irq_intercept_in(QTestState
*s
, const char *string
);
365 * qtest_irq_intercept_out:
366 * @s: #QTestState instance to operate on.
367 * @string: QOM path of a device.
369 * Associate qtest irqs with the GPIO-out pins of the device
370 * whose path is specified by @string.
372 void qtest_irq_intercept_out(QTestState
*s
, const char *string
);
375 * qtest_irq_intercept_out_named:
376 * @s: #QTestState instance to operate on.
377 * @qom_path: QOM path of a device.
378 * @name: Name of the GPIO out pin
380 * Associate a qtest irq with the named GPIO-out pin of the device
381 * whose path is specified by @string and whose name is @name.
383 void qtest_irq_intercept_out_named(QTestState
*s
, const char *qom_path
, const char *name
);
387 * @s: QTestState instance to operate on.
388 * @string: QOM path of a device
393 * Force given device/irq GPIO-in pin to the given level.
395 void qtest_set_irq_in(QTestState
*s
, const char *string
, const char *name
,
400 * @s: #QTestState instance to operate on.
401 * @addr: I/O port to write to.
402 * @value: Value being written.
404 * Write an 8-bit value to an I/O port.
406 void qtest_outb(QTestState
*s
, uint16_t addr
, uint8_t value
);
410 * @s: #QTestState instance to operate on.
411 * @addr: I/O port to write to.
412 * @value: Value being written.
414 * Write a 16-bit value to an I/O port.
416 void qtest_outw(QTestState
*s
, uint16_t addr
, uint16_t value
);
420 * @s: #QTestState instance to operate on.
421 * @addr: I/O port to write to.
422 * @value: Value being written.
424 * Write a 32-bit value to an I/O port.
426 void qtest_outl(QTestState
*s
, uint16_t addr
, uint32_t value
);
430 * @s: #QTestState instance to operate on.
431 * @addr: I/O port to read from.
433 * Returns an 8-bit value from an I/O port.
435 uint8_t qtest_inb(QTestState
*s
, uint16_t addr
);
439 * @s: #QTestState instance to operate on.
440 * @addr: I/O port to read from.
442 * Returns a 16-bit value from an I/O port.
444 uint16_t qtest_inw(QTestState
*s
, uint16_t addr
);
448 * @s: #QTestState instance to operate on.
449 * @addr: I/O port to read from.
451 * Returns a 32-bit value from an I/O port.
453 uint32_t qtest_inl(QTestState
*s
, uint16_t addr
);
457 * @s: #QTestState instance to operate on.
458 * @addr: Guest address to write to.
459 * @value: Value being written.
461 * Writes an 8-bit value to memory.
463 void qtest_writeb(QTestState
*s
, uint64_t addr
, uint8_t value
);
467 * @s: #QTestState instance to operate on.
468 * @addr: Guest address to write to.
469 * @value: Value being written.
471 * Writes a 16-bit value to memory.
473 void qtest_writew(QTestState
*s
, uint64_t addr
, uint16_t value
);
477 * @s: #QTestState instance to operate on.
478 * @addr: Guest address to write to.
479 * @value: Value being written.
481 * Writes a 32-bit value to memory.
483 void qtest_writel(QTestState
*s
, uint64_t addr
, uint32_t value
);
487 * @s: #QTestState instance to operate on.
488 * @addr: Guest address to write to.
489 * @value: Value being written.
491 * Writes a 64-bit value to memory.
493 void qtest_writeq(QTestState
*s
, uint64_t addr
, uint64_t value
);
497 * @s: #QTestState instance to operate on.
498 * @addr: Guest address to read from.
500 * Reads an 8-bit value from memory.
502 * Returns: Value read.
504 uint8_t qtest_readb(QTestState
*s
, uint64_t addr
);
508 * @s: #QTestState instance to operate on.
509 * @addr: Guest address to read from.
511 * Reads a 16-bit value from memory.
513 * Returns: Value read.
515 uint16_t qtest_readw(QTestState
*s
, uint64_t addr
);
519 * @s: #QTestState instance to operate on.
520 * @addr: Guest address to read from.
522 * Reads a 32-bit value from memory.
524 * Returns: Value read.
526 uint32_t qtest_readl(QTestState
*s
, uint64_t addr
);
530 * @s: #QTestState instance to operate on.
531 * @addr: Guest address to read from.
533 * Reads a 64-bit value from memory.
535 * Returns: Value read.
537 uint64_t qtest_readq(QTestState
*s
, uint64_t addr
);
541 * @s: #QTestState instance to operate on.
542 * @addr: Guest address to read from.
543 * @data: Pointer to where memory contents will be stored.
544 * @size: Number of bytes to read.
546 * Read guest memory into a buffer.
548 void qtest_memread(QTestState
*s
, uint64_t addr
, void *data
, size_t size
);
552 * @s: #QTestState instance to operate on.
553 * @name: name of the command to call.
554 * @nargs: Number of args.
555 * @args: Guest address to read args from.
556 * @nret: Number of return value.
557 * @ret: Guest address to write return values to.
559 * Call an RTAS function
561 uint64_t qtest_rtas_call(QTestState
*s
, const char *name
,
562 uint32_t nargs
, uint64_t args
,
563 uint32_t nret
, uint64_t ret
);
567 * @s: #QTestState instance to operate on.
568 * @addr: Guest address to read from.
569 * @data: Pointer to where memory contents will be stored.
570 * @size: Number of bytes to read.
572 * Read guest memory into a buffer and receive using a base64 encoding.
574 void qtest_bufread(QTestState
*s
, uint64_t addr
, void *data
, size_t size
);
578 * @s: #QTestState instance to operate on.
579 * @addr: Guest address to write to.
580 * @data: Pointer to the bytes that will be written to guest memory.
581 * @size: Number of bytes to write.
583 * Write a buffer to guest memory.
585 void qtest_memwrite(QTestState
*s
, uint64_t addr
, const void *data
, size_t size
);
589 * @s: #QTestState instance to operate on.
590 * @addr: Guest address to write to.
591 * @data: Pointer to the bytes that will be written to guest memory.
592 * @size: Number of bytes to write.
594 * Write a buffer to guest memory and transmit using a base64 encoding.
596 void qtest_bufwrite(QTestState
*s
, uint64_t addr
,
597 const void *data
, size_t size
);
601 * @s: #QTestState instance to operate on.
602 * @addr: Guest address to write to.
603 * @patt: Byte pattern to fill the guest memory region with.
604 * @size: Number of bytes to write.
606 * Write a pattern to guest memory.
608 void qtest_memset(QTestState
*s
, uint64_t addr
, uint8_t patt
, size_t size
);
611 * qtest_clock_step_next:
612 * @s: #QTestState instance to operate on.
614 * Advance the QEMU_CLOCK_VIRTUAL to the next deadline.
616 * Returns: The current value of the QEMU_CLOCK_VIRTUAL in nanoseconds.
618 int64_t qtest_clock_step_next(QTestState
*s
);
622 * @s: QTestState instance to operate on.
623 * @step: Number of nanoseconds to advance the clock by.
625 * Advance the QEMU_CLOCK_VIRTUAL by @step nanoseconds.
627 * Returns: The current value of the QEMU_CLOCK_VIRTUAL in nanoseconds.
629 int64_t qtest_clock_step(QTestState
*s
, int64_t step
);
633 * @s: QTestState instance to operate on.
634 * @val: Nanoseconds value to advance the clock to.
636 * Advance the QEMU_CLOCK_VIRTUAL to @val nanoseconds since the VM was launched.
638 * Returns: The current value of the QEMU_CLOCK_VIRTUAL in nanoseconds.
640 int64_t qtest_clock_set(QTestState
*s
, int64_t val
);
644 * @s: QTestState instance to operate on.
646 * Returns: True if the architecture under test has a big endian configuration.
648 bool qtest_big_endian(QTestState
*s
);
653 * Returns: The architecture for the QEMU executable under test.
655 const char *qtest_get_arch(void);
659 * @accel_name: Accelerator name to check for.
661 * Returns: true if the accelerator is built in.
663 bool qtest_has_accel(const char *accel_name
);
667 * @str: Test case path.
668 * @fn: Test case function
670 * Add a GTester testcase with the given name and function.
671 * The path is prefixed with the architecture under test, as
672 * returned by qtest_get_arch().
674 void qtest_add_func(const char *str
, void (*fn
)(void));
677 * qtest_add_data_func:
678 * @str: Test case path.
679 * @data: Test case data
680 * @fn: Test case function
682 * Add a GTester testcase with the given name, data and function.
683 * The path is prefixed with the architecture under test, as
684 * returned by qtest_get_arch().
686 void qtest_add_data_func(const char *str
, const void *data
,
687 void (*fn
)(const void *));
690 * qtest_add_data_func_full:
691 * @str: Test case path.
692 * @data: Test case data
693 * @fn: Test case function
694 * @data_free_func: GDestroyNotify for data
696 * Add a GTester testcase with the given name, data and function.
697 * The path is prefixed with the architecture under test, as
698 * returned by qtest_get_arch().
700 * @data is passed to @data_free_func() on test completion.
702 void qtest_add_data_func_full(const char *str
, void *data
,
703 void (*fn
)(const void *),
704 GDestroyNotify data_free_func
);
708 * @testpath: Test case path
709 * @Fixture: Fixture type
710 * @tdata: Test case data
711 * @fsetup: Test case setup function
712 * @ftest: Test case function
713 * @fteardown: Test case teardown function
715 * Add a GTester testcase with the given name, data and functions.
716 * The path is prefixed with the architecture under test, as
717 * returned by qtest_get_arch().
719 #define qtest_add(testpath, Fixture, tdata, fsetup, ftest, fteardown) \
721 char *path = g_strdup_printf("/%s/%s", qtest_get_arch(), testpath); \
722 g_test_add(path, Fixture, tdata, fsetup, ftest, fteardown); \
727 * qtest_add_abrt_handler:
728 * @fn: Handler function
729 * @data: Argument that is passed to the handler
731 * Add a handler function that is invoked on SIGABRT. This can be used to
732 * terminate processes and perform other cleanup. The handler can be removed
733 * with qtest_remove_abrt_handler().
735 void qtest_add_abrt_handler(GHookFunc fn
, const void *data
);
738 * qtest_remove_abrt_handler:
739 * @data: Argument previously passed to qtest_add_abrt_handler()
741 * Remove an abrt handler that was previously added with
742 * qtest_add_abrt_handler().
744 void qtest_remove_abrt_handler(void *data
);
747 * qtest_vqmp_assert_success_ref:
748 * @qts: QTestState instance to operate on
749 * @fmt: QMP message to send to qemu, formatted like
750 * qobject_from_jsonf_nofail(). See parse_interpolation() for what's
751 * supported after '%'.
752 * @args: variable arguments for @fmt
754 * Sends a QMP message to QEMU, asserts that a 'return' key is present in
755 * the response, and returns the response.
757 QDict
*qtest_vqmp_assert_success_ref(QTestState
*qts
,
758 const char *fmt
, va_list args
)
762 * qtest_vqmp_assert_success:
763 * @qts: QTestState instance to operate on
764 * @fmt: QMP message to send to qemu, formatted like
765 * qobject_from_jsonf_nofail(). See parse_interpolation() for what's
766 * supported after '%'.
767 * @args: variable arguments for @fmt
769 * Sends a QMP message to QEMU and asserts that a 'return' key is present in
772 void qtest_vqmp_assert_success(QTestState
*qts
,
773 const char *fmt
, va_list args
)
778 * qtest_vqmp_fds_assert_success_ref:
779 * @qts: QTestState instance to operate on
780 * @fds: the file descriptors to send
781 * @nfds: number of @fds to send
782 * @fmt: QMP message to send to qemu, formatted like
783 * qobject_from_jsonf_nofail(). See parse_interpolation() for what's
784 * supported after '%'.
785 * @args: variable arguments for @fmt
787 * Sends a QMP message with file descriptors to QEMU,
788 * asserts that a 'return' key is present in the response,
789 * and returns the response.
791 QDict
*qtest_vqmp_fds_assert_success_ref(QTestState
*qts
, int *fds
, size_t nfds
,
792 const char *fmt
, va_list args
)
796 * qtest_vqmp_fds_assert_success:
797 * @qts: QTestState instance to operate on
798 * @fds: the file descriptors to send
799 * @nfds: number of @fds to send
800 * @fmt: QMP message to send to qemu, formatted like
801 * qobject_from_jsonf_nofail(). See parse_interpolation() for what's
802 * supported after '%'.
803 * @args: variable arguments for @fmt
805 * Sends a QMP message with file descriptors to QEMU and
806 * asserts that a 'return' key is present in the response.
808 void qtest_vqmp_fds_assert_success(QTestState
*qts
, int *fds
, size_t nfds
,
809 const char *fmt
, va_list args
)
814 * qtest_qmp_assert_success_ref:
815 * @qts: QTestState instance to operate on
816 * @fmt: QMP message to send to qemu, formatted like
817 * qobject_from_jsonf_nofail(). See parse_interpolation() for what's
818 * supported after '%'.
820 * Sends a QMP message to QEMU, asserts that a 'return' key is present in
821 * the response, and returns the response.
823 QDict
*qtest_qmp_assert_success_ref(QTestState
*qts
, const char *fmt
, ...)
827 * qtest_qmp_assert_success:
828 * @qts: QTestState instance to operate on
829 * @fmt: QMP message to send to qemu, formatted like
830 * qobject_from_jsonf_nofail(). See parse_interpolation() for what's
831 * supported after '%'.
833 * Sends a QMP message to QEMU and asserts that a 'return' key is present in
836 void qtest_qmp_assert_success(QTestState
*qts
, const char *fmt
, ...)
841 * qtest_qmp_fd_assert_success_ref:
842 * @qts: QTestState instance to operate on
843 * @fds: the file descriptors to send
844 * @nfds: number of @fds to send
845 * @fmt: QMP message to send to qemu, formatted like
846 * qobject_from_jsonf_nofail(). See parse_interpolation() for what's
847 * supported after '%'.
849 * Sends a QMP message with file descriptors to QEMU,
850 * asserts that a 'return' key is present in the response,
851 * and returns the response.
853 QDict
*qtest_qmp_fds_assert_success_ref(QTestState
*qts
, int *fds
, size_t nfds
,
854 const char *fmt
, ...)
858 * qtest_qmp_fd_assert_success:
859 * @qts: QTestState instance to operate on
860 * @fds: the file descriptors to send
861 * @nfds: number of @fds to send
862 * @fmt: QMP message to send to qemu, formatted like
863 * qobject_from_jsonf_nofail(). See parse_interpolation() for what's
864 * supported after '%'.
866 * Sends a QMP message with file descriptors to QEMU and
867 * asserts that a 'return' key is present in the response.
869 void qtest_qmp_fds_assert_success(QTestState
*qts
, int *fds
, size_t nfds
,
870 const char *fmt
, ...)
875 * qtest_cb_for_every_machine:
876 * @cb: Pointer to the callback function
877 * @skip_old_versioned: true if versioned old machine types should be skipped
879 * Call a callback function for every name of all available machines.
881 void qtest_cb_for_every_machine(void (*cb
)(const char *machine
),
882 bool skip_old_versioned
);
886 * @machine: The machine to look for
888 * Returns: true if the machine is available in the target binary.
890 bool qtest_has_machine(const char *machine
);
894 * @device: The device to look for
896 * Returns: true if the device is available in the target binary.
898 bool qtest_has_device(const char *device
);
901 * qtest_qmp_device_add_qdict:
902 * @qts: QTestState instance to operate on
903 * @drv: Name of the device that should be added
904 * @arguments: QDict with properties for the device to initialize
906 * Generic hot-plugging test via the device_add QMP command with properties
907 * supplied in form of QDict. Use NULL for empty properties list.
909 void qtest_qmp_device_add_qdict(QTestState
*qts
, const char *drv
,
910 const QDict
*arguments
);
913 * qtest_qmp_device_add:
914 * @qts: QTestState instance to operate on
915 * @driver: Name of the device that should be added
916 * @id: Identification string
917 * @fmt: QMP message to send to qemu, formatted like
918 * qobject_from_jsonf_nofail(). See parse_interpolation() for what's
919 * supported after '%'.
921 * Generic hot-plugging test via the device_add QMP command.
923 void qtest_qmp_device_add(QTestState
*qts
, const char *driver
, const char *id
,
924 const char *fmt
, ...) G_GNUC_PRINTF(4, 5);
927 * qtest_qmp_add_client:
928 * @qts: QTestState instance to operate on
929 * @protocol: the protocol to add to
930 * @fd: the client file-descriptor
932 * Call QMP ``getfd`` (on Windows ``get-win32-socket``) followed by
933 * ``add_client`` with the given @fd.
935 void qtest_qmp_add_client(QTestState
*qts
, const char *protocol
, int fd
);
938 * qtest_qmp_device_del_send:
939 * @qts: QTestState instance to operate on
940 * @id: Identification string
942 * Generic hot-unplugging test via the device_del QMP command.
944 void qtest_qmp_device_del_send(QTestState
*qts
, const char *id
);
947 * qtest_qmp_device_del:
948 * @qts: QTestState instance to operate on
949 * @id: Identification string
951 * Generic hot-unplugging test via the device_del QMP command.
952 * Waiting for command completion event.
954 void qtest_qmp_device_del(QTestState
*qts
, const char *id
);
958 * @s: QTestState instance to operate on.
960 * Returns: true if the child is still alive.
962 bool qtest_probe_child(QTestState
*s
);
965 * qtest_set_expected_status:
966 * @s: QTestState instance to operate on.
967 * @status: an expected exit status.
969 * Set expected exit status of the child.
971 void qtest_set_expected_status(QTestState
*s
, int status
);
973 QTestState
*qtest_inproc_init(QTestState
**s
, bool log
, const char* arch
,
974 void (*send
)(void*, const char*));
976 void qtest_client_inproc_recv(void *opaque
, const char *str
);
979 * qtest_qom_set_bool:
980 * @s: QTestState instance to operate on.
981 * @path: Path to the property being set.
982 * @property: Property being set.
983 * @value: Value to set the property.
985 * Set the property with passed in value.
987 void qtest_qom_set_bool(QTestState
*s
, const char *path
, const char *property
,
991 * qtest_qom_get_bool:
992 * @s: QTestState instance to operate on.
993 * @path: Path to the property being retrieved.
994 * @property: Property from where the value is being retrieved.
996 * Returns: Value retrieved from property.
998 bool qtest_qom_get_bool(QTestState
*s
, const char *path
, const char *property
);
1002 * @s: QTestState instance to operate on.
1004 * Returns: the PID of the QEMU process, or <= 0
1006 pid_t
qtest_pid(QTestState
*s
);
1011 * Returns: true if "qemu-img" is available.
1013 bool have_qemu_img(void);
1017 * @file: File name of the image that should be created
1018 * @fmt: Format, e.g. "qcow2" or "raw"
1019 * @size_mb: Size of the image in megabytes
1021 * Create a disk image with qemu-img. Note that the QTEST_QEMU_IMG
1022 * environment variable must point to the qemu-img file.
1024 * Returns: true if the image has been created successfully.
1026 bool mkimg(const char *file
, const char *fmt
, unsigned size_mb
);