qemu/tests/libqos/malloc-pc.h
John Snow ec2f160538 libqos: add a simple first-fit memory allocator
Implement a simple first-fit memory allocator that
attempts to keep track of leased blocks of memory
in order to be able to re-use blocks.

Additionally, allow the user to specify when
initializing the device that upon cleanup,
we would like to assert that there are no
blocks in use. This may be useful for identifying
problems in qtests that use more complicated
set-up and tear-down routines.

This functionality is used in my upcoming ahci-test v2
patch set, but I didn't see fit to enable it for any
existing tests, which will continue to operate the
same as they have prior.

Signed-off-by: John Snow <jsnow@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2014-09-08 11:12:43 +01:00

30 lines
678 B
C

/*
* libqos malloc support for PC
*
* Copyright IBM, Corp. 2012-2013
*
* Authors:
* Anthony Liguori <aliguori@us.ibm.com>
*
* This work is licensed under the terms of the GNU GPL, version 2 or later.
* See the COPYING file in the top-level directory.
*/
#ifndef LIBQOS_MALLOC_PC_H
#define LIBQOS_MALLOC_PC_H
#include "libqos/malloc.h"
typedef enum {
PC_ALLOC_NO_FLAGS = 0x00,
PC_ALLOC_LEAK_WARN = 0x01,
PC_ALLOC_LEAK_ASSERT = 0x02,
PC_ALLOC_PARANOID = 0x04
} PCAllocOpts;
QGuestAllocator *pc_alloc_init(void);
QGuestAllocator *pc_alloc_init_flags(PCAllocOpts flags);
void pc_alloc_uninit(QGuestAllocator *allocator);
#endif