1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
|
/* $OpenBSD: ldomctl.h,v 1.9 2019/08/05 19:27:47 kettenis Exp $ */
/*
* Copyright (c) 2012 Mark Kettenis
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
struct core;
struct guest;
struct console {
uint64_t ino;
uint64_t resource_id;
uint64_t uartbase;
struct guest *guest;
struct ldc_endpoint *client_endpoint;
struct ldc_endpoint *server_endpoint;
struct md_node *hv_node;
TAILQ_ENTRY(console) link;
};
struct cpu {
uint64_t pid, vid, gid, partid;
uint64_t resource_id;
struct guest *guest;
struct md_node *hv_node;
struct core *core;
TAILQ_ENTRY(cpu) link;
};
struct device {
uint64_t gid;
uint64_t cfghandle;
uint64_t resource_id;
uint64_t rcid;
int virtual;
uint64_t num_msi_eqs;
uint64_t num_msis;
uint64_t msi_ranges[2];
uint64_t num_vpci;
uint64_t msi_eqs_per_vpci;
uint64_t msis_per_vpci;
uint64_t msi_base;
struct guest *guest;
struct md_node *hv_node;
TAILQ_ENTRY(device) link;
};
struct subdevice {
const char *path;
TAILQ_ENTRY(subdevice) link;
};
struct rootcomplex {
uint64_t num_msi_eqs;
uint64_t num_msis;
const void *msi_ranges;
int num_msi_ranges;
const void *vdma_ranges;
int num_vdma_ranges;
uint64_t cfghandle;
const char *path;
TAILQ_ENTRY(rootcomplex) link;
};
struct mblock {
uint64_t membase;
uint64_t memsize;
uint64_t realbase;
uint64_t resource_id;
struct guest *guest;
struct md_node *hv_node;
TAILQ_ENTRY(mblock) link;
};
struct ldc_endpoint {
uint64_t target_type;
uint64_t target_guest;
uint64_t channel;
uint64_t target_channel;
uint64_t tx_ino;
uint64_t rx_ino;
uint64_t resource_id;
uint64_t private_svc;
uint64_t svc_id;
struct guest *guest;
struct md_node *hv_node;
TAILQ_ENTRY(ldc_endpoint) link;
};
struct ldc_channel {
struct ldc_endpoint *client_endpoint;
struct ldc_endpoint *server_endpoint;
};
struct guest {
const char *name;
uint64_t gid;
uint64_t pid;
uint64_t resource_id;
uint64_t tod_offset;
uint64_t perfctraccess;
uint64_t perfctrhtaccess;
uint64_t rngctlaccessible;
uint64_t mdpa;
struct md_node *hv_node;
struct md *md;
uint64_t cpu_vid;
uint64_t endpoint_id;
struct console *console;
TAILQ_HEAD(, cpu) cpu_list;
int num_cpus;
TAILQ_HEAD(, device) device_list;
TAILQ_HEAD(, subdevice) subdevice_list;
TAILQ_HEAD(, mblock) mblock_list;
TAILQ_HEAD(, ldc_endpoint) endpoint_list;
struct ldc_channel domain_services;
struct ldc_channel vio[8];
int num_vios;
TAILQ_ENTRY(guest) link;
};
extern TAILQ_HEAD(guest_head, guest) guest_list;
void add_guest(struct md_node *);
extern struct md *hvmd;
extern uint64_t hv_mdpa;
extern uint64_t hv_membase;
extern uint64_t hv_memsize;
struct vdisk {
SIMPLEQ_ENTRY(vdisk) entry;
const char *path;
};
struct vnet {
SIMPLEQ_ENTRY(vnet) entry;
uint64_t mac_addr;
uint64_t mtu;
};
struct var {
SIMPLEQ_ENTRY(var) entry;
const char *name;
const char *str;
};
struct iodev {
SIMPLEQ_ENTRY(iodev) entry;
const char *path;
};
struct domain {
SIMPLEQ_ENTRY(domain) entry;
const char *name;
uint64_t vcpu, vcpu_stride;
uint64_t memory;
SIMPLEQ_HEAD(, vdisk) vdisk_list;
SIMPLEQ_HEAD(, vnet) vnet_list;
SIMPLEQ_HEAD(, var) var_list;
SIMPLEQ_HEAD(, iodev) iodev_list;
} *domain;
struct ldom_config {
SIMPLEQ_HEAD(, domain) domain_list;
};
int parse_config(const char *, struct ldom_config *);
void build_config(const char *);
|