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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
|
/*
* capabilities.h: hypervisor capabilities
*
* Copyright (C) 2006-2019 Red Hat, Inc.
* Copyright (C) 2006-2008 Daniel P. Berrange
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "internal.h"
#include "virconftypes.h"
#include "cpu_conf.h"
#include "virarch.h"
#include "virobject.h"
#include "virresctrl.h"
#include <libxml/xpath.h>
typedef enum {
VIR_CAPS_GUEST_FEATURE_TYPE_PAE = 0,
VIR_CAPS_GUEST_FEATURE_TYPE_NONPAE,
VIR_CAPS_GUEST_FEATURE_TYPE_IA64_BE,
VIR_CAPS_GUEST_FEATURE_TYPE_ACPI,
VIR_CAPS_GUEST_FEATURE_TYPE_APIC,
VIR_CAPS_GUEST_FEATURE_TYPE_CPUSELECTION,
VIR_CAPS_GUEST_FEATURE_TYPE_DEVICEBOOT,
VIR_CAPS_GUEST_FEATURE_TYPE_DISKSNAPSHOT,
VIR_CAPS_GUEST_FEATURE_TYPE_HAP,
VIR_CAPS_GUEST_FEATURE_TYPE_LAST
} virCapsGuestFeatureType;
struct _virCapsGuestFeature {
bool present;
virTristateSwitch defaultOn;
virTristateBool toggle;
};
struct _virCapsGuestMachine {
char *name;
char *canonical;
unsigned int maxCpus;
bool deprecated;
};
struct _virCapsGuestDomainInfo {
char *emulator;
char *loader;
int nmachines;
virCapsGuestMachine **machines;
};
struct _virCapsGuestDomain {
int type; /* virDomainVirtType */
virCapsGuestDomainInfo info;
};
struct _virCapsGuestArch {
virArch id;
unsigned int wordsize;
virCapsGuestDomainInfo defaultInfo;
size_t ndomains;
size_t ndomains_max;
virCapsGuestDomain **domains;
};
struct _virCapsGuest {
int ostype;
virCapsGuestArch arch;
virCapsGuestFeature features[VIR_CAPS_GUEST_FEATURE_TYPE_LAST];
};
struct _virCapsHostNUMACellCPU {
unsigned int id;
unsigned int socket_id;
unsigned int die_id;
unsigned int core_id;
virBitmap *siblings;
};
struct _virCapsHostNUMACellPageInfo {
unsigned int size; /* page size in kibibytes */
unsigned long long avail; /* the size of pool */
};
struct _virCapsHostNUMACell {
int num;
int ncpus;
unsigned long long mem; /* in kibibytes */
virCapsHostNUMACellCPU *cpus;
size_t ndistances;
virNumaDistance *distances;
int npageinfo;
virCapsHostNUMACellPageInfo *pageinfo;
GArray *caches; /* virNumaCache */
};
struct _virCapsHostNUMA {
gint refs;
GPtrArray *cells;
GArray *interconnects; /* virNumaInterconnect */
};
struct _virCapsHostSecModelLabel {
char *type;
char *label;
};
struct _virCapsHostSecModel {
char *model;
char *doi;
size_t nlabels;
virCapsHostSecModelLabel *labels;
};
struct _virCapsHostCacheBank {
unsigned int id;
unsigned int level; /* 1=L1, 2=L2, 3=L3, etc. */
unsigned long long size; /* B */
virCacheType type; /* Data, Instruction or Unified */
virBitmap *cpus; /* All CPUs that share this bank */
size_t ncontrols;
virResctrlInfoPerCache **controls;
};
void virCapsHostCacheBankFree(virCapsHostCacheBank *ptr);
G_DEFINE_AUTOPTR_CLEANUP_FUNC(virCapsHostCacheBank, virCapsHostCacheBankFree);
struct _virCapsHostCache {
size_t nbanks;
virCapsHostCacheBank **banks;
virResctrlInfoMon *monitor;
};
struct _virCapsHostMemBWNode {
unsigned int id;
virBitmap *cpus; /* All CPUs that belong to this node */
virResctrlInfoMemBWPerNode control;
};
struct _virCapsHostMemBW {
size_t nnodes;
virCapsHostMemBWNode **nodes;
virResctrlInfoMon *monitor;
};
struct _virCapsHost {
virArch arch;
size_t nfeatures;
size_t nfeatures_max;
char **features;
unsigned int powerMgmt; /* Bitmask of the PM capabilities.
* See enum virHostPMCapability.
*/
bool offlineMigrate;
bool liveMigrate;
size_t nmigrateTrans;
size_t nmigrateTrans_max;
char **migrateTrans;
virCapsHostNUMA *numa;
virResctrlInfo *resctrl;
virCapsHostCache cache;
virCapsHostMemBW memBW;
size_t nsecModels;
virCapsHostSecModel *secModels;
char *netprefix;
virCPUDef *cpu;
int nPagesSize; /* size of pagesSize array */
unsigned int *pagesSize; /* page sizes support on the system */
unsigned char host_uuid[VIR_UUID_BUFLEN];
bool iommu;
};
struct _virCapsStoragePool {
int type;
};
struct _virCaps {
virObject parent;
virCapsHost host;
size_t nguests;
size_t nguests_max;
virCapsGuest **guests;
size_t npools;
size_t npools_max;
virCapsStoragePool **pools;
};
G_DEFINE_AUTOPTR_CLEANUP_FUNC(virCaps, virObjectUnref);
struct _virCapsDomainData {
int ostype;
int arch;
int domaintype; /* virDomainVirtType */
const char *emulator;
const char *machinetype;
};
virCaps *
virCapabilitiesNew(virArch hostarch,
bool offlineMigrate,
bool liveMigrate);
void
virCapabilitiesHostNUMAUnref(virCapsHostNUMA *caps);
void
virCapabilitiesHostNUMARef(virCapsHostNUMA *caps);
G_DEFINE_AUTOPTR_CLEANUP_FUNC(virCapsHostNUMA, virCapabilitiesHostNUMAUnref);
int
virCapabilitiesAddHostFeature(virCaps *caps,
const char *name);
int
virCapabilitiesAddHostMigrateTransport(virCaps *caps,
const char *name);
int
virCapabilitiesSetNetPrefix(virCaps *caps,
const char *prefix);
void
virCapabilitiesHostNUMAAddCell(virCapsHostNUMA *caps,
int num,
unsigned long long mem,
int ncpus,
virCapsHostNUMACellCPU **cpus,
int ndistances,
virNumaDistance **distances,
int npageinfo,
virCapsHostNUMACellPageInfo **pageinfo,
GArray **caches);
virCapsGuestMachine **
virCapabilitiesAllocMachines(const char *const *names,
int *nnames);
void
virCapabilitiesFreeGuest(virCapsGuest *guest);
virCapsGuest *
virCapabilitiesAddGuest(virCaps *caps,
int ostype,
virArch arch,
const char *emulator,
const char *loader,
int nmachines,
virCapsGuestMachine **machines);
virCapsGuestDomain *
virCapabilitiesAddGuestDomain(virCapsGuest *guest,
int hvtype,
const char *emulator,
const char *loader,
int nmachines,
virCapsGuestMachine **machines);
void
virCapabilitiesAddGuestFeature(virCapsGuest *guest,
virCapsGuestFeatureType feature);
void
virCapabilitiesAddGuestFeatureWithToggle(virCapsGuest *guest,
virCapsGuestFeatureType feature,
bool defaultOn,
bool toggle);
int
virCapabilitiesAddStoragePool(virCaps *caps,
int poolType);
int
virCapabilitiesHostSecModelAddBaseLabel(virCapsHostSecModel *secmodel,
const char *type,
const char *label);
virCapsDomainData *
virCapabilitiesDomainDataLookup(virCaps *caps,
int ostype,
virArch arch,
int domaintype,
const char *emulator,
const char *machinetype);
bool
virCapabilitiesDomainSupported(virCaps *caps,
int ostype,
virArch arch,
int domaintype);
void
virCapabilitiesClearHostNUMACellCPUTopology(virCapsHostNUMACellCPU *cpu,
size_t ncpus);
char *
virCapabilitiesFormatXML(virCaps *caps);
virBitmap *virCapabilitiesHostNUMAGetCpus(virCapsHostNUMA *caps,
virBitmap *nodemask);
int virCapabilitiesHostNUMAGetMaxNode(virCapsHostNUMA *caps);
int virCapabilitiesGetNodeInfo(virNodeInfoPtr nodeinfo);
int virCapabilitiesInitPages(virCaps *caps);
virCapsHostNUMA *virCapabilitiesHostNUMANew(void);
virCapsHostNUMA *virCapabilitiesHostNUMANewHost(void);
bool virCapsHostCacheBankEquals(virCapsHostCacheBank *a,
virCapsHostCacheBank *b);
void virCapsHostCacheBankFree(virCapsHostCacheBank *ptr);
int virCapabilitiesInitCaches(virCaps *caps);
void virCapabilitiesHostInitIOMMU(virCaps *caps);
|