xref: /qemu/tests/qtest/libqos/libqos.h (revision 143e6db6fa4ecd2a85de740cc3754aeb86d1e802)
12a6a4076SMarkus Armbruster #ifndef LIBQOS_H
22a6a4076SMarkus Armbruster #define LIBQOS_H
3dd0029c0SJohn Snow 
4dd0029c0SJohn Snow #include "libqtest.h"
5dd0029c0SJohn Snow #include "libqos/pci.h"
6dd0029c0SJohn Snow #include "libqos/malloc-pc.h"
7dd0029c0SJohn Snow 
861ae5cf3SLaurent Vivier typedef struct QOSState QOSState;
961ae5cf3SLaurent Vivier 
1090e5add6SJohn Snow typedef struct QOSOps {
1105e520f1SEric Blake     QGuestAllocator *(*init_allocator)(QTestState *qts, QAllocOpts);
1290e5add6SJohn Snow     void (*uninit_allocator)(QGuestAllocator *);
13*143e6db6SEmanuele Giuseppe Esposito     QPCIBus *(*qpci_new)(QTestState *qts, QGuestAllocator *alloc);
142ecd7e2fSLaurent Vivier     void (*qpci_free)(QPCIBus *bus);
1561ae5cf3SLaurent Vivier     void (*shutdown)(QOSState *);
1690e5add6SJohn Snow } QOSOps;
1790e5add6SJohn Snow 
1861ae5cf3SLaurent Vivier struct QOSState {
19dd0029c0SJohn Snow     QTestState *qts;
20dd0029c0SJohn Snow     QGuestAllocator *alloc;
212ecd7e2fSLaurent Vivier     QPCIBus *pcibus;
2290e5add6SJohn Snow     QOSOps *ops;
2361ae5cf3SLaurent Vivier };
24dd0029c0SJohn Snow 
2590e5add6SJohn Snow QOSState *qtest_vboot(QOSOps *ops, const char *cmdline_fmt, va_list ap);
2690e5add6SJohn Snow QOSState *qtest_boot(QOSOps *ops, const char *cmdline_fmt, ...);
2761ae5cf3SLaurent Vivier void qtest_common_shutdown(QOSState *qs);
28dd0029c0SJohn Snow void qtest_shutdown(QOSState *qs);
29cb11e7b2SJohn Snow bool have_qemu_img(void);
30122fdf2dSJohn Snow void mkimg(const char *file, const char *fmt, unsigned size_mb);
31122fdf2dSJohn Snow void mkqcow2(const char *file, unsigned size_mb);
32085248aeSJohn Snow void set_context(QOSState *s);
33085248aeSJohn Snow void migrate(QOSState *from, QOSState *to, const char *uri);
3472c85e94SJohn Snow void prepare_blkdebug_script(const char *debug_fn, const char *event);
35ab4f7057SJohn Snow void generate_pattern(void *buffer, size_t len, size_t cycle_len);
36dd0029c0SJohn Snow 
37dd0029c0SJohn Snow static inline uint64_t qmalloc(QOSState *q, size_t bytes)
38dd0029c0SJohn Snow {
39dd0029c0SJohn Snow     return guest_alloc(q->alloc, bytes);
40dd0029c0SJohn Snow }
41dd0029c0SJohn Snow 
42dd0029c0SJohn Snow static inline void qfree(QOSState *q, uint64_t addr)
43dd0029c0SJohn Snow {
44dd0029c0SJohn Snow     guest_free(q->alloc, addr);
45dd0029c0SJohn Snow }
46dd0029c0SJohn Snow 
47dd0029c0SJohn Snow #endif
48