pvrdma: check return value from pvrdma_idx_ring_has_ routines
[qemu/ar7.git] / tests / libqtest.h
blob9758c51be615a8c19ffdc744465ff750354993d8
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_outb:
235 * @s: #QTestState instance to operate on.
236 * @addr: I/O port to write to.
237 * @value: Value being written.
239 * Write an 8-bit value to an I/O port.
241 void qtest_outb(QTestState *s, uint16_t addr, uint8_t value);
244 * qtest_outw:
245 * @s: #QTestState instance to operate on.
246 * @addr: I/O port to write to.
247 * @value: Value being written.
249 * Write a 16-bit value to an I/O port.
251 void qtest_outw(QTestState *s, uint16_t addr, uint16_t value);
254 * qtest_outl:
255 * @s: #QTestState instance to operate on.
256 * @addr: I/O port to write to.
257 * @value: Value being written.
259 * Write a 32-bit value to an I/O port.
261 void qtest_outl(QTestState *s, uint16_t addr, uint32_t value);
264 * qtest_inb:
265 * @s: #QTestState instance to operate on.
266 * @addr: I/O port to read from.
268 * Returns an 8-bit value from an I/O port.
270 uint8_t qtest_inb(QTestState *s, uint16_t addr);
273 * qtest_inw:
274 * @s: #QTestState instance to operate on.
275 * @addr: I/O port to read from.
277 * Returns a 16-bit value from an I/O port.
279 uint16_t qtest_inw(QTestState *s, uint16_t addr);
282 * qtest_inl:
283 * @s: #QTestState instance to operate on.
284 * @addr: I/O port to read from.
286 * Returns a 32-bit value from an I/O port.
288 uint32_t qtest_inl(QTestState *s, uint16_t addr);
291 * qtest_writeb:
292 * @s: #QTestState instance to operate on.
293 * @addr: Guest address to write to.
294 * @value: Value being written.
296 * Writes an 8-bit value to memory.
298 void qtest_writeb(QTestState *s, uint64_t addr, uint8_t value);
301 * qtest_writew:
302 * @s: #QTestState instance to operate on.
303 * @addr: Guest address to write to.
304 * @value: Value being written.
306 * Writes a 16-bit value to memory.
308 void qtest_writew(QTestState *s, uint64_t addr, uint16_t value);
311 * qtest_writel:
312 * @s: #QTestState instance to operate on.
313 * @addr: Guest address to write to.
314 * @value: Value being written.
316 * Writes a 32-bit value to memory.
318 void qtest_writel(QTestState *s, uint64_t addr, uint32_t value);
321 * qtest_writeq:
322 * @s: #QTestState instance to operate on.
323 * @addr: Guest address to write to.
324 * @value: Value being written.
326 * Writes a 64-bit value to memory.
328 void qtest_writeq(QTestState *s, uint64_t addr, uint64_t value);
331 * qtest_readb:
332 * @s: #QTestState instance to operate on.
333 * @addr: Guest address to read from.
335 * Reads an 8-bit value from memory.
337 * Returns: Value read.
339 uint8_t qtest_readb(QTestState *s, uint64_t addr);
342 * qtest_readw:
343 * @s: #QTestState instance to operate on.
344 * @addr: Guest address to read from.
346 * Reads a 16-bit value from memory.
348 * Returns: Value read.
350 uint16_t qtest_readw(QTestState *s, uint64_t addr);
353 * qtest_readl:
354 * @s: #QTestState instance to operate on.
355 * @addr: Guest address to read from.
357 * Reads a 32-bit value from memory.
359 * Returns: Value read.
361 uint32_t qtest_readl(QTestState *s, uint64_t addr);
364 * qtest_readq:
365 * @s: #QTestState instance to operate on.
366 * @addr: Guest address to read from.
368 * Reads a 64-bit value from memory.
370 * Returns: Value read.
372 uint64_t qtest_readq(QTestState *s, uint64_t addr);
375 * qtest_memread:
376 * @s: #QTestState instance to operate on.
377 * @addr: Guest address to read from.
378 * @data: Pointer to where memory contents will be stored.
379 * @size: Number of bytes to read.
381 * Read guest memory into a buffer.
383 void qtest_memread(QTestState *s, uint64_t addr, void *data, size_t size);
386 * qtest_rtas_call:
387 * @s: #QTestState instance to operate on.
388 * @name: name of the command to call.
389 * @nargs: Number of args.
390 * @args: Guest address to read args from.
391 * @nret: Number of return value.
392 * @ret: Guest address to write return values to.
394 * Call an RTAS function
396 uint64_t qtest_rtas_call(QTestState *s, const char *name,
397 uint32_t nargs, uint64_t args,
398 uint32_t nret, uint64_t ret);
401 * qtest_bufread:
402 * @s: #QTestState instance to operate on.
403 * @addr: Guest address to read from.
404 * @data: Pointer to where memory contents will be stored.
405 * @size: Number of bytes to read.
407 * Read guest memory into a buffer and receive using a base64 encoding.
409 void qtest_bufread(QTestState *s, uint64_t addr, void *data, size_t size);
412 * qtest_memwrite:
413 * @s: #QTestState instance to operate on.
414 * @addr: Guest address to write to.
415 * @data: Pointer to the bytes that will be written to guest memory.
416 * @size: Number of bytes to write.
418 * Write a buffer to guest memory.
420 void qtest_memwrite(QTestState *s, uint64_t addr, const void *data, size_t size);
423 * qtest_bufwrite:
424 * @s: #QTestState instance to operate on.
425 * @addr: Guest address to write to.
426 * @data: Pointer to the bytes that will be written to guest memory.
427 * @size: Number of bytes to write.
429 * Write a buffer to guest memory and transmit using a base64 encoding.
431 void qtest_bufwrite(QTestState *s, uint64_t addr,
432 const void *data, size_t size);
435 * qtest_memset:
436 * @s: #QTestState instance to operate on.
437 * @addr: Guest address to write to.
438 * @patt: Byte pattern to fill the guest memory region with.
439 * @size: Number of bytes to write.
441 * Write a pattern to guest memory.
443 void qtest_memset(QTestState *s, uint64_t addr, uint8_t patt, size_t size);
446 * qtest_clock_step_next:
447 * @s: #QTestState instance to operate on.
449 * Advance the QEMU_CLOCK_VIRTUAL to the next deadline.
451 * Returns: The current value of the QEMU_CLOCK_VIRTUAL in nanoseconds.
453 int64_t qtest_clock_step_next(QTestState *s);
456 * qtest_clock_step:
457 * @s: QTestState instance to operate on.
458 * @step: Number of nanoseconds to advance the clock by.
460 * Advance the QEMU_CLOCK_VIRTUAL by @step nanoseconds.
462 * Returns: The current value of the QEMU_CLOCK_VIRTUAL in nanoseconds.
464 int64_t qtest_clock_step(QTestState *s, int64_t step);
467 * qtest_clock_set:
468 * @s: QTestState instance to operate on.
469 * @val: Nanoseconds value to advance the clock to.
471 * Advance the QEMU_CLOCK_VIRTUAL to @val nanoseconds since the VM was launched.
473 * Returns: The current value of the QEMU_CLOCK_VIRTUAL in nanoseconds.
475 int64_t qtest_clock_set(QTestState *s, int64_t val);
478 * qtest_big_endian:
479 * @s: QTestState instance to operate on.
481 * Returns: True if the architecture under test has a big endian configuration.
483 bool qtest_big_endian(QTestState *s);
486 * qtest_get_arch:
488 * Returns: The architecture for the QEMU executable under test.
490 const char *qtest_get_arch(void);
493 * qtest_add_func:
494 * @str: Test case path.
495 * @fn: Test case function
497 * Add a GTester testcase with the given name and function.
498 * The path is prefixed with the architecture under test, as
499 * returned by qtest_get_arch().
501 void qtest_add_func(const char *str, void (*fn)(void));
504 * qtest_add_data_func:
505 * @str: Test case path.
506 * @data: Test case data
507 * @fn: Test case function
509 * Add a GTester testcase with the given name, data and function.
510 * The path is prefixed with the architecture under test, as
511 * returned by qtest_get_arch().
513 void qtest_add_data_func(const char *str, const void *data,
514 void (*fn)(const void *));
517 * qtest_add_data_func_full:
518 * @str: Test case path.
519 * @data: Test case data
520 * @fn: Test case function
521 * @data_free_func: GDestroyNotify for data
523 * Add a GTester testcase with the given name, data and function.
524 * The path is prefixed with the architecture under test, as
525 * returned by qtest_get_arch().
527 * @data is passed to @data_free_func() on test completion.
529 void qtest_add_data_func_full(const char *str, void *data,
530 void (*fn)(const void *),
531 GDestroyNotify data_free_func);
534 * qtest_add:
535 * @testpath: Test case path
536 * @Fixture: Fixture type
537 * @tdata: Test case data
538 * @fsetup: Test case setup function
539 * @ftest: Test case function
540 * @fteardown: Test case teardown function
542 * Add a GTester testcase with the given name, data and functions.
543 * The path is prefixed with the architecture under test, as
544 * returned by qtest_get_arch().
546 #define qtest_add(testpath, Fixture, tdata, fsetup, ftest, fteardown) \
547 do { \
548 char *path = g_strdup_printf("/%s/%s", qtest_get_arch(), testpath); \
549 g_test_add(path, Fixture, tdata, fsetup, ftest, fteardown); \
550 g_free(path); \
551 } while (0)
553 void qtest_add_abrt_handler(GHookFunc fn, const void *data);
556 * qtest_start:
557 * @args: other arguments to pass to QEMU
559 * Start QEMU and assign the resulting #QTestState to a global variable.
560 * The global variable is used by "shortcut" functions documented below.
562 * Returns: #QTestState instance.
564 static inline QTestState *qtest_start(const char *args)
566 global_qtest = qtest_init(args);
567 return global_qtest;
571 * qtest_end:
573 * Shut down the QEMU process started by qtest_start().
575 static inline void qtest_end(void)
577 qtest_quit(global_qtest);
578 global_qtest = NULL;
582 * qmp:
583 * @fmt...: QMP message to send to qemu, formatted like
584 * qobject_from_jsonf_nofail(). See parse_escape() for what's
585 * supported after '%'.
587 * Sends a QMP message to QEMU and returns the response.
589 QDict *qmp(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
592 * qmp_send:
593 * @fmt...: QMP message to send to qemu, formatted like
594 * qobject_from_jsonf_nofail(). See parse_escape() for what's
595 * supported after '%'.
597 * Sends a QMP message to QEMU and leaves the response in the stream.
599 void qmp_send(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
602 * qmp_receive:
604 * Reads a QMP message from QEMU and returns the response.
606 static inline QDict *qmp_receive(void)
608 return qtest_qmp_receive(global_qtest);
612 * qmp_eventwait:
613 * @s: #event event to wait for.
615 * Continuously polls for QMP responses until it receives the desired event.
617 static inline void qmp_eventwait(const char *event)
619 return qtest_qmp_eventwait(global_qtest, event);
623 * qmp_eventwait_ref:
624 * @s: #event event to wait for.
626 * Continuously polls for QMP responses until it receives the desired event.
627 * Returns a copy of the event for further investigation.
629 static inline QDict *qmp_eventwait_ref(const char *event)
631 return qtest_qmp_eventwait_ref(global_qtest, event);
635 * hmp:
636 * @fmt...: HMP command to send to QEMU, formats arguments like sprintf().
638 * Send HMP command to QEMU via QMP's human-monitor-command.
640 * Returns: the command's output. The caller should g_free() it.
642 char *hmp(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
645 * get_irq:
646 * @num: Interrupt to observe.
648 * Returns: The level of the @num interrupt.
650 static inline bool get_irq(int num)
652 return qtest_get_irq(global_qtest, num);
656 * irq_intercept_in:
657 * @string: QOM path of a device.
659 * Associate qtest irqs with the GPIO-in pins of the device
660 * whose path is specified by @string.
662 static inline void irq_intercept_in(const char *string)
664 qtest_irq_intercept_in(global_qtest, string);
668 * qtest_irq_intercept_out:
669 * @string: QOM path of a device.
671 * Associate qtest irqs with the GPIO-out pins of the device
672 * whose path is specified by @string.
674 static inline void irq_intercept_out(const char *string)
676 qtest_irq_intercept_out(global_qtest, string);
680 * outb:
681 * @addr: I/O port to write to.
682 * @value: Value being written.
684 * Write an 8-bit value to an I/O port.
686 static inline void outb(uint16_t addr, uint8_t value)
688 qtest_outb(global_qtest, addr, value);
692 * outw:
693 * @addr: I/O port to write to.
694 * @value: Value being written.
696 * Write a 16-bit value to an I/O port.
698 static inline void outw(uint16_t addr, uint16_t value)
700 qtest_outw(global_qtest, addr, value);
704 * outl:
705 * @addr: I/O port to write to.
706 * @value: Value being written.
708 * Write a 32-bit value to an I/O port.
710 static inline void outl(uint16_t addr, uint32_t value)
712 qtest_outl(global_qtest, addr, value);
716 * inb:
717 * @addr: I/O port to read from.
719 * Reads an 8-bit value from an I/O port.
721 * Returns: Value read.
723 static inline uint8_t inb(uint16_t addr)
725 return qtest_inb(global_qtest, addr);
729 * inw:
730 * @addr: I/O port to read from.
732 * Reads a 16-bit value from an I/O port.
734 * Returns: Value read.
736 static inline uint16_t inw(uint16_t addr)
738 return qtest_inw(global_qtest, addr);
742 * inl:
743 * @addr: I/O port to read from.
745 * Reads a 32-bit value from an I/O port.
747 * Returns: Value read.
749 static inline uint32_t inl(uint16_t addr)
751 return qtest_inl(global_qtest, addr);
755 * writeb:
756 * @addr: Guest address to write to.
757 * @value: Value being written.
759 * Writes an 8-bit value to guest memory.
761 static inline void writeb(uint64_t addr, uint8_t value)
763 qtest_writeb(global_qtest, addr, value);
767 * writew:
768 * @addr: Guest address to write to.
769 * @value: Value being written.
771 * Writes a 16-bit value to guest memory.
773 static inline void writew(uint64_t addr, uint16_t value)
775 qtest_writew(global_qtest, addr, value);
779 * writel:
780 * @addr: Guest address to write to.
781 * @value: Value being written.
783 * Writes a 32-bit value to guest memory.
785 static inline void writel(uint64_t addr, uint32_t value)
787 qtest_writel(global_qtest, addr, value);
791 * writeq:
792 * @addr: Guest address to write to.
793 * @value: Value being written.
795 * Writes a 64-bit value to guest memory.
797 static inline void writeq(uint64_t addr, uint64_t value)
799 qtest_writeq(global_qtest, addr, value);
803 * readb:
804 * @addr: Guest address to read from.
806 * Reads an 8-bit value from guest memory.
808 * Returns: Value read.
810 static inline uint8_t readb(uint64_t addr)
812 return qtest_readb(global_qtest, addr);
816 * readw:
817 * @addr: Guest address to read from.
819 * Reads a 16-bit value from guest memory.
821 * Returns: Value read.
823 static inline uint16_t readw(uint64_t addr)
825 return qtest_readw(global_qtest, addr);
829 * readl:
830 * @addr: Guest address to read from.
832 * Reads a 32-bit value from guest memory.
834 * Returns: Value read.
836 static inline uint32_t readl(uint64_t addr)
838 return qtest_readl(global_qtest, addr);
842 * readq:
843 * @addr: Guest address to read from.
845 * Reads a 64-bit value from guest memory.
847 * Returns: Value read.
849 static inline uint64_t readq(uint64_t addr)
851 return qtest_readq(global_qtest, addr);
855 * memread:
856 * @addr: Guest address to read from.
857 * @data: Pointer to where memory contents will be stored.
858 * @size: Number of bytes to read.
860 * Read guest memory into a buffer.
862 static inline void memread(uint64_t addr, void *data, size_t size)
864 qtest_memread(global_qtest, addr, data, size);
868 * bufread:
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, receive using a base64 encoding.
875 static inline void bufread(uint64_t addr, void *data, size_t size)
877 qtest_bufread(global_qtest, addr, data, size);
881 * memwrite:
882 * @addr: Guest address to write to.
883 * @data: Pointer to the bytes that will be written to guest memory.
884 * @size: Number of bytes to write.
886 * Write a buffer to guest memory.
888 static inline void memwrite(uint64_t addr, const void *data, size_t size)
890 qtest_memwrite(global_qtest, addr, data, size);
894 * bufwrite:
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, transmit using a base64 encoding.
901 static inline void bufwrite(uint64_t addr, const void *data, size_t size)
903 qtest_bufwrite(global_qtest, addr, data, size);
907 * qmemset:
908 * @addr: Guest address to write to.
909 * @patt: Byte pattern to fill the guest memory region with.
910 * @size: Number of bytes to write.
912 * Write a pattern to guest memory.
914 static inline void qmemset(uint64_t addr, uint8_t patt, size_t size)
916 qtest_memset(global_qtest, addr, patt, size);
920 * clock_step_next:
922 * Advance the QEMU_CLOCK_VIRTUAL to the next deadline.
924 * Returns: The current value of the QEMU_CLOCK_VIRTUAL in nanoseconds.
926 static inline int64_t clock_step_next(void)
928 return qtest_clock_step_next(global_qtest);
932 * clock_step:
933 * @step: Number of nanoseconds to advance the clock by.
935 * Advance the QEMU_CLOCK_VIRTUAL by @step nanoseconds.
937 * Returns: The current value of the QEMU_CLOCK_VIRTUAL in nanoseconds.
939 static inline int64_t clock_step(int64_t step)
941 return qtest_clock_step(global_qtest, step);
945 * clock_set:
946 * @val: Nanoseconds value to advance the clock to.
948 * Advance the QEMU_CLOCK_VIRTUAL to @val nanoseconds since the VM was launched.
950 * Returns: The current value of the QEMU_CLOCK_VIRTUAL in nanoseconds.
952 static inline int64_t clock_set(int64_t val)
954 return qtest_clock_set(global_qtest, val);
957 QDict *qmp_fd_receive(int fd);
958 void qmp_fd_vsend(int fd, const char *fmt, va_list ap) GCC_FMT_ATTR(2, 0);
959 void qmp_fd_send(int fd, const char *fmt, ...) GCC_FMT_ATTR(2, 3);
960 void qmp_fd_send_raw(int fd, const char *fmt, ...) GCC_FMT_ATTR(2, 3);
961 void qmp_fd_vsend_raw(int fd, const char *fmt, va_list ap) GCC_FMT_ATTR(2, 0);
962 QDict *qmp_fdv(int fd, const char *fmt, va_list ap) GCC_FMT_ATTR(2, 0);
963 QDict *qmp_fd(int fd, const char *fmt, ...) GCC_FMT_ATTR(2, 3);
966 * qtest_cb_for_every_machine:
967 * @cb: Pointer to the callback function
968 * @skip_old_versioned: true if versioned old machine types should be skipped
970 * Call a callback function for every name of all available machines.
972 void qtest_cb_for_every_machine(void (*cb)(const char *machine),
973 bool skip_old_versioned);
976 * qtest_qmp_device_add:
977 * @driver: Name of the device that should be added
978 * @id: Identification string
979 * @fmt...: QMP message to send to qemu, formatted like
980 * qobject_from_jsonf_nofail(). See parse_escape() for what's
981 * supported after '%'.
983 * Generic hot-plugging test via the device_add QMP command.
985 void qtest_qmp_device_add(const char *driver, const char *id, const char *fmt,
986 ...) GCC_FMT_ATTR(3, 4);
989 * qtest_qmp_device_del:
990 * @id: Identification string
992 * Generic hot-unplugging test via the device_del QMP command.
994 void qtest_qmp_device_del(const char *id);
997 * qmp_rsp_is_err:
998 * @rsp: QMP response to check for error
1000 * Test @rsp for error and discard @rsp.
1001 * Returns 'true' if there is error in @rsp and 'false' otherwise.
1003 bool qmp_rsp_is_err(QDict *rsp);
1006 * qmp_assert_error_class:
1007 * @rsp: QMP response to check for error
1008 * @class: an error class
1010 * Assert the response has the given error class and discard @rsp.
1012 void qmp_assert_error_class(QDict *rsp, const char *class);
1015 * qtest_probe_child:
1016 * @s: QTestState instance to operate on.
1018 * Returns: true if the child is still alive.
1020 bool qtest_probe_child(QTestState *s);
1022 #endif