target/arm: Implement AArch32 HCR and HCR2
[qemu.git] / tests / libqtest.h
blob1159b73d15e27b7eb83230248daf3b30fc32fe27
1 /*
2 * QTest
4 * Copyright IBM, Corp. 2012
5 * Copyright Red Hat, Inc. 2012
6 * Copyright SUSE LINUX Products GmbH 2013
8 * Authors:
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.
17 #ifndef LIBQTEST_H
18 #define LIBQTEST_H
20 typedef struct QTestState QTestState;
22 extern QTestState *global_qtest;
24 /**
25 * qtest_initf:
26 * @fmt...: Format for creating other arguments to pass to QEMU, formatted
27 * like sprintf().
29 * Convenience wrapper around qtest_start().
31 * Returns: #QTestState instance.
33 QTestState *qtest_initf(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
35 /**
36 * qtest_vinitf:
37 * @fmt: Format for creating other arguments to pass to QEMU, formatted
38 * like vsprintf().
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);
47 /**
48 * qtest_init:
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);
56 /**
57 * qtest_init_without_qmp_handshake:
58 * @use_oob: true to have the server advertise OOB support
59 * @extra_args: other arguments to pass to QEMU. CAUTION: these
60 * arguments are subject to word splitting and shell evaluation.
62 * Returns: #QTestState instance.
64 QTestState *qtest_init_without_qmp_handshake(bool use_oob,
65 const char *extra_args);
67 /**
68 * qtest_quit:
69 * @s: #QTestState instance to operate on.
71 * Shut down the QEMU process associated to @s.
73 void qtest_quit(QTestState *s);
75 /**
76 * qtest_qmp:
77 * @s: #QTestState instance to operate on.
78 * @fmt...: QMP message to send to qemu, formatted like
79 * qobject_from_jsonf_nofail(). See parse_escape() for what's
80 * supported after '%'.
82 * Sends a QMP message to QEMU and returns the response.
84 QDict *qtest_qmp(QTestState *s, const char *fmt, ...)
85 GCC_FMT_ATTR(2, 3);
87 /**
88 * qtest_qmp_send:
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 leaves the response in the stream.
96 void qtest_qmp_send(QTestState *s, const char *fmt, ...)
97 GCC_FMT_ATTR(2, 3);
99 /**
100 * qtest_qmpv:
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 '%'.
105 * @ap: QMP message arguments
107 * Sends a QMP message to QEMU and returns the response.
109 QDict *qtest_vqmp(QTestState *s, const char *fmt, va_list ap)
110 GCC_FMT_ATTR(2, 0);
113 * qtest_qmp_vsend:
114 * @s: #QTestState instance to operate on.
115 * @fmt: QMP message to send to QEMU, formatted like
116 * qobject_from_jsonf_nofail(). See parse_escape() for what's
117 * supported after '%'.
118 * @ap: QMP message arguments
120 * Sends a QMP message to QEMU and leaves the response in the stream.
122 void qtest_qmp_vsend(QTestState *s, const char *fmt, va_list ap)
123 GCC_FMT_ATTR(2, 0);
126 * qtest_receive:
127 * @s: #QTestState instance to operate on.
129 * Reads a QMP message from QEMU and returns the response.
131 QDict *qtest_qmp_receive(QTestState *s);
134 * qtest_qmp_eventwait:
135 * @s: #QTestState instance to operate on.
136 * @s: #event event to wait for.
138 * Continuously polls for QMP responses until it receives the desired event.
140 void qtest_qmp_eventwait(QTestState *s, const char *event);
143 * qtest_qmp_eventwait_ref:
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.
148 * Returns a copy of the event for further investigation.
150 QDict *qtest_qmp_eventwait_ref(QTestState *s, const char *event);
153 * qtest_qmp_receive_success:
154 * @s: #QTestState instance to operate on
155 * @event_cb: Event callback
156 * @opaque: Argument for @event_cb
158 * Poll QMP messages until a command success response is received.
159 * If @event_cb, call it for each event received, passing @opaque,
160 * the event's name and data.
161 * Return the success response's "return" member.
163 QDict *qtest_qmp_receive_success(QTestState *s,
164 void (*event_cb)(void *opaque,
165 const char *name,
166 QDict *data),
167 void *opaque);
170 * qtest_hmp:
171 * @s: #QTestState instance to operate on.
172 * @fmt...: HMP command to send to QEMU, formats arguments like sprintf().
174 * Send HMP command to QEMU via QMP's human-monitor-command.
175 * QMP events are discarded.
177 * Returns: the command's output. The caller should g_free() it.
179 char *qtest_hmp(QTestState *s, const char *fmt, ...) GCC_FMT_ATTR(2, 3);
182 * qtest_hmpv:
183 * @s: #QTestState instance to operate on.
184 * @fmt: HMP command to send to QEMU, formats arguments like vsprintf().
185 * @ap: HMP command arguments
187 * Send HMP command to QEMU via QMP's human-monitor-command.
188 * QMP events are discarded.
190 * Returns: the command's output. The caller should g_free() it.
192 char *qtest_vhmp(QTestState *s, const char *fmt, va_list ap)
193 GCC_FMT_ATTR(2, 0);
196 * qtest_get_irq:
197 * @s: #QTestState instance to operate on.
198 * @num: Interrupt to observe.
200 * Returns: The level of the @num interrupt.
202 bool qtest_get_irq(QTestState *s, int num);
205 * qtest_irq_intercept_in:
206 * @s: #QTestState instance to operate on.
207 * @string: QOM path of a device.
209 * Associate qtest irqs with the GPIO-in pins of the device
210 * whose path is specified by @string.
212 void qtest_irq_intercept_in(QTestState *s, const char *string);
215 * qtest_irq_intercept_out:
216 * @s: #QTestState instance to operate on.
217 * @string: QOM path of a device.
219 * Associate qtest irqs with the GPIO-out pins of the device
220 * whose path is specified by @string.
222 void qtest_irq_intercept_out(QTestState *s, const char *string);
225 * qtest_outb:
226 * @s: #QTestState instance to operate on.
227 * @addr: I/O port to write to.
228 * @value: Value being written.
230 * Write an 8-bit value to an I/O port.
232 void qtest_outb(QTestState *s, uint16_t addr, uint8_t value);
235 * qtest_outw:
236 * @s: #QTestState instance to operate on.
237 * @addr: I/O port to write to.
238 * @value: Value being written.
240 * Write a 16-bit value to an I/O port.
242 void qtest_outw(QTestState *s, uint16_t addr, uint16_t value);
245 * qtest_outl:
246 * @s: #QTestState instance to operate on.
247 * @addr: I/O port to write to.
248 * @value: Value being written.
250 * Write a 32-bit value to an I/O port.
252 void qtest_outl(QTestState *s, uint16_t addr, uint32_t value);
255 * qtest_inb:
256 * @s: #QTestState instance to operate on.
257 * @addr: I/O port to read from.
259 * Returns an 8-bit value from an I/O port.
261 uint8_t qtest_inb(QTestState *s, uint16_t addr);
264 * qtest_inw:
265 * @s: #QTestState instance to operate on.
266 * @addr: I/O port to read from.
268 * Returns a 16-bit value from an I/O port.
270 uint16_t qtest_inw(QTestState *s, uint16_t addr);
273 * qtest_inl:
274 * @s: #QTestState instance to operate on.
275 * @addr: I/O port to read from.
277 * Returns a 32-bit value from an I/O port.
279 uint32_t qtest_inl(QTestState *s, uint16_t addr);
282 * qtest_writeb:
283 * @s: #QTestState instance to operate on.
284 * @addr: Guest address to write to.
285 * @value: Value being written.
287 * Writes an 8-bit value to memory.
289 void qtest_writeb(QTestState *s, uint64_t addr, uint8_t value);
292 * qtest_writew:
293 * @s: #QTestState instance to operate on.
294 * @addr: Guest address to write to.
295 * @value: Value being written.
297 * Writes a 16-bit value to memory.
299 void qtest_writew(QTestState *s, uint64_t addr, uint16_t value);
302 * qtest_writel:
303 * @s: #QTestState instance to operate on.
304 * @addr: Guest address to write to.
305 * @value: Value being written.
307 * Writes a 32-bit value to memory.
309 void qtest_writel(QTestState *s, uint64_t addr, uint32_t value);
312 * qtest_writeq:
313 * @s: #QTestState instance to operate on.
314 * @addr: Guest address to write to.
315 * @value: Value being written.
317 * Writes a 64-bit value to memory.
319 void qtest_writeq(QTestState *s, uint64_t addr, uint64_t value);
322 * qtest_readb:
323 * @s: #QTestState instance to operate on.
324 * @addr: Guest address to read from.
326 * Reads an 8-bit value from memory.
328 * Returns: Value read.
330 uint8_t qtest_readb(QTestState *s, uint64_t addr);
333 * qtest_readw:
334 * @s: #QTestState instance to operate on.
335 * @addr: Guest address to read from.
337 * Reads a 16-bit value from memory.
339 * Returns: Value read.
341 uint16_t qtest_readw(QTestState *s, uint64_t addr);
344 * qtest_readl:
345 * @s: #QTestState instance to operate on.
346 * @addr: Guest address to read from.
348 * Reads a 32-bit value from memory.
350 * Returns: Value read.
352 uint32_t qtest_readl(QTestState *s, uint64_t addr);
355 * qtest_readq:
356 * @s: #QTestState instance to operate on.
357 * @addr: Guest address to read from.
359 * Reads a 64-bit value from memory.
361 * Returns: Value read.
363 uint64_t qtest_readq(QTestState *s, uint64_t addr);
366 * qtest_memread:
367 * @s: #QTestState instance to operate on.
368 * @addr: Guest address to read from.
369 * @data: Pointer to where memory contents will be stored.
370 * @size: Number of bytes to read.
372 * Read guest memory into a buffer.
374 void qtest_memread(QTestState *s, uint64_t addr, void *data, size_t size);
377 * qtest_rtas_call:
378 * @s: #QTestState instance to operate on.
379 * @name: name of the command to call.
380 * @nargs: Number of args.
381 * @args: Guest address to read args from.
382 * @nret: Number of return value.
383 * @ret: Guest address to write return values to.
385 * Call an RTAS function
387 uint64_t qtest_rtas_call(QTestState *s, const char *name,
388 uint32_t nargs, uint64_t args,
389 uint32_t nret, uint64_t ret);
392 * qtest_bufread:
393 * @s: #QTestState instance to operate on.
394 * @addr: Guest address to read from.
395 * @data: Pointer to where memory contents will be stored.
396 * @size: Number of bytes to read.
398 * Read guest memory into a buffer and receive using a base64 encoding.
400 void qtest_bufread(QTestState *s, uint64_t addr, void *data, size_t size);
403 * qtest_memwrite:
404 * @s: #QTestState instance to operate on.
405 * @addr: Guest address to write to.
406 * @data: Pointer to the bytes that will be written to guest memory.
407 * @size: Number of bytes to write.
409 * Write a buffer to guest memory.
411 void qtest_memwrite(QTestState *s, uint64_t addr, const void *data, size_t size);
414 * qtest_bufwrite:
415 * @s: #QTestState instance to operate on.
416 * @addr: Guest address to write to.
417 * @data: Pointer to the bytes that will be written to guest memory.
418 * @size: Number of bytes to write.
420 * Write a buffer to guest memory and transmit using a base64 encoding.
422 void qtest_bufwrite(QTestState *s, uint64_t addr,
423 const void *data, size_t size);
426 * qtest_memset:
427 * @s: #QTestState instance to operate on.
428 * @addr: Guest address to write to.
429 * @patt: Byte pattern to fill the guest memory region with.
430 * @size: Number of bytes to write.
432 * Write a pattern to guest memory.
434 void qtest_memset(QTestState *s, uint64_t addr, uint8_t patt, size_t size);
437 * qtest_clock_step_next:
438 * @s: #QTestState instance to operate on.
440 * Advance the QEMU_CLOCK_VIRTUAL to the next deadline.
442 * Returns: The current value of the QEMU_CLOCK_VIRTUAL in nanoseconds.
444 int64_t qtest_clock_step_next(QTestState *s);
447 * qtest_clock_step:
448 * @s: QTestState instance to operate on.
449 * @step: Number of nanoseconds to advance the clock by.
451 * Advance the QEMU_CLOCK_VIRTUAL by @step nanoseconds.
453 * Returns: The current value of the QEMU_CLOCK_VIRTUAL in nanoseconds.
455 int64_t qtest_clock_step(QTestState *s, int64_t step);
458 * qtest_clock_set:
459 * @s: QTestState instance to operate on.
460 * @val: Nanoseconds value to advance the clock to.
462 * Advance the QEMU_CLOCK_VIRTUAL to @val nanoseconds since the VM was launched.
464 * Returns: The current value of the QEMU_CLOCK_VIRTUAL in nanoseconds.
466 int64_t qtest_clock_set(QTestState *s, int64_t val);
469 * qtest_big_endian:
470 * @s: QTestState instance to operate on.
472 * Returns: True if the architecture under test has a big endian configuration.
474 bool qtest_big_endian(QTestState *s);
477 * qtest_get_arch:
479 * Returns: The architecture for the QEMU executable under test.
481 const char *qtest_get_arch(void);
484 * qtest_add_func:
485 * @str: Test case path.
486 * @fn: Test case function
488 * Add a GTester testcase with the given name and function.
489 * The path is prefixed with the architecture under test, as
490 * returned by qtest_get_arch().
492 void qtest_add_func(const char *str, void (*fn)(void));
495 * qtest_add_data_func:
496 * @str: Test case path.
497 * @data: Test case data
498 * @fn: Test case function
500 * Add a GTester testcase with the given name, data and function.
501 * The path is prefixed with the architecture under test, as
502 * returned by qtest_get_arch().
504 void qtest_add_data_func(const char *str, const void *data,
505 void (*fn)(const void *));
508 * qtest_add_data_func_full:
509 * @str: Test case path.
510 * @data: Test case data
511 * @fn: Test case function
512 * @data_free_func: GDestroyNotify for data
514 * Add a GTester testcase with the given name, data and function.
515 * The path is prefixed with the architecture under test, as
516 * returned by qtest_get_arch().
518 * @data is passed to @data_free_func() on test completion.
520 void qtest_add_data_func_full(const char *str, void *data,
521 void (*fn)(const void *),
522 GDestroyNotify data_free_func);
525 * qtest_add:
526 * @testpath: Test case path
527 * @Fixture: Fixture type
528 * @tdata: Test case data
529 * @fsetup: Test case setup function
530 * @ftest: Test case function
531 * @fteardown: Test case teardown function
533 * Add a GTester testcase with the given name, data and functions.
534 * The path is prefixed with the architecture under test, as
535 * returned by qtest_get_arch().
537 #define qtest_add(testpath, Fixture, tdata, fsetup, ftest, fteardown) \
538 do { \
539 char *path = g_strdup_printf("/%s/%s", qtest_get_arch(), testpath); \
540 g_test_add(path, Fixture, tdata, fsetup, ftest, fteardown); \
541 g_free(path); \
542 } while (0)
544 void qtest_add_abrt_handler(GHookFunc fn, const void *data);
547 * qtest_start:
548 * @args: other arguments to pass to QEMU
550 * Start QEMU and assign the resulting #QTestState to a global variable.
551 * The global variable is used by "shortcut" functions documented below.
553 * Returns: #QTestState instance.
555 static inline QTestState *qtest_start(const char *args)
557 global_qtest = qtest_init(args);
558 return global_qtest;
562 * qtest_end:
564 * Shut down the QEMU process started by qtest_start().
566 static inline void qtest_end(void)
568 qtest_quit(global_qtest);
569 global_qtest = NULL;
573 * qmp:
574 * @fmt...: QMP message to send to qemu, formatted like
575 * qobject_from_jsonf_nofail(). See parse_escape() for what's
576 * supported after '%'.
578 * Sends a QMP message to QEMU and returns the response.
580 QDict *qmp(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
583 * qmp_send:
584 * @fmt...: QMP message to send to qemu, formatted like
585 * qobject_from_jsonf_nofail(). See parse_escape() for what's
586 * supported after '%'.
588 * Sends a QMP message to QEMU and leaves the response in the stream.
590 void qmp_send(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
593 * qmp_receive:
595 * Reads a QMP message from QEMU and returns the response.
597 static inline QDict *qmp_receive(void)
599 return qtest_qmp_receive(global_qtest);
603 * qmp_eventwait:
604 * @s: #event event to wait for.
606 * Continuously polls for QMP responses until it receives the desired event.
608 static inline void qmp_eventwait(const char *event)
610 return qtest_qmp_eventwait(global_qtest, event);
614 * qmp_eventwait_ref:
615 * @s: #event event to wait for.
617 * Continuously polls for QMP responses until it receives the desired event.
618 * Returns a copy of the event for further investigation.
620 static inline QDict *qmp_eventwait_ref(const char *event)
622 return qtest_qmp_eventwait_ref(global_qtest, event);
626 * hmp:
627 * @fmt...: HMP command to send to QEMU, formats arguments like sprintf().
629 * Send HMP command to QEMU via QMP's human-monitor-command.
631 * Returns: the command's output. The caller should g_free() it.
633 char *hmp(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
636 * get_irq:
637 * @num: Interrupt to observe.
639 * Returns: The level of the @num interrupt.
641 static inline bool get_irq(int num)
643 return qtest_get_irq(global_qtest, num);
647 * irq_intercept_in:
648 * @string: QOM path of a device.
650 * Associate qtest irqs with the GPIO-in pins of the device
651 * whose path is specified by @string.
653 static inline void irq_intercept_in(const char *string)
655 qtest_irq_intercept_in(global_qtest, string);
659 * qtest_irq_intercept_out:
660 * @string: QOM path of a device.
662 * Associate qtest irqs with the GPIO-out pins of the device
663 * whose path is specified by @string.
665 static inline void irq_intercept_out(const char *string)
667 qtest_irq_intercept_out(global_qtest, string);
671 * outb:
672 * @addr: I/O port to write to.
673 * @value: Value being written.
675 * Write an 8-bit value to an I/O port.
677 static inline void outb(uint16_t addr, uint8_t value)
679 qtest_outb(global_qtest, addr, value);
683 * outw:
684 * @addr: I/O port to write to.
685 * @value: Value being written.
687 * Write a 16-bit value to an I/O port.
689 static inline void outw(uint16_t addr, uint16_t value)
691 qtest_outw(global_qtest, addr, value);
695 * outl:
696 * @addr: I/O port to write to.
697 * @value: Value being written.
699 * Write a 32-bit value to an I/O port.
701 static inline void outl(uint16_t addr, uint32_t value)
703 qtest_outl(global_qtest, addr, value);
707 * inb:
708 * @addr: I/O port to read from.
710 * Reads an 8-bit value from an I/O port.
712 * Returns: Value read.
714 static inline uint8_t inb(uint16_t addr)
716 return qtest_inb(global_qtest, addr);
720 * inw:
721 * @addr: I/O port to read from.
723 * Reads a 16-bit value from an I/O port.
725 * Returns: Value read.
727 static inline uint16_t inw(uint16_t addr)
729 return qtest_inw(global_qtest, addr);
733 * inl:
734 * @addr: I/O port to read from.
736 * Reads a 32-bit value from an I/O port.
738 * Returns: Value read.
740 static inline uint32_t inl(uint16_t addr)
742 return qtest_inl(global_qtest, addr);
746 * writeb:
747 * @addr: Guest address to write to.
748 * @value: Value being written.
750 * Writes an 8-bit value to guest memory.
752 static inline void writeb(uint64_t addr, uint8_t value)
754 qtest_writeb(global_qtest, addr, value);
758 * writew:
759 * @addr: Guest address to write to.
760 * @value: Value being written.
762 * Writes a 16-bit value to guest memory.
764 static inline void writew(uint64_t addr, uint16_t value)
766 qtest_writew(global_qtest, addr, value);
770 * writel:
771 * @addr: Guest address to write to.
772 * @value: Value being written.
774 * Writes a 32-bit value to guest memory.
776 static inline void writel(uint64_t addr, uint32_t value)
778 qtest_writel(global_qtest, addr, value);
782 * writeq:
783 * @addr: Guest address to write to.
784 * @value: Value being written.
786 * Writes a 64-bit value to guest memory.
788 static inline void writeq(uint64_t addr, uint64_t value)
790 qtest_writeq(global_qtest, addr, value);
794 * readb:
795 * @addr: Guest address to read from.
797 * Reads an 8-bit value from guest memory.
799 * Returns: Value read.
801 static inline uint8_t readb(uint64_t addr)
803 return qtest_readb(global_qtest, addr);
807 * readw:
808 * @addr: Guest address to read from.
810 * Reads a 16-bit value from guest memory.
812 * Returns: Value read.
814 static inline uint16_t readw(uint64_t addr)
816 return qtest_readw(global_qtest, addr);
820 * readl:
821 * @addr: Guest address to read from.
823 * Reads a 32-bit value from guest memory.
825 * Returns: Value read.
827 static inline uint32_t readl(uint64_t addr)
829 return qtest_readl(global_qtest, addr);
833 * readq:
834 * @addr: Guest address to read from.
836 * Reads a 64-bit value from guest memory.
838 * Returns: Value read.
840 static inline uint64_t readq(uint64_t addr)
842 return qtest_readq(global_qtest, addr);
846 * memread:
847 * @addr: Guest address to read from.
848 * @data: Pointer to where memory contents will be stored.
849 * @size: Number of bytes to read.
851 * Read guest memory into a buffer.
853 static inline void memread(uint64_t addr, void *data, size_t size)
855 qtest_memread(global_qtest, addr, data, size);
859 * bufread:
860 * @addr: Guest address to read from.
861 * @data: Pointer to where memory contents will be stored.
862 * @size: Number of bytes to read.
864 * Read guest memory into a buffer, receive using a base64 encoding.
866 static inline void bufread(uint64_t addr, void *data, size_t size)
868 qtest_bufread(global_qtest, addr, data, size);
872 * memwrite:
873 * @addr: Guest address to write to.
874 * @data: Pointer to the bytes that will be written to guest memory.
875 * @size: Number of bytes to write.
877 * Write a buffer to guest memory.
879 static inline void memwrite(uint64_t addr, const void *data, size_t size)
881 qtest_memwrite(global_qtest, addr, data, size);
885 * bufwrite:
886 * @addr: Guest address to write to.
887 * @data: Pointer to the bytes that will be written to guest memory.
888 * @size: Number of bytes to write.
890 * Write a buffer to guest memory, transmit using a base64 encoding.
892 static inline void bufwrite(uint64_t addr, const void *data, size_t size)
894 qtest_bufwrite(global_qtest, addr, data, size);
898 * qmemset:
899 * @addr: Guest address to write to.
900 * @patt: Byte pattern to fill the guest memory region with.
901 * @size: Number of bytes to write.
903 * Write a pattern to guest memory.
905 static inline void qmemset(uint64_t addr, uint8_t patt, size_t size)
907 qtest_memset(global_qtest, addr, patt, size);
911 * clock_step_next:
913 * Advance the QEMU_CLOCK_VIRTUAL to the next deadline.
915 * Returns: The current value of the QEMU_CLOCK_VIRTUAL in nanoseconds.
917 static inline int64_t clock_step_next(void)
919 return qtest_clock_step_next(global_qtest);
923 * clock_step:
924 * @step: Number of nanoseconds to advance the clock by.
926 * Advance the QEMU_CLOCK_VIRTUAL by @step nanoseconds.
928 * Returns: The current value of the QEMU_CLOCK_VIRTUAL in nanoseconds.
930 static inline int64_t clock_step(int64_t step)
932 return qtest_clock_step(global_qtest, step);
936 * clock_set:
937 * @val: Nanoseconds value to advance the clock to.
939 * Advance the QEMU_CLOCK_VIRTUAL to @val nanoseconds since the VM was launched.
941 * Returns: The current value of the QEMU_CLOCK_VIRTUAL in nanoseconds.
943 static inline int64_t clock_set(int64_t val)
945 return qtest_clock_set(global_qtest, val);
948 QDict *qmp_fd_receive(int fd);
949 void qmp_fd_vsend(int fd, const char *fmt, va_list ap) GCC_FMT_ATTR(2, 0);
950 void qmp_fd_send(int fd, const char *fmt, ...) GCC_FMT_ATTR(2, 3);
951 QDict *qmp_fdv(int fd, const char *fmt, va_list ap) GCC_FMT_ATTR(2, 0);
952 QDict *qmp_fd(int fd, const char *fmt, ...) GCC_FMT_ATTR(2, 3);
955 * qtest_cb_for_every_machine:
956 * @cb: Pointer to the callback function
957 * @skip_old_versioned: true if versioned old machine types should be skipped
959 * Call a callback function for every name of all available machines.
961 void qtest_cb_for_every_machine(void (*cb)(const char *machine),
962 bool skip_old_versioned);
965 * qtest_qmp_device_add:
966 * @driver: Name of the device that should be added
967 * @id: Identification string
968 * @fmt...: QMP message to send to qemu, formatted like
969 * qobject_from_jsonf_nofail(). See parse_escape() for what's
970 * supported after '%'.
972 * Generic hot-plugging test via the device_add QMP command.
974 void qtest_qmp_device_add(const char *driver, const char *id, const char *fmt,
975 ...) GCC_FMT_ATTR(3, 4);
978 * qtest_qmp_device_del:
979 * @id: Identification string
981 * Generic hot-unplugging test via the device_del QMP command.
983 void qtest_qmp_device_del(const char *id);
986 * qmp_rsp_is_err:
987 * @rsp: QMP response to check for error
989 * Test @rsp for error and discard @rsp.
990 * Returns 'true' if there is error in @rsp and 'false' otherwise.
992 bool qmp_rsp_is_err(QDict *rsp);
994 #endif