2 * QEMU Host Memory Backend
4 * Copyright (C) 2013-2014 Red Hat Inc
7 * Igor Mammedov <imammedo@redhat.com>
9 * This work is licensed under the terms of the GNU GPL, version 2 or later.
10 * See the COPYING file in the top-level directory.
13 #ifndef SYSEMU_HOSTMEM_H
14 #define SYSEMU_HOSTMEM_H
16 #include "sysemu/numa.h"
17 #include "qapi/qapi-types-machine.h"
18 #include "qom/object.h"
19 #include "exec/memory.h"
20 #include "qemu/bitmap.h"
22 #define TYPE_MEMORY_BACKEND "memory-backend"
23 OBJECT_DECLARE_TYPE(HostMemoryBackend
, HostMemoryBackendClass
,
28 * @TYPE_MEMORY_BACKEND_RAM:
29 * name of backend that uses mmap on the anonymous RAM
32 #define TYPE_MEMORY_BACKEND_RAM "memory-backend-ram"
36 * @TYPE_MEMORY_BACKEND_FILE:
37 * name of backend that uses mmap on a file descriptor
39 #define TYPE_MEMORY_BACKEND_FILE "memory-backend-file"
43 * HostMemoryBackendClass:
44 * @parent_class: opaque parent class container
46 struct HostMemoryBackendClass
{
47 ObjectClass parent_class
;
49 void (*alloc
)(HostMemoryBackend
*backend
, Error
**errp
);
55 * @parent: opaque parent object container
56 * @size: amount of memory backend provides
57 * @mr: MemoryRegion representing host memory belonging to backend
58 * @prealloc_threads: number of threads to be used for preallocatining RAM
60 struct HostMemoryBackend
{
66 bool merge
, dump
, use_canonical_path
;
67 bool prealloc
, is_mapped
, share
, reserve
;
68 uint32_t prealloc_threads
;
69 DECLARE_BITMAP(host_nodes
, MAX_NODES
+ 1);
75 bool host_memory_backend_mr_inited(HostMemoryBackend
*backend
);
76 MemoryRegion
*host_memory_backend_get_memory(HostMemoryBackend
*backend
);
78 void host_memory_backend_set_mapped(HostMemoryBackend
*backend
, bool mapped
);
79 bool host_memory_backend_is_mapped(HostMemoryBackend
*backend
);
80 size_t host_memory_backend_pagesize(HostMemoryBackend
*memdev
);
81 char *host_memory_backend_get_name(HostMemoryBackend
*backend
);