1
2
3
4
5
6
7
8
9
10
11
12
13#ifndef SYSEMU_HOSTMEM_H
14#define SYSEMU_HOSTMEM_H
15
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"
21#include "qemu/thread-context.h"
22
23#define TYPE_MEMORY_BACKEND "memory-backend"
24OBJECT_DECLARE_TYPE(HostMemoryBackend, HostMemoryBackendClass,
25 MEMORY_BACKEND)
26
27
28
29
30
31
32
33#define TYPE_MEMORY_BACKEND_RAM "memory-backend-ram"
34
35
36
37
38
39
40#define TYPE_MEMORY_BACKEND_FILE "memory-backend-file"
41
42
43
44
45
46
47struct HostMemoryBackendClass {
48 ObjectClass parent_class;
49
50 void (*alloc)(HostMemoryBackend *backend, Error **errp);
51};
52
53
54
55
56
57
58
59
60
61struct HostMemoryBackend {
62
63 Object parent;
64
65
66 uint64_t size;
67 bool merge, dump, use_canonical_path;
68 bool prealloc, is_mapped, share, reserve;
69 uint32_t prealloc_threads;
70 ThreadContext *prealloc_context;
71 DECLARE_BITMAP(host_nodes, MAX_NODES + 1);
72 HostMemPolicy policy;
73
74 MemoryRegion mr;
75};
76
77bool host_memory_backend_mr_inited(HostMemoryBackend *backend);
78MemoryRegion *host_memory_backend_get_memory(HostMemoryBackend *backend);
79
80void host_memory_backend_set_mapped(HostMemoryBackend *backend, bool mapped);
81bool host_memory_backend_is_mapped(HostMemoryBackend *backend);
82size_t host_memory_backend_pagesize(HostMemoryBackend *memdev);
83char *host_memory_backend_get_name(HostMemoryBackend *backend);
84
85#endif
86