]> git.proxmox.com Git - mirror_qemu.git/blame - include/sysemu/hostmem.h
Merge remote-tracking branch 'remotes/maxreitz/tags/pull-block-2021-05-14' into staging
[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"
c821774a 23OBJECT_DECLARE_TYPE(HostMemoryBackend, HostMemoryBackendClass,
30b5707c 24 MEMORY_BACKEND)
1f070489 25
900c0ba3
IM
26/* hostmem-ram.c */
27/**
28 * @TYPE_MEMORY_BACKEND_RAM:
29 * name of backend that uses mmap on the anonymous RAM
30 */
31
32#define TYPE_MEMORY_BACKEND_RAM "memory-backend-ram"
33
34/* hostmem-file.c */
35/**
36 * @TYPE_MEMORY_BACKEND_FILE:
37 * name of backend that uses mmap on a file descriptor
38 */
39#define TYPE_MEMORY_BACKEND_FILE "memory-backend-file"
40
1f070489
IM
41
42/**
43 * HostMemoryBackendClass:
44 * @parent_class: opaque parent class container
45 */
46struct HostMemoryBackendClass {
47 ObjectClass parent_class;
bd9262d9
HT
48
49 void (*alloc)(HostMemoryBackend *backend, Error **errp);
1f070489
IM
50};
51
52/**
53 * @HostMemoryBackend
54 *
55 * @parent: opaque parent object container
56 * @size: amount of memory backend provides
1f070489 57 * @mr: MemoryRegion representing host memory belonging to backend
ffac16fa 58 * @prealloc_threads: number of threads to be used for preallocatining RAM
1f070489
IM
59 */
60struct HostMemoryBackend {
61 /* private */
62 Object parent;
63
64 /* protected */
65 uint64_t size;
fa0cb34d 66 bool merge, dump, use_canonical_path;
4ebc74db 67 bool prealloc, is_mapped, share;
ffac16fa 68 uint32_t prealloc_threads;
4cf1b76b
HT
69 DECLARE_BITMAP(host_nodes, MAX_NODES + 1);
70 HostMemPolicy policy;
1f070489
IM
71
72 MemoryRegion mr;
73};
74
4728b574 75bool host_memory_backend_mr_inited(HostMemoryBackend *backend);
7943e97b 76MemoryRegion *host_memory_backend_get_memory(HostMemoryBackend *backend);
1f070489 77
2aece63c
XG
78void host_memory_backend_set_mapped(HostMemoryBackend *backend, bool mapped);
79bool host_memory_backend_is_mapped(HostMemoryBackend *backend);
2b108085 80size_t host_memory_backend_pagesize(HostMemoryBackend *memdev);
fa0cb34d 81char *host_memory_backend_get_name(HostMemoryBackend *backend);
2b108085 82
1f070489 83#endif