capabilities.h 8.8 KB
Newer Older
1 2 3
/*
 * capabilities.h: hypervisor capabilities
 *
4
 * Copyright (C) 2006-2013 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 40 41 42 43
typedef struct _virCapsGuestFeature virCapsGuestFeature;
typedef virCapsGuestFeature *virCapsGuestFeaturePtr;
struct _virCapsGuestFeature {
    char *name;
    int defaultOn;
    int toggle;
};

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 64 65 66 67 68 69 70
};

typedef struct _virCapsGuestDomain virCapsGuestDomain;
typedef virCapsGuestDomain *virCapsGuestDomainPtr;
struct _virCapsGuestDomain {
    char *type;
    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 82 83
    virCapsGuestDomainPtr *domains;
};

typedef struct _virCapsGuest virCapsGuest;
typedef virCapsGuest *virCapsGuestPtr;
struct _virCapsGuest {
    char *ostype;
    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 */
};

105 106 107 108 109
typedef struct _virCapsHostNUMACell virCapsHostNUMACell;
typedef virCapsHostNUMACell *virCapsHostNUMACellPtr;
struct _virCapsHostNUMACell {
    int num;
    int ncpus;
110
    unsigned long long mem; /* in kibibytes */
111
    virCapsHostNUMACellCPUPtr cpus;
112 113
    int nsiblings;
    virCapsHostNUMACellSiblingInfoPtr siblings;
114 115
};

116 117 118 119 120 121 122
typedef struct _virCapsHostSecModelLabel virCapsHostSecModelLabel;
typedef virCapsHostSecModelLabel *virCapsHostSecModelLabelPtr;
struct _virCapsHostSecModelLabel {
    char *type;
    char *label;
};

123
typedef struct _virCapsHostSecModel virCapsHostSecModel;
124
typedef virCapsHostSecModel *virCapsHostSecModelPtr;
125 126 127
struct _virCapsHostSecModel {
    char *model;
    char *doi;
128 129
    size_t nlabels;
    virCapsHostSecModelLabelPtr labels;
130 131
};

132 133 134
typedef struct _virCapsHost virCapsHost;
typedef virCapsHost *virCapsHostPtr;
struct _virCapsHost {
135
    virArch arch;
E
Eric Blake 已提交
136 137
    size_t nfeatures;
    size_t nfeatures_max;
138
    char **features;
139 140 141
    unsigned int powerMgmt;    /* Bitmask of the PM capabilities.
                                * See enum virHostPMCapability.
                                */
142 143
    int offlineMigrate;
    int liveMigrate;
E
Eric Blake 已提交
144 145
    size_t nmigrateTrans;
    size_t nmigrateTrans_max;
146
    char **migrateTrans;
E
Eric Blake 已提交
147 148
    size_t nnumaCell;
    size_t nnumaCell_max;
149
    virCapsHostNUMACellPtr *numaCell;
150 151 152 153

    size_t nsecModels;
    virCapsHostSecModelPtr secModels;

154
    virCPUDefPtr cpu;
155
    unsigned char host_uuid[VIR_UUID_BUFLEN];
156 157
};

158 159 160 161 162 163 164 165 166 167 168 169 170 171 172
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;
};

173
typedef struct _virCaps virCaps;
174
typedef virCaps *virCapsPtr;
175
struct _virCaps {
176 177
    virObject parent;

178
    virCapsHost host;
E
Eric Blake 已提交
179 180
    size_t nguests;
    size_t nguests_max;
181 182 183 184 185
    virCapsGuestPtr *guests;
};


extern virCapsPtr
186
virCapabilitiesNew(virArch hostarch,
187 188 189
                   int offlineMigrate,
                   int liveMigrate);

190 191 192
extern void
virCapabilitiesFreeNUMAInfo(virCapsPtr caps);

193 194 195 196 197 198 199 200 201 202 203 204
extern int
virCapabilitiesAddHostFeature(virCapsPtr caps,
                              const char *name);

extern int
virCapabilitiesAddHostMigrateTransport(virCapsPtr caps,
                                       const char *name);


extern int
virCapabilitiesAddHostNUMACell(virCapsPtr caps,
                               int num,
205
                               unsigned long long mem,
206 207 208 209
                               int ncpus,
                               virCapsHostNUMACellCPUPtr cpus,
                               int nsiblings,
                               virCapsHostNUMACellSiblingInfoPtr siblings);
210 211


212 213 214 215
extern int
virCapabilitiesSetHostCPU(virCapsPtr caps,
                          virCPUDefPtr cpu);

216

217 218 219 220 221 222 223
extern virCapsGuestMachinePtr *
virCapabilitiesAllocMachines(const char *const *names,
                             int nnames);
extern void
virCapabilitiesFreeMachines(virCapsGuestMachinePtr *machines,
                            int nmachines);

224 225 226
extern virCapsGuestPtr
virCapabilitiesAddGuest(virCapsPtr caps,
                        const char *ostype,
227
                        virArch arch,
228 229 230
                        const char *emulator,
                        const char *loader,
                        int nmachines,
231
                        virCapsGuestMachinePtr *machines);
232 233 234 235 236 237 238

extern virCapsGuestDomainPtr
virCapabilitiesAddGuestDomain(virCapsGuestPtr guest,
                              const char *hvtype,
                              const char *emulator,
                              const char *loader,
                              int nmachines,
239
                              virCapsGuestMachinePtr *machines);
240 241 242 243 244 245 246

extern virCapsGuestFeaturePtr
virCapabilitiesAddGuestFeature(virCapsGuestPtr guest,
                               const char *name,
                               int defaultOn,
                               int toggle);

247 248 249 250 251
extern int
virCapabilitiesHostSecModelAddBaseLabel(virCapsHostSecModelPtr secmodel,
                                        const char *type,
                                        const char *label);

252
extern int
253
virCapabilitiesSupportsGuestArch(virCapsPtr caps,
254
                                 virArch arch);
255
extern int
256 257
virCapabilitiesSupportsGuestOSType(virCapsPtr caps,
                                   const char *ostype);
258
extern int
259 260
virCapabilitiesSupportsGuestOSTypeArch(virCapsPtr caps,
                                       const char *ostype,
261
                                       virArch arch);
262

263 264 265
void
virCapabilitiesClearHostNUMACellCPUTopology(virCapsHostNUMACellCPUPtr cpu,
                                            size_t ncpus);
266

267
extern virArch
268
virCapabilitiesDefaultGuestArch(virCapsPtr caps,
269 270
                                const char *ostype,
                                const char *domain);
271 272 273
extern const char *
virCapabilitiesDefaultGuestMachine(virCapsPtr caps,
                                   const char *ostype,
274
                                   virArch arch,
275
                                   const char *domain);
276 277 278
extern const char *
virCapabilitiesDefaultGuestEmulator(virCapsPtr caps,
                                    const char *ostype,
279
                                    virArch arch,
280 281 282 283 284
                                    const char *domain);

extern char *
virCapabilitiesFormatXML(virCapsPtr caps);

285 286
virBitmapPtr virCapabilitiesGetCpusForNodemask(virCapsPtr caps,
                                               virBitmapPtr nodemask);
287 288

#endif /* __VIR_CAPABILITIES_H */