aboutsummaryrefslogtreecommitdiff
path: root/tests/libqos/malloc.h
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2018-11-29 12:37:04 +0100
committerPaolo Bonzini <pbonzini@redhat.com>2019-03-07 17:28:07 +0100
commiteb5937bad691ed18a401079a0604aa11fea0ecdd (patch)
treea26310ca140c15230c51cceeebc538f7f55b7888 /tests/libqos/malloc.h
parent143e6db6fa4ecd2a85de740cc3754aeb86d1e802 (diff)
downloadqemu-eb5937bad691ed18a401079a0604aa11fea0ecdd.zip
qemu-eb5937bad691ed18a401079a0604aa11fea0ecdd.tar.gz
qemu-eb5937bad691ed18a401079a0604aa11fea0ecdd.tar.bz2
tests/libqos: embed allocators instead of malloc-ing them separately
qgraph will embed these objects instead of allocating them in a separate object. Expose a new API "generic_alloc_init" and "generic_alloc_destroy" for that, and rename the existing API with s/init/new/ and s/uninit/free/. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'tests/libqos/malloc.h')
-rw-r--r--tests/libqos/malloc.h21
1 files changed, 15 insertions, 6 deletions
diff --git a/tests/libqos/malloc.h b/tests/libqos/malloc.h
index 828fdda..4d1a2e2 100644
--- a/tests/libqos/malloc.h
+++ b/tests/libqos/malloc.h
@@ -23,19 +23,28 @@ typedef enum {
ALLOC_PARANOID = 0x04
} QAllocOpts;
-typedef struct QGuestAllocator QGuestAllocator;
+typedef QTAILQ_HEAD(MemList, MemBlock) MemList;
-void alloc_uninit(QGuestAllocator *allocator);
+typedef struct QGuestAllocator {
+ QAllocOpts opts;
+ uint64_t start;
+ uint64_t end;
+ uint32_t page_size;
+
+ MemList *used;
+ MemList *free;
+} QGuestAllocator;
/* Always returns page aligned values */
uint64_t guest_alloc(QGuestAllocator *allocator, size_t size);
void guest_free(QGuestAllocator *allocator, uint64_t addr);
void migrate_allocator(QGuestAllocator *src, QGuestAllocator *dst);
-QGuestAllocator *alloc_init(uint64_t start, uint64_t end);
-QGuestAllocator *alloc_init_flags(QAllocOpts flags,
- uint64_t start, uint64_t end);
-void alloc_set_page_size(QGuestAllocator *allocator, size_t page_size);
void alloc_set_flags(QGuestAllocator *allocator, QAllocOpts opts);
+void alloc_init(QGuestAllocator *alloc, QAllocOpts flags,
+ uint64_t start, uint64_t end,
+ size_t page_size);
+void alloc_destroy(QGuestAllocator *allocator);
+
#endif