xref: /qemu/tests/qtest/libqos/libqos.h (revision 122fdf2d8822699482723e6f50f34c9c3933360b)
1dd0029c0SJohn Snow #ifndef __libqos_h
2dd0029c0SJohn Snow #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 
890e5add6SJohn Snow typedef struct QOSOps {
990e5add6SJohn Snow     QGuestAllocator *(*init_allocator)(QAllocOpts);
1090e5add6SJohn Snow     void (*uninit_allocator)(QGuestAllocator *);
1190e5add6SJohn Snow } QOSOps;
1290e5add6SJohn Snow 
13dd0029c0SJohn Snow typedef struct QOSState {
14dd0029c0SJohn Snow     QTestState *qts;
15dd0029c0SJohn Snow     QGuestAllocator *alloc;
1690e5add6SJohn Snow     QOSOps *ops;
17dd0029c0SJohn Snow } QOSState;
18dd0029c0SJohn Snow 
1990e5add6SJohn Snow QOSState *qtest_vboot(QOSOps *ops, const char *cmdline_fmt, va_list ap);
2090e5add6SJohn Snow QOSState *qtest_boot(QOSOps *ops, const char *cmdline_fmt, ...);
21dd0029c0SJohn Snow void qtest_shutdown(QOSState *qs);
22*122fdf2dSJohn Snow void mkimg(const char *file, const char *fmt, unsigned size_mb);
23*122fdf2dSJohn Snow void mkqcow2(const char *file, unsigned size_mb);
24dd0029c0SJohn Snow 
25dd0029c0SJohn Snow static inline uint64_t qmalloc(QOSState *q, size_t bytes)
26dd0029c0SJohn Snow {
27dd0029c0SJohn Snow     return guest_alloc(q->alloc, bytes);
28dd0029c0SJohn Snow }
29dd0029c0SJohn Snow 
30dd0029c0SJohn Snow static inline void qfree(QOSState *q, uint64_t addr)
31dd0029c0SJohn Snow {
32dd0029c0SJohn Snow     guest_free(q->alloc, addr);
33dd0029c0SJohn Snow }
34dd0029c0SJohn Snow 
35dd0029c0SJohn Snow #endif
36