1
2
3
4
5
6
7
8
9
10
11
12
13#ifndef LIBQOS_MALLOC_H
14#define LIBQOS_MALLOC_H
15
16#include "qemu/queue.h"
17#include "libqtest.h"
18
19typedef enum {
20 ALLOC_NO_FLAGS = 0x00,
21 ALLOC_LEAK_WARN = 0x01,
22 ALLOC_LEAK_ASSERT = 0x02,
23 ALLOC_PARANOID = 0x04
24} QAllocOpts;
25
26typedef QTAILQ_HEAD(MemList, MemBlock) MemList;
27
28typedef struct QGuestAllocator {
29 QAllocOpts opts;
30 uint64_t start;
31 uint64_t end;
32 uint32_t page_size;
33
34 MemList *used;
35 MemList *free;
36} QGuestAllocator;
37
38
39uint64_t guest_alloc(QGuestAllocator *allocator, size_t size);
40void guest_free(QGuestAllocator *allocator, uint64_t addr);
41void migrate_allocator(QGuestAllocator *src, QGuestAllocator *dst);
42
43void alloc_set_flags(QGuestAllocator *allocator, QAllocOpts opts);
44
45void alloc_init(QGuestAllocator *alloc, QAllocOpts flags,
46 uint64_t start, uint64_t end,
47 size_t page_size);
48void alloc_destroy(QGuestAllocator *allocator);
49
50#endif
51