]> git.proxmox.com Git - mirror_qemu.git/blame - include/sysemu/hostmem.h
hostmem: add property to map memory with MAP_SHARED
[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 */
12#ifndef QEMU_RAM_H
13#define QEMU_RAM_H
14
15#include "qom/object.h"
16#include "qapi/error.h"
17#include "exec/memory.h"
18#include "qemu/option.h"
19
20#define TYPE_MEMORY_BACKEND "memory-backend"
21#define MEMORY_BACKEND(obj) \
22 OBJECT_CHECK(HostMemoryBackend, (obj), TYPE_MEMORY_BACKEND)
23#define MEMORY_BACKEND_GET_CLASS(obj) \
24 OBJECT_GET_CLASS(HostMemoryBackendClass, (obj), TYPE_MEMORY_BACKEND)
25#define MEMORY_BACKEND_CLASS(klass) \
26 OBJECT_CLASS_CHECK(HostMemoryBackendClass, (klass), TYPE_MEMORY_BACKEND)
27
28typedef struct HostMemoryBackend HostMemoryBackend;
29typedef struct HostMemoryBackendClass HostMemoryBackendClass;
30
31/**
32 * HostMemoryBackendClass:
33 * @parent_class: opaque parent class container
34 */
35struct HostMemoryBackendClass {
36 ObjectClass parent_class;
bd9262d9
HT
37
38 void (*alloc)(HostMemoryBackend *backend, Error **errp);
1f070489
IM
39};
40
41/**
42 * @HostMemoryBackend
43 *
44 * @parent: opaque parent object container
45 * @size: amount of memory backend provides
46 * @id: unique identification string in memdev namespace
47 * @mr: MemoryRegion representing host memory belonging to backend
48 */
49struct HostMemoryBackend {
50 /* private */
51 Object parent;
52
53 /* protected */
54 uint64_t size;
605d0a94 55 bool merge, dump;
a35ba7be 56 bool prealloc, force_prealloc;
1f070489
IM
57
58 MemoryRegion mr;
59};
60
61MemoryRegion *host_memory_backend_get_memory(HostMemoryBackend *backend,
62 Error **errp);
63
64#endif