capabilities.h 10.4 KB
Newer Older
1 2 3
/*
 * capabilities.h: hypervisor capabilities
 *
4
 * Copyright (C) 2006-2015 Red Hat, Inc.
5 6 7 8 9 10 11 12 13 14 15 16 17
 * 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
18
 * License along with this library.  If not, see
O
Osier Yang 已提交
19
 * <http://www.gnu.org/licenses/>.
20 21 22 23 24
 *
 * Author: Daniel P. Berrange <berrange@redhat.com>
 */

#ifndef __VIR_CAPABILITIES_H
25
# define __VIR_CAPABILITIES_H
26

27
# include "internal.h"
28
# include "virbuffer.h"
29
# include "cpu_conf.h"
30
# include "virarch.h"
31
# include "virmacaddr.h"
32
# include "virobject.h"
33

34
# include <libxml/xpath.h>
35

36 37 38 39
typedef struct _virCapsGuestFeature virCapsGuestFeature;
typedef virCapsGuestFeature *virCapsGuestFeaturePtr;
struct _virCapsGuestFeature {
    char *name;
40 41
    bool defaultOn;
    bool toggle;
42 43
};

44 45 46 47 48
typedef struct _virCapsGuestMachine virCapsGuestMachine;
typedef virCapsGuestMachine *virCapsGuestMachinePtr;
struct _virCapsGuestMachine {
    char *name;
    char *canonical;
49
    unsigned int maxCpus;
50 51
};

52 53 54 55 56 57
typedef struct _virCapsGuestDomainInfo virCapsGuestDomainInfo;
typedef virCapsGuestDomainInfo *virCapsGuestDomainInfoPtr;
struct _virCapsGuestDomainInfo {
    char *emulator;
    char *loader;
    int nmachines;
58
    virCapsGuestMachinePtr *machines;
59 60 61 62 63
};

typedef struct _virCapsGuestDomain virCapsGuestDomain;
typedef virCapsGuestDomain *virCapsGuestDomainPtr;
struct _virCapsGuestDomain {
64
    int type; /* virDomainVirtType */
65 66 67 68 69 70
    virCapsGuestDomainInfo info;
};

typedef struct _virCapsGuestArch virCapsGuestArch;
typedef virCapsGuestArch *virCapsGuestArchptr;
struct _virCapsGuestArch {
71 72
    virArch id;
    unsigned int wordsize;
73
    virCapsGuestDomainInfo defaultInfo;
E
Eric Blake 已提交
74 75
    size_t ndomains;
    size_t ndomains_max;
76 77 78 79 80 81
    virCapsGuestDomainPtr *domains;
};

typedef struct _virCapsGuest virCapsGuest;
typedef virCapsGuest *virCapsGuestPtr;
struct _virCapsGuest {
82
    int ostype;
83
    virCapsGuestArch arch;
E
Eric Blake 已提交
84 85
    size_t nfeatures;
    size_t nfeatures_max;
86 87 88
    virCapsGuestFeaturePtr *features;
};

89 90 91 92 93 94 95 96 97
typedef struct _virCapsHostNUMACellCPU virCapsHostNUMACellCPU;
typedef virCapsHostNUMACellCPU *virCapsHostNUMACellCPUPtr;
struct _virCapsHostNUMACellCPU {
    unsigned int id;
    unsigned int socket_id;
    unsigned int core_id;
    virBitmapPtr siblings;
};

98 99 100 101 102 103 104
typedef struct _virCapsHostNUMACellSiblingInfo virCapsHostNUMACellSiblingInfo;
typedef virCapsHostNUMACellSiblingInfo *virCapsHostNUMACellSiblingInfoPtr;
struct _virCapsHostNUMACellSiblingInfo {
    int node;               /* foreign NUMA node */
    unsigned int distance;  /* distance to the node */
};

M
Michal Privoznik 已提交
105 106 107 108 109 110 111
typedef struct _virCapsHostNUMACellPageInfo virCapsHostNUMACellPageInfo;
typedef virCapsHostNUMACellPageInfo *virCapsHostNUMACellPageInfoPtr;
struct _virCapsHostNUMACellPageInfo {
    unsigned int size;      /* page size in kibibytes */
    size_t avail;           /* the size of pool */
};

112 113 114 115 116
typedef struct _virCapsHostNUMACell virCapsHostNUMACell;
typedef virCapsHostNUMACell *virCapsHostNUMACellPtr;
struct _virCapsHostNUMACell {
    int num;
    int ncpus;
117
    unsigned long long mem; /* in kibibytes */
118
    virCapsHostNUMACellCPUPtr cpus;
119 120
    int nsiblings;
    virCapsHostNUMACellSiblingInfoPtr siblings;
M
Michal Privoznik 已提交
121 122
    int npageinfo;
    virCapsHostNUMACellPageInfoPtr pageinfo;
123 124
};

125 126 127 128 129 130 131
typedef struct _virCapsHostSecModelLabel virCapsHostSecModelLabel;
typedef virCapsHostSecModelLabel *virCapsHostSecModelLabelPtr;
struct _virCapsHostSecModelLabel {
    char *type;
    char *label;
};

132
typedef struct _virCapsHostSecModel virCapsHostSecModel;
133
typedef virCapsHostSecModel *virCapsHostSecModelPtr;
134 135 136
struct _virCapsHostSecModel {
    char *model;
    char *doi;
137 138
    size_t nlabels;
    virCapsHostSecModelLabelPtr labels;
139 140
};

141 142 143 144 145 146 147 148 149 150
typedef enum {
    VIR_CACHE_TYPE_BOTH,
    VIR_CACHE_TYPE_CODE,
    VIR_CACHE_TYPE_DATA,

    VIR_CACHE_TYPE_LAST
} virCacheType;

VIR_ENUM_DECL(virCache);

151 152 153 154 155 156 157 158
typedef struct _virCapsHostCacheControl virCapsHostCacheControl;
typedef virCapsHostCacheControl *virCapsHostCacheControlPtr;
struct _virCapsHostCacheControl {
    unsigned long long min; /* minimum cache control size in B */
    virCacheType scope;  /* data, code or both */
    unsigned int max_allocation; /* max number of supported allocations */
};

159 160 161 162 163 164 165 166
typedef struct _virCapsHostCacheBank virCapsHostCacheBank;
typedef virCapsHostCacheBank *virCapsHostCacheBankPtr;
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 */
    virBitmapPtr cpus;  /* All CPUs that share this bank */
167 168
    size_t ncontrols;
    virCapsHostCacheControlPtr *controls;
169 170
};

171 172 173
typedef struct _virCapsHost virCapsHost;
typedef virCapsHost *virCapsHostPtr;
struct _virCapsHost {
174
    virArch arch;
E
Eric Blake 已提交
175 176
    size_t nfeatures;
    size_t nfeatures_max;
177
    char **features;
178 179 180
    unsigned int powerMgmt;    /* Bitmask of the PM capabilities.
                                * See enum virHostPMCapability.
                                */
181 182
    bool offlineMigrate;
    bool liveMigrate;
E
Eric Blake 已提交
183 184
    size_t nmigrateTrans;
    size_t nmigrateTrans_max;
185
    char **migrateTrans;
E
Eric Blake 已提交
186 187
    size_t nnumaCell;
    size_t nnumaCell_max;
188
    virCapsHostNUMACellPtr *numaCell;
189

190 191 192
    size_t ncaches;
    virCapsHostCacheBankPtr *caches;

193 194 195
    size_t nsecModels;
    virCapsHostSecModelPtr secModels;

196
    char *netprefix;
197
    virCPUDefPtr cpu;
M
Michal Privoznik 已提交
198 199
    int nPagesSize;             /* size of pagesSize array */
    unsigned int *pagesSize;    /* page sizes support on the system */
200
    unsigned char host_uuid[VIR_UUID_BUFLEN];
201 202
};

203 204 205 206 207 208 209 210 211 212 213 214 215 216 217
typedef int (*virDomainDefNamespaceParse)(xmlDocPtr, xmlNodePtr,
                                          xmlXPathContextPtr, void **);
typedef void (*virDomainDefNamespaceFree)(void *);
typedef int (*virDomainDefNamespaceXMLFormat)(virBufferPtr, void *);
typedef const char *(*virDomainDefNamespaceHref)(void);

typedef struct _virDomainXMLNamespace virDomainXMLNamespace;
typedef virDomainXMLNamespace *virDomainXMLNamespacePtr;
struct _virDomainXMLNamespace {
    virDomainDefNamespaceParse parse;
    virDomainDefNamespaceFree free;
    virDomainDefNamespaceXMLFormat format;
    virDomainDefNamespaceHref href;
};

218
typedef struct _virCaps virCaps;
219
typedef virCaps *virCapsPtr;
220
struct _virCaps {
221 222
    virObject parent;

223
    virCapsHost host;
E
Eric Blake 已提交
224 225
    size_t nguests;
    size_t nguests_max;
226 227 228
    virCapsGuestPtr *guests;
};

229 230 231 232 233
typedef struct _virCapsDomainData virCapsDomainData;
typedef virCapsDomainData *virCapsDomainDataPtr;
struct _virCapsDomainData {
    int ostype;
    int arch;
234
    int domaintype; /* virDomainVirtType */
235 236 237 238
    const char *emulator;
    const char *machinetype;
};

239

240
virCapsPtr
241
virCapabilitiesNew(virArch hostarch,
242 243
                   bool offlineMigrate,
                   bool liveMigrate);
244

245
void
246 247
virCapabilitiesFreeNUMAInfo(virCapsPtr caps);

248
int
249 250 251
virCapabilitiesAddHostFeature(virCapsPtr caps,
                              const char *name);

252
int
253 254 255
virCapabilitiesAddHostMigrateTransport(virCapsPtr caps,
                                       const char *name);

256
int
257 258
virCapabilitiesSetNetPrefix(virCapsPtr caps,
                            const char *prefix);
259

260
int
261 262
virCapabilitiesAddHostNUMACell(virCapsPtr caps,
                               int num,
263
                               unsigned long long mem,
264 265 266
                               int ncpus,
                               virCapsHostNUMACellCPUPtr cpus,
                               int nsiblings,
M
Michal Privoznik 已提交
267 268 269
                               virCapsHostNUMACellSiblingInfoPtr siblings,
                               int npageinfo,
                               virCapsHostNUMACellPageInfoPtr pageinfo);
270 271


272
int
273 274 275
virCapabilitiesSetHostCPU(virCapsPtr caps,
                          virCPUDefPtr cpu);

276

277
virCapsGuestMachinePtr *
278 279
virCapabilitiesAllocMachines(const char *const *names,
                             int nnames);
280
void
281 282 283
virCapabilitiesFreeMachines(virCapsGuestMachinePtr *machines,
                            int nmachines);

284 285 286
void
virCapabilitiesFreeGuest(virCapsGuestPtr guest);

287
virCapsGuestPtr
288
virCapabilitiesAddGuest(virCapsPtr caps,
289
                        int ostype,
290
                        virArch arch,
291 292 293
                        const char *emulator,
                        const char *loader,
                        int nmachines,
294
                        virCapsGuestMachinePtr *machines);
295

296
virCapsGuestDomainPtr
297
virCapabilitiesAddGuestDomain(virCapsGuestPtr guest,
298
                              int hvtype,
299 300 301
                              const char *emulator,
                              const char *loader,
                              int nmachines,
302
                              virCapsGuestMachinePtr *machines);
303

304
virCapsGuestFeaturePtr
305 306
virCapabilitiesAddGuestFeature(virCapsGuestPtr guest,
                               const char *name,
307 308
                               bool defaultOn,
                               bool toggle);
309

310
int
311 312 313 314
virCapabilitiesHostSecModelAddBaseLabel(virCapsHostSecModelPtr secmodel,
                                        const char *type,
                                        const char *label);

315 316 317 318 319 320 321 322
virCapsDomainDataPtr
virCapabilitiesDomainDataLookup(virCapsPtr caps,
                                int ostype,
                                virArch arch,
                                int domaintype,
                                const char *emulator,
                                const char *machinetype);

323 324 325
void
virCapabilitiesClearHostNUMACellCPUTopology(virCapsHostNUMACellCPUPtr cpu,
                                            size_t ncpus);
326

327
char *
328 329
virCapabilitiesFormatXML(virCapsPtr caps);

330 331
virBitmapPtr virCapabilitiesGetCpusForNodemask(virCapsPtr caps,
                                               virBitmapPtr nodemask);
332

M
Martin Kletzander 已提交
333 334
int virCapabilitiesGetNodeInfo(virNodeInfoPtr nodeinfo);

335 336
int virCapabilitiesInitPages(virCapsPtr caps);

M
Martin Kletzander 已提交
337 338
int virCapabilitiesInitNUMA(virCapsPtr caps);

339 340 341 342 343 344
bool virCapsHostCacheBankEquals(virCapsHostCacheBankPtr a,
                                virCapsHostCacheBankPtr b);
void virCapsHostCacheBankFree(virCapsHostCacheBankPtr ptr);

int virCapabilitiesInitCaches(virCapsPtr caps);

345
#endif /* __VIR_CAPABILITIES_H */