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