]> git.proxmox.com Git - mirror_qemu.git/blame - include/sysemu/hostmem.h
Use DECLARE_*CHECKER* macros
[mirror_qemu.git] / include / sysemu / hostmem.h
CommitLineData
1f070489
IM
1/*
2 * QEMU Host Memory Backend
3 *
4 * Copyright (C) 2013-2014 Red Hat Inc
5 *
6 * Authors:
7 * Igor Mammedov <imammedo@redhat.com>
8 *
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.
11 */
121d0712
MA
12
13#ifndef SYSEMU_HOSTMEM_H
14#define SYSEMU_HOSTMEM_H
1f070489 15
b58c5c2d 16#include "sysemu/numa.h"
8ac25c84 17#include "qapi/qapi-types-machine.h"
1f070489 18#include "qom/object.h"
1f070489 19#include "exec/memory.h"
4cf1b76b 20#include "qemu/bitmap.h"
1f070489
IM
21
22#define TYPE_MEMORY_BACKEND "memory-backend"
db1015e9
EH
23typedef struct HostMemoryBackend HostMemoryBackend;
24typedef struct HostMemoryBackendClass HostMemoryBackendClass;
8110fa1d
EH
25DECLARE_OBJ_CHECKERS(HostMemoryBackend, HostMemoryBackendClass,
26 MEMORY_BACKEND, TYPE_MEMORY_BACKEND)
1f070489 27
900c0ba3
IM
28/* hostmem-ram.c */
29/**
30 * @TYPE_MEMORY_BACKEND_RAM:
31 * name of backend that uses mmap on the anonymous RAM
32 */
33
34#define TYPE_MEMORY_BACKEND_RAM "memory-backend-ram"
35
36/* hostmem-file.c */
37/**
38 * @TYPE_MEMORY_BACKEND_FILE:
39 * name of backend that uses mmap on a file descriptor
40 */
41#define TYPE_MEMORY_BACKEND_FILE "memory-backend-file"
42
1f070489
IM
43
44/**
45 * HostMemoryBackendClass:
46 * @parent_class: opaque parent class container
47 */
48struct HostMemoryBackendClass {
49 ObjectClass parent_class;
bd9262d9
HT
50
51 void (*alloc)(HostMemoryBackend *backend, Error **errp);
1f070489
IM
52};
53
54/**
55 * @HostMemoryBackend
56 *
57 * @parent: opaque parent object container
58 * @size: amount of memory backend provides
1f070489 59 * @mr: MemoryRegion representing host memory belonging to backend
ffac16fa 60 * @prealloc_threads: number of threads to be used for preallocatining RAM
1f070489
IM
61 */
62struct HostMemoryBackend {
63 /* private */
64 Object parent;
65
66 /* protected */
67 uint64_t size;
fa0cb34d 68 bool merge, dump, use_canonical_path;
4ebc74db 69 bool prealloc, is_mapped, share;
ffac16fa 70 uint32_t prealloc_threads;
4cf1b76b
HT
71 DECLARE_BITMAP(host_nodes, MAX_NODES + 1);
72 HostMemPolicy policy;
1f070489
IM
73
74 MemoryRegion mr;
75};
76
4728b574 77bool host_memory_backend_mr_inited(HostMemoryBackend *backend);
7943e97b 78MemoryRegion *host_memory_backend_get_memory(HostMemoryBackend *backend);
1f070489 79
2aece63c
XG
80void host_memory_backend_set_mapped(HostMemoryBackend *backend, bool mapped);
81bool host_memory_backend_is_mapped(HostMemoryBackend *backend);
2b108085 82size_t host_memory_backend_pagesize(HostMemoryBackend *memdev);
fa0cb34d 83char *host_memory_backend_get_name(HostMemoryBackend *backend);
2b108085 84
1f070489 85#endif