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
22#define TYPE_MEMORY_BACKEND "memory-backend"
23OBJECT_DECLARE_TYPE(HostMemoryBackend, HostMemoryBackendClass,
24 MEMORY_BACKEND)
25
26
27
28
29
30
31
32#define TYPE_MEMORY_BACKEND_RAM "memory-backend-ram"
33
34
35
36
37
38
39#define TYPE_MEMORY_BACKEND_FILE "memory-backend-file"
40
41
42
43
44
45
46struct HostMemoryBackendClass {
47 ObjectClass parent_class;
48
49 void (*alloc)(HostMemoryBackend *backend, Error **errp);
50};
51
52
53
54
55
56
57
58
59
60struct HostMemoryBackend {
61
62 Object parent;
63
64
65 uint64_t size;
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);
70 HostMemPolicy policy;
71
72 MemoryRegion mr;
73};
74
75bool host_memory_backend_mr_inited(HostMemoryBackend *backend);
76MemoryRegion *host_memory_backend_get_memory(HostMemoryBackend *backend);
77
78void host_memory_backend_set_mapped(HostMemoryBackend *backend, bool mapped);
79bool host_memory_backend_is_mapped(HostMemoryBackend *backend);
80size_t host_memory_backend_pagesize(HostMemoryBackend *memdev);
81char *host_memory_backend_get_name(HostMemoryBackend *backend);
82
83#endif
84