]> git.proxmox.com Git - mirror_qemu.git/blame - tests/libqtest.h
qom: Update documentation comment of struct Object
[mirror_qemu.git] / tests / libqtest.h
CommitLineData
49ee3590
AL
1/*
2 * QTest
3 *
4 * Copyright IBM, Corp. 2012
5 * Copyright Red Hat, Inc. 2012
872536bf 6 * Copyright SUSE LINUX Products GmbH 2013
49ee3590
AL
7 *
8 * Authors:
9 * Anthony Liguori <aliguori@us.ibm.com>
10 * Paolo Bonzini <pbonzini@redhat.com>
872536bf 11 * Andreas Färber <afaerber@suse.de>
49ee3590
AL
12 *
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.
15 *
16 */
17#ifndef LIBQTEST_H
18#define LIBQTEST_H
19
1d9358e6 20#include <stddef.h>
49ee3590
AL
21#include <stdint.h>
22#include <stdbool.h>
b73cf9e9 23#include <stdarg.h>
49ee3590 24#include <sys/types.h>
0c460dac 25#include "qapi/qmp/qdict.h"
89b516d8 26#include "glib-compat.h"
49ee3590
AL
27
28typedef struct QTestState QTestState;
29
30extern QTestState *global_qtest;
31
32/**
33 * qtest_init:
34 * @extra_args: other arguments to pass to QEMU.
6acf801d
AF
35 *
36 * Returns: #QTestState instance.
49ee3590
AL
37 */
38QTestState *qtest_init(const char *extra_args);
39
40/**
41 * qtest_quit:
6acf801d 42 * @s: #QTestState instance to operate on.
49ee3590
AL
43 *
44 * Shut down the QEMU process associated to @s.
45 */
46void qtest_quit(QTestState *s);
47
a3ca163c 48/**
0d1aa05e 49 * qtest_qmp_discard_response:
6acf801d 50 * @s: #QTestState instance to operate on.
a3ca163c
KW
51 * @fmt...: QMP message to send to qemu
52 *
0d1aa05e 53 * Sends a QMP message to QEMU and consumes the response.
a3ca163c 54 */
0d1aa05e 55void qtest_qmp_discard_response(QTestState *s, const char *fmt, ...);
a3ca163c 56
0c460dac
SH
57/**
58 * qtest_qmp:
59 * @s: #QTestState instance to operate on.
60 * @fmt...: QMP message to send to qemu
61 *
62 * Sends a QMP message to QEMU and returns the response.
63 */
64QDict *qtest_qmp(QTestState *s, const char *fmt, ...);
65
ba4ed393
JS
66/**
67 * qtest_async_qmp:
68 * @s: #QTestState instance to operate on.
69 * @fmt...: QMP message to send to qemu
70 *
71 * Sends a QMP message to QEMU and leaves the response in the stream.
72 */
73void qtest_async_qmp(QTestState *s, const char *fmt, ...);
74
b73cf9e9 75/**
0d1aa05e 76 * qtest_qmpv_discard_response:
b73cf9e9
AF
77 * @s: #QTestState instance to operate on.
78 * @fmt: QMP message to send to QEMU
79 * @ap: QMP message arguments
80 *
0d1aa05e 81 * Sends a QMP message to QEMU and consumes the response.
b73cf9e9 82 */
0d1aa05e 83void qtest_qmpv_discard_response(QTestState *s, const char *fmt, va_list ap);
b73cf9e9 84
0c460dac
SH
85/**
86 * qtest_qmpv:
87 * @s: #QTestState instance to operate on.
88 * @fmt: QMP message to send to QEMU
89 * @ap: QMP message arguments
90 *
91 * Sends a QMP message to QEMU and returns the response.
92 */
93QDict *qtest_qmpv(QTestState *s, const char *fmt, va_list ap);
94
ba4ed393
JS
95/**
96 * qtest_async_qmpv:
97 * @s: #QTestState instance to operate on.
98 * @fmt: QMP message to send to QEMU
99 * @ap: QMP message arguments
100 *
101 * Sends a QMP message to QEMU and leaves the response in the stream.
102 */
103void qtest_async_qmpv(QTestState *s, const char *fmt, va_list ap);
104
66e0c7b1
AF
105/**
106 * qtest_receive:
107 * @s: #QTestState instance to operate on.
108 *
109 * Reads a QMP message from QEMU and returns the response.
110 */
111QDict *qtest_qmp_receive(QTestState *s);
112
8fe941f7
JS
113/**
114 * qtest_qmp_eventwait:
115 * @s: #QTestState instance to operate on.
116 * @s: #event event to wait for.
117 *
118 * Continuosly polls for QMP responses until it receives the desired event.
119 */
120void qtest_qmp_eventwait(QTestState *s, const char *event);
121
5fb48d96
MA
122/**
123 * qtest_hmpv:
124 * @s: #QTestState instance to operate on.
125 * @fmt...: HMP command to send to QEMU
126 *
127 * Send HMP command to QEMU via QMP's human-monitor-command.
128 *
129 * Returns: the command's output. The caller should g_free() it.
130 */
131char *qtest_hmp(QTestState *s, const char *fmt, ...);
132
133/**
134 * qtest_hmpv:
135 * @s: #QTestState instance to operate on.
136 * @fmt: HMP command to send to QEMU
137 * @ap: HMP command arguments
138 *
139 * Send HMP command to QEMU via QMP's human-monitor-command.
140 *
141 * Returns: the command's output. The caller should g_free() it.
142 */
143char *qtest_hmpv(QTestState *s, const char *fmt, va_list ap);
144
49ee3590
AL
145/**
146 * qtest_get_irq:
6acf801d 147 * @s: #QTestState instance to operate on.
49ee3590
AL
148 * @num: Interrupt to observe.
149 *
6acf801d 150 * Returns: The level of the @num interrupt.
49ee3590
AL
151 */
152bool qtest_get_irq(QTestState *s, int num);
153
154/**
155 * qtest_irq_intercept_in:
6acf801d 156 * @s: #QTestState instance to operate on.
49ee3590
AL
157 * @string: QOM path of a device.
158 *
159 * Associate qtest irqs with the GPIO-in pins of the device
160 * whose path is specified by @string.
161 */
162void qtest_irq_intercept_in(QTestState *s, const char *string);
163
164/**
165 * qtest_irq_intercept_out:
6acf801d 166 * @s: #QTestState instance to operate on.
49ee3590
AL
167 * @string: QOM path of a device.
168 *
169 * Associate qtest irqs with the GPIO-out pins of the device
170 * whose path is specified by @string.
171 */
172void qtest_irq_intercept_out(QTestState *s, const char *string);
173
174/**
175 * qtest_outb:
6acf801d 176 * @s: #QTestState instance to operate on.
49ee3590
AL
177 * @addr: I/O port to write to.
178 * @value: Value being written.
179 *
180 * Write an 8-bit value to an I/O port.
181 */
182void qtest_outb(QTestState *s, uint16_t addr, uint8_t value);
183
184/**
185 * qtest_outw:
6acf801d 186 * @s: #QTestState instance to operate on.
49ee3590
AL
187 * @addr: I/O port to write to.
188 * @value: Value being written.
189 *
190 * Write a 16-bit value to an I/O port.
191 */
192void qtest_outw(QTestState *s, uint16_t addr, uint16_t value);
193
194/**
195 * qtest_outl:
6acf801d 196 * @s: #QTestState instance to operate on.
49ee3590
AL
197 * @addr: I/O port to write to.
198 * @value: Value being written.
199 *
200 * Write a 32-bit value to an I/O port.
201 */
202void qtest_outl(QTestState *s, uint16_t addr, uint32_t value);
203
204/**
205 * qtest_inb:
6acf801d 206 * @s: #QTestState instance to operate on.
49ee3590 207 * @addr: I/O port to read from.
49ee3590
AL
208 *
209 * Returns an 8-bit value from an I/O port.
210 */
211uint8_t qtest_inb(QTestState *s, uint16_t addr);
212
213/**
214 * qtest_inw:
6acf801d 215 * @s: #QTestState instance to operate on.
49ee3590 216 * @addr: I/O port to read from.
49ee3590
AL
217 *
218 * Returns a 16-bit value from an I/O port.
219 */
220uint16_t qtest_inw(QTestState *s, uint16_t addr);
221
222/**
223 * qtest_inl:
6acf801d 224 * @s: #QTestState instance to operate on.
49ee3590 225 * @addr: I/O port to read from.
49ee3590
AL
226 *
227 * Returns a 32-bit value from an I/O port.
228 */
229uint32_t qtest_inl(QTestState *s, uint16_t addr);
230
872536bf
AF
231/**
232 * qtest_writeb:
233 * @s: #QTestState instance to operate on.
234 * @addr: Guest address to write to.
235 * @value: Value being written.
236 *
237 * Writes an 8-bit value to memory.
238 */
239void qtest_writeb(QTestState *s, uint64_t addr, uint8_t value);
240
241/**
242 * qtest_writew:
243 * @s: #QTestState instance to operate on.
244 * @addr: Guest address to write to.
245 * @value: Value being written.
246 *
247 * Writes a 16-bit value to memory.
248 */
249void qtest_writew(QTestState *s, uint64_t addr, uint16_t value);
250
251/**
252 * qtest_writel:
253 * @s: #QTestState instance to operate on.
254 * @addr: Guest address to write to.
255 * @value: Value being written.
256 *
257 * Writes a 32-bit value to memory.
258 */
259void qtest_writel(QTestState *s, uint64_t addr, uint32_t value);
260
261/**
262 * qtest_writeq:
263 * @s: #QTestState instance to operate on.
264 * @addr: Guest address to write to.
265 * @value: Value being written.
266 *
267 * Writes a 64-bit value to memory.
268 */
269void qtest_writeq(QTestState *s, uint64_t addr, uint64_t value);
270
271/**
272 * qtest_readb:
273 * @s: #QTestState instance to operate on.
274 * @addr: Guest address to read from.
275 *
276 * Reads an 8-bit value from memory.
277 *
278 * Returns: Value read.
279 */
280uint8_t qtest_readb(QTestState *s, uint64_t addr);
281
282/**
283 * qtest_readw:
284 * @s: #QTestState instance to operate on.
285 * @addr: Guest address to read from.
286 *
287 * Reads a 16-bit value from memory.
288 *
289 * Returns: Value read.
290 */
291uint16_t qtest_readw(QTestState *s, uint64_t addr);
292
293/**
294 * qtest_readl:
295 * @s: #QTestState instance to operate on.
296 * @addr: Guest address to read from.
297 *
298 * Reads a 32-bit value from memory.
299 *
300 * Returns: Value read.
301 */
302uint32_t qtest_readl(QTestState *s, uint64_t addr);
303
304/**
305 * qtest_readq:
306 * @s: #QTestState instance to operate on.
307 * @addr: Guest address to read from.
308 *
309 * Reads a 64-bit value from memory.
310 *
311 * Returns: Value read.
312 */
313uint64_t qtest_readq(QTestState *s, uint64_t addr);
314
49ee3590
AL
315/**
316 * qtest_memread:
6acf801d 317 * @s: #QTestState instance to operate on.
49ee3590
AL
318 * @addr: Guest address to read from.
319 * @data: Pointer to where memory contents will be stored.
320 * @size: Number of bytes to read.
321 *
322 * Read guest memory into a buffer.
323 */
324void qtest_memread(QTestState *s, uint64_t addr, void *data, size_t size);
325
7a6a740d
JS
326/**
327 * qtest_bufread:
328 * @s: #QTestState instance to operate on.
329 * @addr: Guest address to read from.
330 * @data: Pointer to where memory contents will be stored.
331 * @size: Number of bytes to read.
332 *
333 * Read guest memory into a buffer and receive using a base64 encoding.
334 */
335void qtest_bufread(QTestState *s, uint64_t addr, void *data, size_t size);
336
49ee3590
AL
337/**
338 * qtest_memwrite:
6acf801d 339 * @s: #QTestState instance to operate on.
49ee3590
AL
340 * @addr: Guest address to write to.
341 * @data: Pointer to the bytes that will be written to guest memory.
342 * @size: Number of bytes to write.
343 *
344 * Write a buffer to guest memory.
345 */
346void qtest_memwrite(QTestState *s, uint64_t addr, const void *data, size_t size);
347
7a6a740d
JS
348/**
349 * qtest_bufwrite:
350 * @s: #QTestState instance to operate on.
351 * @addr: Guest address to write to.
352 * @data: Pointer to the bytes that will be written to guest memory.
353 * @size: Number of bytes to write.
354 *
355 * Write a buffer to guest memory and transmit using a base64 encoding.
356 */
357void qtest_bufwrite(QTestState *s, uint64_t addr,
358 const void *data, size_t size);
359
86298845
JS
360/**
361 * qtest_memset:
362 * @s: #QTestState instance to operate on.
363 * @addr: Guest address to write to.
364 * @patt: Byte pattern to fill the guest memory region with.
365 * @size: Number of bytes to write.
366 *
367 * Write a pattern to guest memory.
368 */
369void qtest_memset(QTestState *s, uint64_t addr, uint8_t patt, size_t size);
370
49ee3590
AL
371/**
372 * qtest_clock_step_next:
6acf801d
AF
373 * @s: #QTestState instance to operate on.
374 *
bc72ad67 375 * Advance the QEMU_CLOCK_VIRTUAL to the next deadline.
49ee3590 376 *
bc72ad67 377 * Returns: The current value of the QEMU_CLOCK_VIRTUAL in nanoseconds.
49ee3590
AL
378 */
379int64_t qtest_clock_step_next(QTestState *s);
380
381/**
382 * qtest_clock_step:
383 * @s: QTestState instance to operate on.
384 * @step: Number of nanoseconds to advance the clock by.
385 *
bc72ad67 386 * Advance the QEMU_CLOCK_VIRTUAL by @step nanoseconds.
6acf801d 387 *
bc72ad67 388 * Returns: The current value of the QEMU_CLOCK_VIRTUAL in nanoseconds.
49ee3590
AL
389 */
390int64_t qtest_clock_step(QTestState *s, int64_t step);
391
392/**
393 * qtest_clock_set:
394 * @s: QTestState instance to operate on.
395 * @val: Nanoseconds value to advance the clock to.
396 *
bc72ad67 397 * Advance the QEMU_CLOCK_VIRTUAL to @val nanoseconds since the VM was launched.
6acf801d 398 *
bc72ad67 399 * Returns: The current value of the QEMU_CLOCK_VIRTUAL in nanoseconds.
49ee3590
AL
400 */
401int64_t qtest_clock_set(QTestState *s, int64_t val);
402
403/**
404 * qtest_get_arch:
405 *
6acf801d 406 * Returns: The architecture for the QEMU executable under test.
49ee3590
AL
407 */
408const char *qtest_get_arch(void);
409
410/**
411 * qtest_add_func:
412 * @str: Test case path.
413 * @fn: Test case function
414 *
415 * Add a GTester testcase with the given name and function.
416 * The path is prefixed with the architecture under test, as
6acf801d 417 * returned by qtest_get_arch().
49ee3590
AL
418 */
419void qtest_add_func(const char *str, void (*fn));
420
7949c0e3
AF
421/**
422 * qtest_add_data_func:
423 * @str: Test case path.
424 * @data: Test case data
425 * @fn: Test case function
426 *
427 * Add a GTester testcase with the given name, data and function.
428 * The path is prefixed with the architecture under test, as
429 * returned by qtest_get_arch().
430 */
431void qtest_add_data_func(const char *str, const void *data, void (*fn));
432
45b0f830
AF
433/**
434 * qtest_add:
435 * @testpath: Test case path
436 * @Fixture: Fixture type
437 * @tdata: Test case data
438 * @fsetup: Test case setup function
439 * @ftest: Test case function
440 * @fteardown: Test case teardown function
441 *
442 * Add a GTester testcase with the given name, data and functions.
443 * The path is prefixed with the architecture under test, as
444 * returned by qtest_get_arch().
445 */
446#define qtest_add(testpath, Fixture, tdata, fsetup, ftest, fteardown) \
447 do { \
448 char *path = g_strdup_printf("/%s/%s", qtest_get_arch(), testpath); \
449 g_test_add(path, Fixture, tdata, fsetup, ftest, fteardown); \
450 g_free(path); \
451 } while (0)
452
063c23d9
MAL
453void qtest_add_abrt_handler(void (*fn), const void *data);
454
49ee3590
AL
455/**
456 * qtest_start:
457 * @args: other arguments to pass to QEMU
458 *
6acf801d
AF
459 * Start QEMU and assign the resulting #QTestState to a global variable.
460 * The global variable is used by "shortcut" functions documented below.
461 *
462 * Returns: #QTestState instance.
49ee3590 463 */
6acf801d
AF
464static inline QTestState *qtest_start(const char *args)
465{
96b8ca47
SH
466 global_qtest = qtest_init(args);
467 return global_qtest;
6acf801d 468}
49ee3590 469
1d9358e6
MA
470/**
471 * qtest_end:
472 *
473 * Shut down the QEMU process started by qtest_start().
474 */
475static inline void qtest_end(void)
476{
477 qtest_quit(global_qtest);
96b8ca47 478 global_qtest = NULL;
1d9358e6
MA
479}
480
0c460dac
SH
481/**
482 * qmp:
483 * @fmt...: QMP message to send to qemu
484 *
485 * Sends a QMP message to QEMU and returns the response.
486 */
0100f425 487QDict *qmp(const char *fmt, ...);
0c460dac 488
ba4ed393
JS
489/**
490 * qmp_async:
491 * @fmt...: QMP message to send to qemu
492 *
493 * Sends a QMP message to QEMU and leaves the response in the stream.
494 */
495void qmp_async(const char *fmt, ...);
496
a3ca163c 497/**
0d1aa05e 498 * qmp_discard_response:
a3ca163c
KW
499 * @fmt...: QMP message to send to qemu
500 *
0d1aa05e 501 * Sends a QMP message to QEMU and consumes the response.
a3ca163c 502 */
0100f425 503void qmp_discard_response(const char *fmt, ...);
a3ca163c 504
66e0c7b1
AF
505/**
506 * qmp_receive:
507 *
508 * Reads a QMP message from QEMU and returns the response.
509 */
510static inline QDict *qmp_receive(void)
511{
512 return qtest_qmp_receive(global_qtest);
513}
514
8fe941f7
JS
515/**
516 * qmp_eventwait:
517 * @s: #event event to wait for.
518 *
519 * Continuosly polls for QMP responses until it receives the desired event.
520 */
521static inline void qmp_eventwait(const char *event)
522{
523 return qtest_qmp_eventwait(global_qtest, event);
524}
525
5fb48d96
MA
526/**
527 * hmp:
528 * @fmt...: HMP command to send to QEMU
529 *
530 * Send HMP command to QEMU via QMP's human-monitor-command.
531 *
532 * Returns: the command's output. The caller should g_free() it.
533 */
534char *hmp(const char *fmt, ...);
535
49ee3590
AL
536/**
537 * get_irq:
538 * @num: Interrupt to observe.
539 *
6acf801d 540 * Returns: The level of the @num interrupt.
49ee3590 541 */
6acf801d
AF
542static inline bool get_irq(int num)
543{
544 return qtest_get_irq(global_qtest, num);
545}
49ee3590
AL
546
547/**
548 * irq_intercept_in:
549 * @string: QOM path of a device.
550 *
551 * Associate qtest irqs with the GPIO-in pins of the device
552 * whose path is specified by @string.
553 */
6acf801d
AF
554static inline void irq_intercept_in(const char *string)
555{
556 qtest_irq_intercept_in(global_qtest, string);
557}
49ee3590
AL
558
559/**
560 * qtest_irq_intercept_out:
561 * @string: QOM path of a device.
562 *
563 * Associate qtest irqs with the GPIO-out pins of the device
564 * whose path is specified by @string.
565 */
6acf801d
AF
566static inline void irq_intercept_out(const char *string)
567{
568 qtest_irq_intercept_out(global_qtest, string);
569}
49ee3590
AL
570
571/**
572 * outb:
573 * @addr: I/O port to write to.
574 * @value: Value being written.
575 *
576 * Write an 8-bit value to an I/O port.
577 */
6acf801d
AF
578static inline void outb(uint16_t addr, uint8_t value)
579{
580 qtest_outb(global_qtest, addr, value);
581}
49ee3590
AL
582
583/**
584 * outw:
585 * @addr: I/O port to write to.
586 * @value: Value being written.
587 *
588 * Write a 16-bit value to an I/O port.
589 */
6acf801d
AF
590static inline void outw(uint16_t addr, uint16_t value)
591{
592 qtest_outw(global_qtest, addr, value);
593}
49ee3590
AL
594
595/**
596 * outl:
597 * @addr: I/O port to write to.
598 * @value: Value being written.
599 *
600 * Write a 32-bit value to an I/O port.
601 */
6acf801d
AF
602static inline void outl(uint16_t addr, uint32_t value)
603{
604 qtest_outl(global_qtest, addr, value);
605}
49ee3590
AL
606
607/**
608 * inb:
609 * @addr: I/O port to read from.
49ee3590 610 *
6acf801d
AF
611 * Reads an 8-bit value from an I/O port.
612 *
613 * Returns: Value read.
49ee3590 614 */
6acf801d
AF
615static inline uint8_t inb(uint16_t addr)
616{
617 return qtest_inb(global_qtest, addr);
618}
49ee3590
AL
619
620/**
621 * inw:
622 * @addr: I/O port to read from.
49ee3590 623 *
6acf801d
AF
624 * Reads a 16-bit value from an I/O port.
625 *
626 * Returns: Value read.
49ee3590 627 */
6acf801d
AF
628static inline uint16_t inw(uint16_t addr)
629{
630 return qtest_inw(global_qtest, addr);
631}
49ee3590
AL
632
633/**
634 * inl:
635 * @addr: I/O port to read from.
49ee3590 636 *
6acf801d
AF
637 * Reads a 32-bit value from an I/O port.
638 *
639 * Returns: Value read.
49ee3590 640 */
6acf801d
AF
641static inline uint32_t inl(uint16_t addr)
642{
643 return qtest_inl(global_qtest, addr);
644}
49ee3590 645
872536bf
AF
646/**
647 * writeb:
648 * @addr: Guest address to write to.
649 * @value: Value being written.
650 *
651 * Writes an 8-bit value to guest memory.
652 */
653static inline void writeb(uint64_t addr, uint8_t value)
654{
655 qtest_writeb(global_qtest, addr, value);
656}
657
658/**
659 * writew:
660 * @addr: Guest address to write to.
661 * @value: Value being written.
662 *
663 * Writes a 16-bit value to guest memory.
664 */
665static inline void writew(uint64_t addr, uint16_t value)
666{
667 qtest_writew(global_qtest, addr, value);
668}
669
670/**
671 * writel:
672 * @addr: Guest address to write to.
673 * @value: Value being written.
674 *
675 * Writes a 32-bit value to guest memory.
676 */
677static inline void writel(uint64_t addr, uint32_t value)
678{
679 qtest_writel(global_qtest, addr, value);
680}
681
682/**
683 * writeq:
684 * @addr: Guest address to write to.
685 * @value: Value being written.
686 *
687 * Writes a 64-bit value to guest memory.
688 */
689static inline void writeq(uint64_t addr, uint64_t value)
690{
691 qtest_writeq(global_qtest, addr, value);
692}
693
694/**
695 * readb:
696 * @addr: Guest address to read from.
697 *
698 * Reads an 8-bit value from guest memory.
699 *
700 * Returns: Value read.
701 */
702static inline uint8_t readb(uint64_t addr)
703{
704 return qtest_readb(global_qtest, addr);
705}
706
707/**
708 * readw:
709 * @addr: Guest address to read from.
710 *
711 * Reads a 16-bit value from guest memory.
712 *
713 * Returns: Value read.
714 */
715static inline uint16_t readw(uint64_t addr)
716{
717 return qtest_readw(global_qtest, addr);
718}
719
720/**
721 * readl:
722 * @addr: Guest address to read from.
723 *
724 * Reads a 32-bit value from guest memory.
725 *
726 * Returns: Value read.
727 */
728static inline uint32_t readl(uint64_t addr)
729{
730 return qtest_readl(global_qtest, addr);
731}
732
733/**
734 * readq:
735 * @addr: Guest address to read from.
736 *
737 * Reads a 64-bit value from guest memory.
738 *
739 * Returns: Value read.
740 */
741static inline uint64_t readq(uint64_t addr)
742{
743 return qtest_readq(global_qtest, addr);
744}
745
49ee3590
AL
746/**
747 * memread:
748 * @addr: Guest address to read from.
749 * @data: Pointer to where memory contents will be stored.
750 * @size: Number of bytes to read.
751 *
752 * Read guest memory into a buffer.
753 */
6acf801d
AF
754static inline void memread(uint64_t addr, void *data, size_t size)
755{
756 qtest_memread(global_qtest, addr, data, size);
757}
49ee3590 758
7a6a740d
JS
759/**
760 * bufread:
761 * @addr: Guest address to read from.
762 * @data: Pointer to where memory contents will be stored.
763 * @size: Number of bytes to read.
764 *
765 * Read guest memory into a buffer, receive using a base64 encoding.
766 */
767static inline void bufread(uint64_t addr, void *data, size_t size)
768{
769 qtest_bufread(global_qtest, addr, data, size);
770}
771
49ee3590
AL
772/**
773 * memwrite:
774 * @addr: Guest address to write to.
775 * @data: Pointer to the bytes that will be written to guest memory.
776 * @size: Number of bytes to write.
777 *
778 * Write a buffer to guest memory.
779 */
6acf801d
AF
780static inline void memwrite(uint64_t addr, const void *data, size_t size)
781{
782 qtest_memwrite(global_qtest, addr, data, size);
783}
49ee3590 784
7a6a740d
JS
785/**
786 * bufwrite:
787 * @addr: Guest address to write to.
788 * @data: Pointer to the bytes that will be written to guest memory.
789 * @size: Number of bytes to write.
790 *
791 * Write a buffer to guest memory, transmit using a base64 encoding.
792 */
793static inline void bufwrite(uint64_t addr, const void *data, size_t size)
794{
795 qtest_bufwrite(global_qtest, addr, data, size);
796}
797
86298845
JS
798/**
799 * qmemset:
800 * @addr: Guest address to write to.
801 * @patt: Byte pattern to fill the guest memory region with.
802 * @size: Number of bytes to write.
803 *
804 * Write a pattern to guest memory.
805 */
806static inline void qmemset(uint64_t addr, uint8_t patt, size_t size)
807{
808 qtest_memset(global_qtest, addr, patt, size);
809}
810
49ee3590
AL
811/**
812 * clock_step_next:
813 *
bc72ad67 814 * Advance the QEMU_CLOCK_VIRTUAL to the next deadline.
6acf801d 815 *
bc72ad67 816 * Returns: The current value of the QEMU_CLOCK_VIRTUAL in nanoseconds.
49ee3590 817 */
6acf801d
AF
818static inline int64_t clock_step_next(void)
819{
820 return qtest_clock_step_next(global_qtest);
821}
49ee3590
AL
822
823/**
824 * clock_step:
825 * @step: Number of nanoseconds to advance the clock by.
826 *
bc72ad67 827 * Advance the QEMU_CLOCK_VIRTUAL by @step nanoseconds.
6acf801d 828 *
bc72ad67 829 * Returns: The current value of the QEMU_CLOCK_VIRTUAL in nanoseconds.
49ee3590 830 */
6acf801d
AF
831static inline int64_t clock_step(int64_t step)
832{
833 return qtest_clock_step(global_qtest, step);
834}
49ee3590
AL
835
836/**
837 * clock_set:
838 * @val: Nanoseconds value to advance the clock to.
839 *
bc72ad67 840 * Advance the QEMU_CLOCK_VIRTUAL to @val nanoseconds since the VM was launched.
6acf801d 841 *
bc72ad67 842 * Returns: The current value of the QEMU_CLOCK_VIRTUAL in nanoseconds.
49ee3590 843 */
6acf801d
AF
844static inline int64_t clock_set(int64_t val)
845{
846 return qtest_clock_set(global_qtest, val);
847}
49ee3590 848
46e0cf76
MM
849/**
850 * qtest_big_endian:
851 *
852 * Returns: True if the architecture under test has a big endian configuration.
853 */
854bool qtest_big_endian(void);
855
dc47995e
MAL
856
857QDict *qmp_fd_receive(int fd);
858void qmp_fd_sendv(int fd, const char *fmt, va_list ap);
859void qmp_fd_send(int fd, const char *fmt, ...);
860QDict *qmp_fdv(int fd, const char *fmt, va_list ap);
861QDict *qmp_fd(int fd, const char *fmt, ...);
862
49ee3590 863#endif