mem: add share parameter to memory-backend-ram
[qemu.git] / include / sysemu / hostmem.h
blobd5ab0b99c6164fa649c6915a3246d0a3c0eab79a
1 /*
2 * QEMU Host Memory Backend
4 * Copyright (C) 2013-2014 Red Hat Inc
6 * Authors:
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/sysemu.h" /* for MAX_NODES */
17 #include "qom/object.h"
18 #include "exec/memory.h"
19 #include "qemu/bitmap.h"
21 #define TYPE_MEMORY_BACKEND "memory-backend"
22 #define MEMORY_BACKEND(obj) \
23 OBJECT_CHECK(HostMemoryBackend, (obj), TYPE_MEMORY_BACKEND)
24 #define MEMORY_BACKEND_GET_CLASS(obj) \
25 OBJECT_GET_CLASS(HostMemoryBackendClass, (obj), TYPE_MEMORY_BACKEND)
26 #define MEMORY_BACKEND_CLASS(klass) \
27 OBJECT_CLASS_CHECK(HostMemoryBackendClass, (klass), TYPE_MEMORY_BACKEND)
29 typedef struct HostMemoryBackend HostMemoryBackend;
30 typedef struct HostMemoryBackendClass HostMemoryBackendClass;
32 /**
33 * HostMemoryBackendClass:
34 * @parent_class: opaque parent class container
36 struct HostMemoryBackendClass {
37 ObjectClass parent_class;
39 void (*alloc)(HostMemoryBackend *backend, Error **errp);
42 /**
43 * @HostMemoryBackend
45 * @parent: opaque parent object container
46 * @size: amount of memory backend provides
47 * @mr: MemoryRegion representing host memory belonging to backend
49 struct HostMemoryBackend {
50 /* private */
51 Object parent;
53 /* protected */
54 char *id;
55 uint64_t size;
56 bool merge, dump;
57 bool prealloc, force_prealloc, is_mapped, share;
58 DECLARE_BITMAP(host_nodes, MAX_NODES + 1);
59 HostMemPolicy policy;
61 MemoryRegion mr;
64 bool host_memory_backend_mr_inited(HostMemoryBackend *backend);
65 MemoryRegion *host_memory_backend_get_memory(HostMemoryBackend *backend,
66 Error **errp);
68 void host_memory_backend_set_mapped(HostMemoryBackend *backend, bool mapped);
69 bool host_memory_backend_is_mapped(HostMemoryBackend *backend);
70 #endif