xref: /openbmc/qemu/tests/qtest/libqos/libqos.h (revision 6832189f)
1 #ifndef LIBQOS_H
2 #define LIBQOS_H
3 
4 #include "../libqtest.h"
5 #include "pci.h"
6 #include "libqos-malloc.h"
7 
8 typedef struct QOSState QOSState;
9 
10 typedef struct QOSOps {
11     void (*alloc_init)(QGuestAllocator *, QTestState *, QAllocOpts);
12     QPCIBus *(*qpci_new)(QTestState *qts, QGuestAllocator *alloc);
13     void (*qpci_free)(QPCIBus *bus);
14     void (*shutdown)(QOSState *);
15 } QOSOps;
16 
17 struct QOSState {
18     QTestState *qts;
19     QGuestAllocator alloc;
20     QPCIBus *pcibus;
21     QOSOps *ops;
22 };
23 
24 QOSState *qtest_vboot(QOSOps *ops, const char *cmdline_fmt, va_list ap)
25     G_GNUC_PRINTF(2, 0);
26 QOSState *qtest_boot(QOSOps *ops, const char *cmdline_fmt, ...)
27     G_GNUC_PRINTF(2, 3);
28 void qtest_common_shutdown(QOSState *qs);
29 void qtest_shutdown(QOSState *qs);
30 bool have_qemu_img(void);
31 void mkimg(const char *file, const char *fmt, unsigned size_mb);
32 void mkqcow2(const char *file, unsigned size_mb);
33 void migrate(QOSState *from, QOSState *to, const char *uri);
34 void prepare_blkdebug_script(const char *debug_fn, const char *event);
35 void generate_pattern(void *buffer, size_t len, size_t cycle_len);
36 
37 static inline uint64_t qmalloc(QOSState *q, size_t bytes)
38 {
39     return guest_alloc(&q->alloc, bytes);
40 }
41 
42 static inline void qfree(QOSState *q, uint64_t addr)
43 {
44     guest_free(&q->alloc, addr);
45 }
46 
47 #endif
48