]> git.ipfire.org Git - thirdparty/qemu.git/blame - include/hw/virtio/virtio-mem.h
Move QOM typedefs and add missing includes
[thirdparty/qemu.git] / include / hw / virtio / virtio-mem.h
CommitLineData
910b2576
DH
1/*
2 * Virtio MEM device
3 *
4 * Copyright (C) 2020 Red Hat, Inc.
5 *
6 * Authors:
7 * David Hildenbrand <david@redhat.com>
8 *
9 * This work is licensed under the terms of the GNU GPL, version 2.
10 * See the COPYING file in the top-level directory.
11 */
12
13#ifndef HW_VIRTIO_MEM_H
14#define HW_VIRTIO_MEM_H
15
16#include "standard-headers/linux/virtio_mem.h"
17#include "hw/virtio/virtio.h"
18#include "qapi/qapi-types-misc.h"
19#include "sysemu/hostmem.h"
db1015e9 20#include "qom/object.h"
910b2576
DH
21
22#define TYPE_VIRTIO_MEM "virtio-mem"
23
db1015e9
EH
24typedef struct VirtIOMEM VirtIOMEM;
25typedef struct VirtIOMEMClass VirtIOMEMClass;
910b2576
DH
26#define VIRTIO_MEM(obj) \
27 OBJECT_CHECK(VirtIOMEM, (obj), TYPE_VIRTIO_MEM)
28#define VIRTIO_MEM_CLASS(oc) \
29 OBJECT_CLASS_CHECK(VirtIOMEMClass, (oc), TYPE_VIRTIO_MEM)
30#define VIRTIO_MEM_GET_CLASS(obj) \
31 OBJECT_GET_CLASS(VirtIOMEMClass, (obj), TYPE_VIRTIO_MEM)
32
33#define VIRTIO_MEM_MEMDEV_PROP "memdev"
34#define VIRTIO_MEM_NODE_PROP "node"
35#define VIRTIO_MEM_SIZE_PROP "size"
36#define VIRTIO_MEM_REQUESTED_SIZE_PROP "requested-size"
37#define VIRTIO_MEM_BLOCK_SIZE_PROP "block-size"
38#define VIRTIO_MEM_ADDR_PROP "memaddr"
39
db1015e9 40struct VirtIOMEM {
910b2576
DH
41 VirtIODevice parent_obj;
42
43 /* guest -> host request queue */
44 VirtQueue *vq;
45
46 /* bitmap used to track unplugged memory */
47 int32_t bitmap_size;
48 unsigned long *bitmap;
49
50 /* assigned memory backend and memory region */
51 HostMemoryBackend *memdev;
52
53 /* NUMA node */
54 uint32_t node;
55
56 /* assigned address of the region in guest physical memory */
57 uint64_t addr;
58
59 /* usable region size (<= region_size) */
60 uint64_t usable_region_size;
61
62 /* actual size (how much the guest plugged) */
63 uint64_t size;
64
65 /* requested size */
66 uint64_t requested_size;
67
68 /* block size and alignment */
69 uint64_t block_size;
c95b4437
DH
70
71 /* notifiers to notify when "size" changes */
72 NotifierList size_change_notifiers;
0bc7806c
DH
73
74 /* don't migrate unplugged memory */
75 NotifierWithReturn precopy_notifier;
db1015e9 76};
910b2576 77
db1015e9 78struct VirtIOMEMClass {
910b2576
DH
79 /* private */
80 VirtIODevice parent;
81
82 /* public */
83 void (*fill_device_info)(const VirtIOMEM *vmen, VirtioMEMDeviceInfo *vi);
84 MemoryRegion *(*get_memory_region)(VirtIOMEM *vmem, Error **errp);
c95b4437
DH
85 void (*add_size_change_notifier)(VirtIOMEM *vmem, Notifier *notifier);
86 void (*remove_size_change_notifier)(VirtIOMEM *vmem, Notifier *notifier);
db1015e9 87};
910b2576
DH
88
89#endif