hyperv: make hyperv_vp_index inline
[qemu.git] / tests / libqtest.h
blobed88ff99d551a382f6eb244123a0206945ea79f6
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_qmp_send_raw:
101 * @s: #QTestState instance to operate on.
102 * @fmt...: text to send, formatted like sprintf()
104 * Sends text to the QMP monitor verbatim. Need not be valid JSON;
105 * this is useful for negative tests.
107 void qtest_qmp_send_raw(QTestState *s, const char *fmt, ...)
108 GCC_FMT_ATTR(2, 3);
111 * qtest_qmpv:
112 * @s: #QTestState instance to operate on.
113 * @fmt: QMP message to send to QEMU, formatted like
114 * qobject_from_jsonf_nofail(). See parse_escape() for what's
115 * supported after '%'.
116 * @ap: QMP message arguments
118 * Sends a QMP message to QEMU and returns the response.
120 QDict *qtest_vqmp(QTestState *s, const char *fmt, va_list ap)
121 GCC_FMT_ATTR(2, 0);
124 * qtest_qmp_vsend:
125 * @s: #QTestState instance to operate on.
126 * @fmt: QMP message to send to QEMU, formatted like
127 * qobject_from_jsonf_nofail(). See parse_escape() for what's
128 * supported after '%'.
129 * @ap: QMP message arguments
131 * Sends a QMP message to QEMU and leaves the response in the stream.
133 void qtest_qmp_vsend(QTestState *s, const char *fmt, va_list ap)
134 GCC_FMT_ATTR(2, 0);
137 * qtest_receive:
138 * @s: #QTestState instance to operate on.
140 * Reads a QMP message from QEMU and returns the response.
142 QDict *qtest_qmp_receive(QTestState *s);
145 * qtest_qmp_eventwait:
146 * @s: #QTestState instance to operate on.
147 * @s: #event event to wait for.
149 * Continuously polls for QMP responses until it receives the desired event.
151 void qtest_qmp_eventwait(QTestState *s, const char *event);
154 * qtest_qmp_eventwait_ref:
155 * @s: #QTestState instance to operate on.
156 * @s: #event event to wait for.
158 * Continuously polls for QMP responses until it receives the desired event.
159 * Returns a copy of the event for further investigation.
161 QDict *qtest_qmp_eventwait_ref(QTestState *s, const char *event);
164 * qtest_qmp_receive_success:
165 * @s: #QTestState instance to operate on
166 * @event_cb: Event callback
167 * @opaque: Argument for @event_cb
169 * Poll QMP messages until a command success response is received.
170 * If @event_cb, call it for each event received, passing @opaque,
171 * the event's name and data.
172 * Return the success response's "return" member.
174 QDict *qtest_qmp_receive_success(QTestState *s,
175 void (*event_cb)(void *opaque,
176 const char *name,
177 QDict *data),
178 void *opaque);
181 * qtest_hmp:
182 * @s: #QTestState instance to operate on.
183 * @fmt...: HMP command to send to QEMU, formats arguments like sprintf().
185 * Send HMP command to QEMU via QMP's human-monitor-command.
186 * QMP events are discarded.
188 * Returns: the command's output. The caller should g_free() it.
190 char *qtest_hmp(QTestState *s, const char *fmt, ...) GCC_FMT_ATTR(2, 3);
193 * qtest_hmpv:
194 * @s: #QTestState instance to operate on.
195 * @fmt: HMP command to send to QEMU, formats arguments like vsprintf().
196 * @ap: HMP command arguments
198 * Send HMP command to QEMU via QMP's human-monitor-command.
199 * QMP events are discarded.
201 * Returns: the command's output. The caller should g_free() it.
203 char *qtest_vhmp(QTestState *s, const char *fmt, va_list ap)
204 GCC_FMT_ATTR(2, 0);
207 * qtest_get_irq:
208 * @s: #QTestState instance to operate on.
209 * @num: Interrupt to observe.
211 * Returns: The level of the @num interrupt.
213 bool qtest_get_irq(QTestState *s, int num);
216 * qtest_irq_intercept_in:
217 * @s: #QTestState instance to operate on.
218 * @string: QOM path of a device.
220 * Associate qtest irqs with the GPIO-in pins of the device
221 * whose path is specified by @string.
223 void qtest_irq_intercept_in(QTestState *s, const char *string);
226 * qtest_irq_intercept_out:
227 * @s: #QTestState instance to operate on.
228 * @string: QOM path of a device.
230 * Associate qtest irqs with the GPIO-out pins of the device
231 * whose path is specified by @string.
233 void qtest_irq_intercept_out(QTestState *s, const char *string);
236 * qtest_outb:
237 * @s: #QTestState instance to operate on.
238 * @addr: I/O port to write to.
239 * @value: Value being written.
241 * Write an 8-bit value to an I/O port.
243 void qtest_outb(QTestState *s, uint16_t addr, uint8_t value);
246 * qtest_outw:
247 * @s: #QTestState instance to operate on.
248 * @addr: I/O port to write to.
249 * @value: Value being written.
251 * Write a 16-bit value to an I/O port.
253 void qtest_outw(QTestState *s, uint16_t addr, uint16_t value);
256 * qtest_outl:
257 * @s: #QTestState instance to operate on.
258 * @addr: I/O port to write to.
259 * @value: Value being written.
261 * Write a 32-bit value to an I/O port.
263 void qtest_outl(QTestState *s, uint16_t addr, uint32_t value);
266 * qtest_inb:
267 * @s: #QTestState instance to operate on.
268 * @addr: I/O port to read from.
270 * Returns an 8-bit value from an I/O port.
272 uint8_t qtest_inb(QTestState *s, uint16_t addr);
275 * qtest_inw:
276 * @s: #QTestState instance to operate on.
277 * @addr: I/O port to read from.
279 * Returns a 16-bit value from an I/O port.
281 uint16_t qtest_inw(QTestState *s, uint16_t addr);
284 * qtest_inl:
285 * @s: #QTestState instance to operate on.
286 * @addr: I/O port to read from.
288 * Returns a 32-bit value from an I/O port.
290 uint32_t qtest_inl(QTestState *s, uint16_t addr);
293 * qtest_writeb:
294 * @s: #QTestState instance to operate on.
295 * @addr: Guest address to write to.
296 * @value: Value being written.
298 * Writes an 8-bit value to memory.
300 void qtest_writeb(QTestState *s, uint64_t addr, uint8_t value);
303 * qtest_writew:
304 * @s: #QTestState instance to operate on.
305 * @addr: Guest address to write to.
306 * @value: Value being written.
308 * Writes a 16-bit value to memory.
310 void qtest_writew(QTestState *s, uint64_t addr, uint16_t value);
313 * qtest_writel:
314 * @s: #QTestState instance to operate on.
315 * @addr: Guest address to write to.
316 * @value: Value being written.
318 * Writes a 32-bit value to memory.
320 void qtest_writel(QTestState *s, uint64_t addr, uint32_t value);
323 * qtest_writeq:
324 * @s: #QTestState instance to operate on.
325 * @addr: Guest address to write to.
326 * @value: Value being written.
328 * Writes a 64-bit value to memory.
330 void qtest_writeq(QTestState *s, uint64_t addr, uint64_t value);
333 * qtest_readb:
334 * @s: #QTestState instance to operate on.
335 * @addr: Guest address to read from.
337 * Reads an 8-bit value from memory.
339 * Returns: Value read.
341 uint8_t qtest_readb(QTestState *s, uint64_t addr);
344 * qtest_readw:
345 * @s: #QTestState instance to operate on.
346 * @addr: Guest address to read from.
348 * Reads a 16-bit value from memory.
350 * Returns: Value read.
352 uint16_t qtest_readw(QTestState *s, uint64_t addr);
355 * qtest_readl:
356 * @s: #QTestState instance to operate on.
357 * @addr: Guest address to read from.
359 * Reads a 32-bit value from memory.
361 * Returns: Value read.
363 uint32_t qtest_readl(QTestState *s, uint64_t addr);
366 * qtest_readq:
367 * @s: #QTestState instance to operate on.
368 * @addr: Guest address to read from.
370 * Reads a 64-bit value from memory.
372 * Returns: Value read.
374 uint64_t qtest_readq(QTestState *s, uint64_t addr);
377 * qtest_memread:
378 * @s: #QTestState instance to operate on.
379 * @addr: Guest address to read from.
380 * @data: Pointer to where memory contents will be stored.
381 * @size: Number of bytes to read.
383 * Read guest memory into a buffer.
385 void qtest_memread(QTestState *s, uint64_t addr, void *data, size_t size);
388 * qtest_rtas_call:
389 * @s: #QTestState instance to operate on.
390 * @name: name of the command to call.
391 * @nargs: Number of args.
392 * @args: Guest address to read args from.
393 * @nret: Number of return value.
394 * @ret: Guest address to write return values to.
396 * Call an RTAS function
398 uint64_t qtest_rtas_call(QTestState *s, const char *name,
399 uint32_t nargs, uint64_t args,
400 uint32_t nret, uint64_t ret);
403 * qtest_bufread:
404 * @s: #QTestState instance to operate on.
405 * @addr: Guest address to read from.
406 * @data: Pointer to where memory contents will be stored.
407 * @size: Number of bytes to read.
409 * Read guest memory into a buffer and receive using a base64 encoding.
411 void qtest_bufread(QTestState *s, uint64_t addr, void *data, size_t size);
414 * qtest_memwrite:
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.
422 void qtest_memwrite(QTestState *s, uint64_t addr, const void *data, size_t size);
425 * qtest_bufwrite:
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 and transmit using a base64 encoding.
433 void qtest_bufwrite(QTestState *s, uint64_t addr,
434 const void *data, size_t size);
437 * qtest_memset:
438 * @s: #QTestState instance to operate on.
439 * @addr: Guest address to write to.
440 * @patt: Byte pattern to fill the guest memory region with.
441 * @size: Number of bytes to write.
443 * Write a pattern to guest memory.
445 void qtest_memset(QTestState *s, uint64_t addr, uint8_t patt, size_t size);
448 * qtest_clock_step_next:
449 * @s: #QTestState instance to operate on.
451 * Advance the QEMU_CLOCK_VIRTUAL to the next deadline.
453 * Returns: The current value of the QEMU_CLOCK_VIRTUAL in nanoseconds.
455 int64_t qtest_clock_step_next(QTestState *s);
458 * qtest_clock_step:
459 * @s: QTestState instance to operate on.
460 * @step: Number of nanoseconds to advance the clock by.
462 * Advance the QEMU_CLOCK_VIRTUAL by @step nanoseconds.
464 * Returns: The current value of the QEMU_CLOCK_VIRTUAL in nanoseconds.
466 int64_t qtest_clock_step(QTestState *s, int64_t step);
469 * qtest_clock_set:
470 * @s: QTestState instance to operate on.
471 * @val: Nanoseconds value to advance the clock to.
473 * Advance the QEMU_CLOCK_VIRTUAL to @val nanoseconds since the VM was launched.
475 * Returns: The current value of the QEMU_CLOCK_VIRTUAL in nanoseconds.
477 int64_t qtest_clock_set(QTestState *s, int64_t val);
480 * qtest_big_endian:
481 * @s: QTestState instance to operate on.
483 * Returns: True if the architecture under test has a big endian configuration.
485 bool qtest_big_endian(QTestState *s);
488 * qtest_get_arch:
490 * Returns: The architecture for the QEMU executable under test.
492 const char *qtest_get_arch(void);
495 * qtest_add_func:
496 * @str: Test case path.
497 * @fn: Test case function
499 * Add a GTester testcase with the given name and function.
500 * The path is prefixed with the architecture under test, as
501 * returned by qtest_get_arch().
503 void qtest_add_func(const char *str, void (*fn)(void));
506 * qtest_add_data_func:
507 * @str: Test case path.
508 * @data: Test case data
509 * @fn: Test case function
511 * Add a GTester testcase with the given name, data and function.
512 * The path is prefixed with the architecture under test, as
513 * returned by qtest_get_arch().
515 void qtest_add_data_func(const char *str, const void *data,
516 void (*fn)(const void *));
519 * qtest_add_data_func_full:
520 * @str: Test case path.
521 * @data: Test case data
522 * @fn: Test case function
523 * @data_free_func: GDestroyNotify for data
525 * Add a GTester testcase with the given name, data and function.
526 * The path is prefixed with the architecture under test, as
527 * returned by qtest_get_arch().
529 * @data is passed to @data_free_func() on test completion.
531 void qtest_add_data_func_full(const char *str, void *data,
532 void (*fn)(const void *),
533 GDestroyNotify data_free_func);
536 * qtest_add:
537 * @testpath: Test case path
538 * @Fixture: Fixture type
539 * @tdata: Test case data
540 * @fsetup: Test case setup function
541 * @ftest: Test case function
542 * @fteardown: Test case teardown function
544 * Add a GTester testcase with the given name, data and functions.
545 * The path is prefixed with the architecture under test, as
546 * returned by qtest_get_arch().
548 #define qtest_add(testpath, Fixture, tdata, fsetup, ftest, fteardown) \
549 do { \
550 char *path = g_strdup_printf("/%s/%s", qtest_get_arch(), testpath); \
551 g_test_add(path, Fixture, tdata, fsetup, ftest, fteardown); \
552 g_free(path); \
553 } while (0)
555 void qtest_add_abrt_handler(GHookFunc fn, const void *data);
558 * qtest_start:
559 * @args: other arguments to pass to QEMU
561 * Start QEMU and assign the resulting #QTestState to a global variable.
562 * The global variable is used by "shortcut" functions documented below.
564 * Returns: #QTestState instance.
566 static inline QTestState *qtest_start(const char *args)
568 global_qtest = qtest_init(args);
569 return global_qtest;
573 * qtest_end:
575 * Shut down the QEMU process started by qtest_start().
577 static inline void qtest_end(void)
579 qtest_quit(global_qtest);
580 global_qtest = NULL;
584 * qmp:
585 * @fmt...: QMP message to send to qemu, formatted like
586 * qobject_from_jsonf_nofail(). See parse_escape() for what's
587 * supported after '%'.
589 * Sends a QMP message to QEMU and returns the response.
591 QDict *qmp(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
594 * qmp_send:
595 * @fmt...: QMP message to send to qemu, formatted like
596 * qobject_from_jsonf_nofail(). See parse_escape() for what's
597 * supported after '%'.
599 * Sends a QMP message to QEMU and leaves the response in the stream.
601 void qmp_send(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
604 * qmp_receive:
606 * Reads a QMP message from QEMU and returns the response.
608 static inline QDict *qmp_receive(void)
610 return qtest_qmp_receive(global_qtest);
614 * qmp_eventwait:
615 * @s: #event event to wait for.
617 * Continuously polls for QMP responses until it receives the desired event.
619 static inline void qmp_eventwait(const char *event)
621 return qtest_qmp_eventwait(global_qtest, event);
625 * qmp_eventwait_ref:
626 * @s: #event event to wait for.
628 * Continuously polls for QMP responses until it receives the desired event.
629 * Returns a copy of the event for further investigation.
631 static inline QDict *qmp_eventwait_ref(const char *event)
633 return qtest_qmp_eventwait_ref(global_qtest, event);
637 * hmp:
638 * @fmt...: HMP command to send to QEMU, formats arguments like sprintf().
640 * Send HMP command to QEMU via QMP's human-monitor-command.
642 * Returns: the command's output. The caller should g_free() it.
644 char *hmp(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
647 * get_irq:
648 * @num: Interrupt to observe.
650 * Returns: The level of the @num interrupt.
652 static inline bool get_irq(int num)
654 return qtest_get_irq(global_qtest, num);
658 * irq_intercept_in:
659 * @string: QOM path of a device.
661 * Associate qtest irqs with the GPIO-in pins of the device
662 * whose path is specified by @string.
664 static inline void irq_intercept_in(const char *string)
666 qtest_irq_intercept_in(global_qtest, string);
670 * qtest_irq_intercept_out:
671 * @string: QOM path of a device.
673 * Associate qtest irqs with the GPIO-out pins of the device
674 * whose path is specified by @string.
676 static inline void irq_intercept_out(const char *string)
678 qtest_irq_intercept_out(global_qtest, string);
682 * outb:
683 * @addr: I/O port to write to.
684 * @value: Value being written.
686 * Write an 8-bit value to an I/O port.
688 static inline void outb(uint16_t addr, uint8_t value)
690 qtest_outb(global_qtest, addr, value);
694 * outw:
695 * @addr: I/O port to write to.
696 * @value: Value being written.
698 * Write a 16-bit value to an I/O port.
700 static inline void outw(uint16_t addr, uint16_t value)
702 qtest_outw(global_qtest, addr, value);
706 * outl:
707 * @addr: I/O port to write to.
708 * @value: Value being written.
710 * Write a 32-bit value to an I/O port.
712 static inline void outl(uint16_t addr, uint32_t value)
714 qtest_outl(global_qtest, addr, value);
718 * inb:
719 * @addr: I/O port to read from.
721 * Reads an 8-bit value from an I/O port.
723 * Returns: Value read.
725 static inline uint8_t inb(uint16_t addr)
727 return qtest_inb(global_qtest, addr);
731 * inw:
732 * @addr: I/O port to read from.
734 * Reads a 16-bit value from an I/O port.
736 * Returns: Value read.
738 static inline uint16_t inw(uint16_t addr)
740 return qtest_inw(global_qtest, addr);
744 * inl:
745 * @addr: I/O port to read from.
747 * Reads a 32-bit value from an I/O port.
749 * Returns: Value read.
751 static inline uint32_t inl(uint16_t addr)
753 return qtest_inl(global_qtest, addr);
757 * writeb:
758 * @addr: Guest address to write to.
759 * @value: Value being written.
761 * Writes an 8-bit value to guest memory.
763 static inline void writeb(uint64_t addr, uint8_t value)
765 qtest_writeb(global_qtest, addr, value);
769 * writew:
770 * @addr: Guest address to write to.
771 * @value: Value being written.
773 * Writes a 16-bit value to guest memory.
775 static inline void writew(uint64_t addr, uint16_t value)
777 qtest_writew(global_qtest, addr, value);
781 * writel:
782 * @addr: Guest address to write to.
783 * @value: Value being written.
785 * Writes a 32-bit value to guest memory.
787 static inline void writel(uint64_t addr, uint32_t value)
789 qtest_writel(global_qtest, addr, value);
793 * writeq:
794 * @addr: Guest address to write to.
795 * @value: Value being written.
797 * Writes a 64-bit value to guest memory.
799 static inline void writeq(uint64_t addr, uint64_t value)
801 qtest_writeq(global_qtest, addr, value);
805 * readb:
806 * @addr: Guest address to read from.
808 * Reads an 8-bit value from guest memory.
810 * Returns: Value read.
812 static inline uint8_t readb(uint64_t addr)
814 return qtest_readb(global_qtest, addr);
818 * readw:
819 * @addr: Guest address to read from.
821 * Reads a 16-bit value from guest memory.
823 * Returns: Value read.
825 static inline uint16_t readw(uint64_t addr)
827 return qtest_readw(global_qtest, addr);
831 * readl:
832 * @addr: Guest address to read from.
834 * Reads a 32-bit value from guest memory.
836 * Returns: Value read.
838 static inline uint32_t readl(uint64_t addr)
840 return qtest_readl(global_qtest, addr);
844 * readq:
845 * @addr: Guest address to read from.
847 * Reads a 64-bit value from guest memory.
849 * Returns: Value read.
851 static inline uint64_t readq(uint64_t addr)
853 return qtest_readq(global_qtest, addr);
857 * memread:
858 * @addr: Guest address to read from.
859 * @data: Pointer to where memory contents will be stored.
860 * @size: Number of bytes to read.
862 * Read guest memory into a buffer.
864 static inline void memread(uint64_t addr, void *data, size_t size)
866 qtest_memread(global_qtest, addr, data, size);
870 * bufread:
871 * @addr: Guest address to read from.
872 * @data: Pointer to where memory contents will be stored.
873 * @size: Number of bytes to read.
875 * Read guest memory into a buffer, receive using a base64 encoding.
877 static inline void bufread(uint64_t addr, void *data, size_t size)
879 qtest_bufread(global_qtest, addr, data, size);
883 * memwrite:
884 * @addr: Guest address to write to.
885 * @data: Pointer to the bytes that will be written to guest memory.
886 * @size: Number of bytes to write.
888 * Write a buffer to guest memory.
890 static inline void memwrite(uint64_t addr, const void *data, size_t size)
892 qtest_memwrite(global_qtest, addr, data, size);
896 * bufwrite:
897 * @addr: Guest address to write to.
898 * @data: Pointer to the bytes that will be written to guest memory.
899 * @size: Number of bytes to write.
901 * Write a buffer to guest memory, transmit using a base64 encoding.
903 static inline void bufwrite(uint64_t addr, const void *data, size_t size)
905 qtest_bufwrite(global_qtest, addr, data, size);
909 * qmemset:
910 * @addr: Guest address to write to.
911 * @patt: Byte pattern to fill the guest memory region with.
912 * @size: Number of bytes to write.
914 * Write a pattern to guest memory.
916 static inline void qmemset(uint64_t addr, uint8_t patt, size_t size)
918 qtest_memset(global_qtest, addr, patt, size);
922 * clock_step_next:
924 * Advance the QEMU_CLOCK_VIRTUAL to the next deadline.
926 * Returns: The current value of the QEMU_CLOCK_VIRTUAL in nanoseconds.
928 static inline int64_t clock_step_next(void)
930 return qtest_clock_step_next(global_qtest);
934 * clock_step:
935 * @step: Number of nanoseconds to advance the clock by.
937 * Advance the QEMU_CLOCK_VIRTUAL by @step nanoseconds.
939 * Returns: The current value of the QEMU_CLOCK_VIRTUAL in nanoseconds.
941 static inline int64_t clock_step(int64_t step)
943 return qtest_clock_step(global_qtest, step);
947 * clock_set:
948 * @val: Nanoseconds value to advance the clock to.
950 * Advance the QEMU_CLOCK_VIRTUAL to @val nanoseconds since the VM was launched.
952 * Returns: The current value of the QEMU_CLOCK_VIRTUAL in nanoseconds.
954 static inline int64_t clock_set(int64_t val)
956 return qtest_clock_set(global_qtest, val);
959 QDict *qmp_fd_receive(int fd);
960 void qmp_fd_vsend(int fd, const char *fmt, va_list ap) GCC_FMT_ATTR(2, 0);
961 void qmp_fd_send(int fd, const char *fmt, ...) GCC_FMT_ATTR(2, 3);
962 void qmp_fd_send_raw(int fd, const char *fmt, ...) GCC_FMT_ATTR(2, 3);
963 void qmp_fd_vsend_raw(int fd, const char *fmt, va_list ap) GCC_FMT_ATTR(2, 0);
964 QDict *qmp_fdv(int fd, const char *fmt, va_list ap) GCC_FMT_ATTR(2, 0);
965 QDict *qmp_fd(int fd, const char *fmt, ...) GCC_FMT_ATTR(2, 3);
968 * qtest_cb_for_every_machine:
969 * @cb: Pointer to the callback function
970 * @skip_old_versioned: true if versioned old machine types should be skipped
972 * Call a callback function for every name of all available machines.
974 void qtest_cb_for_every_machine(void (*cb)(const char *machine),
975 bool skip_old_versioned);
978 * qtest_qmp_device_add:
979 * @driver: Name of the device that should be added
980 * @id: Identification string
981 * @fmt...: QMP message to send to qemu, formatted like
982 * qobject_from_jsonf_nofail(). See parse_escape() for what's
983 * supported after '%'.
985 * Generic hot-plugging test via the device_add QMP command.
987 void qtest_qmp_device_add(const char *driver, const char *id, const char *fmt,
988 ...) GCC_FMT_ATTR(3, 4);
991 * qtest_qmp_device_del:
992 * @id: Identification string
994 * Generic hot-unplugging test via the device_del QMP command.
996 void qtest_qmp_device_del(const char *id);
999 * qmp_rsp_is_err:
1000 * @rsp: QMP response to check for error
1002 * Test @rsp for error and discard @rsp.
1003 * Returns 'true' if there is error in @rsp and 'false' otherwise.
1005 bool qmp_rsp_is_err(QDict *rsp);
1008 * qmp_assert_error_class:
1009 * @rsp: QMP response to check for error
1010 * @class: an error class
1012 * Assert the response has the given error class and discard @rsp.
1014 void qmp_assert_error_class(QDict *rsp, const char *class);
1016 #endif