libqos.h 1.2 KB
Newer Older
1 2
#ifndef LIBQOS_H
#define LIBQOS_H
J
John Snow 已提交
3 4 5

#include "libqtest.h"
#include "libqos/pci.h"
6
#include "libqos/malloc.h"
J
John Snow 已提交
7

8 9
typedef struct QOSState QOSState;

J
John Snow 已提交
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 *);
J
John Snow 已提交
15 16
} QOSOps;

17
struct QOSState {
J
John Snow 已提交
18
    QTestState *qts;
19
    QGuestAllocator alloc;
20
    QPCIBus *pcibus;
J
John Snow 已提交
21
    QOSOps *ops;
22
};
J
John Snow 已提交
23

J
John Snow 已提交
24 25
QOSState *qtest_vboot(QOSOps *ops, const char *cmdline_fmt, va_list ap);
QOSState *qtest_boot(QOSOps *ops, const char *cmdline_fmt, ...);
26
void qtest_common_shutdown(QOSState *qs);
J
John Snow 已提交
27
void qtest_shutdown(QOSState *qs);
J
John Snow 已提交
28
bool have_qemu_img(void);
29 30
void mkimg(const char *file, const char *fmt, unsigned size_mb);
void mkqcow2(const char *file, unsigned size_mb);
J
John Snow 已提交
31
void migrate(QOSState *from, QOSState *to, const char *uri);
J
John Snow 已提交
32
void prepare_blkdebug_script(const char *debug_fn, const char *event);
J
John Snow 已提交
33
void generate_pattern(void *buffer, size_t len, size_t cycle_len);
J
John Snow 已提交
34 35 36

static inline uint64_t qmalloc(QOSState *q, size_t bytes)
{
37
    return guest_alloc(&q->alloc, bytes);
J
John Snow 已提交
38 39 40 41
}

static inline void qfree(QOSState *q, uint64_t addr)
{
42
    guest_free(&q->alloc, addr);
J
John Snow 已提交
43 44 45
}

#endif