capabilities.h 8.1 KB
Newer Older
1 2 3
/*
 * capabilities.h: hypervisor capabilities
 *
E
Eric Blake 已提交
4
 * Copyright (C) 2006-2008, 2010 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
O
Osier Yang 已提交
18 19
 * License along with this library;  If not, see
 * <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 28 29
# include "internal.h"
# include "buf.h"
# include "cpu_conf.h"
30
# include "virmacaddr.h"
31

32
# include <libxml/xpath.h>
33

34 35 36 37 38 39 40 41
typedef struct _virCapsGuestFeature virCapsGuestFeature;
typedef virCapsGuestFeature *virCapsGuestFeaturePtr;
struct _virCapsGuestFeature {
    char *name;
    int defaultOn;
    int toggle;
};

42 43 44 45 46 47 48
typedef struct _virCapsGuestMachine virCapsGuestMachine;
typedef virCapsGuestMachine *virCapsGuestMachinePtr;
struct _virCapsGuestMachine {
    char *name;
    char *canonical;
};

49 50 51 52 53 54
typedef struct _virCapsGuestDomainInfo virCapsGuestDomainInfo;
typedef virCapsGuestDomainInfo *virCapsGuestDomainInfoPtr;
struct _virCapsGuestDomainInfo {
    char *emulator;
    char *loader;
    int nmachines;
55
    virCapsGuestMachinePtr *machines;
56
    time_t emulator_mtime; /* do @machines need refreshing? */
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
};

typedef struct _virCapsGuestDomain virCapsGuestDomain;
typedef virCapsGuestDomain *virCapsGuestDomainPtr;
struct _virCapsGuestDomain {
    char *type;
    virCapsGuestDomainInfo info;
};

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

typedef struct _virCapsGuest virCapsGuest;
typedef virCapsGuest *virCapsGuestPtr;
struct _virCapsGuest {
    char *ostype;
    virCapsGuestArch arch;
E
Eric Blake 已提交
82 83
    size_t nfeatures;
    size_t nfeatures_max;
84 85 86 87 88 89 90 91 92 93 94
    virCapsGuestFeaturePtr *features;
};

typedef struct _virCapsHostNUMACell virCapsHostNUMACell;
typedef virCapsHostNUMACell *virCapsHostNUMACellPtr;
struct _virCapsHostNUMACell {
    int num;
    int ncpus;
    int *cpus;
};

95
typedef struct _virCapsHostSecModel virCapsHostSecModel;
96
typedef virCapsHostSecModel *virCapsHostSecModelPtr;
97 98 99 100 101
struct _virCapsHostSecModel {
    char *model;
    char *doi;
};

102 103 104 105
typedef struct _virCapsHost virCapsHost;
typedef virCapsHost *virCapsHostPtr;
struct _virCapsHost {
    char *arch;
E
Eric Blake 已提交
106 107
    size_t nfeatures;
    size_t nfeatures_max;
108
    char **features;
109 110 111
    unsigned int powerMgmt;    /* Bitmask of the PM capabilities.
                                * See enum virHostPMCapability.
                                */
112 113
    int offlineMigrate;
    int liveMigrate;
E
Eric Blake 已提交
114 115
    size_t nmigrateTrans;
    size_t nmigrateTrans_max;
116
    char **migrateTrans;
E
Eric Blake 已提交
117 118
    size_t nnumaCell;
    size_t nnumaCell_max;
119
    virCapsHostNUMACellPtr *numaCell;
120 121 122 123

    size_t nsecModels;
    virCapsHostSecModelPtr secModels;

124
    virCPUDefPtr cpu;
125
    unsigned char host_uuid[VIR_UUID_BUFLEN];
126 127
};

128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
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;
};

143 144 145 146
typedef struct _virCaps virCaps;
typedef virCaps* virCapsPtr;
struct _virCaps {
    virCapsHost host;
E
Eric Blake 已提交
147 148
    size_t nguests;
    size_t nguests_max;
149
    virCapsGuestPtr *guests;
150
    unsigned char macPrefix[VIR_MAC_PREFIX_BUFLEN];
151
    unsigned int emulatorRequired : 1;
152 153
    const char *defaultDiskDriverName;
    const char *defaultDiskDriverType;
154
    int (*defaultConsoleTargetType)(const char *ostype);
155 156
    void *(*privateDataAllocFunc)(void);
    void (*privateDataFreeFunc)(void *);
157 158
    int (*privateDataXMLFormat)(virBufferPtr, void *);
    int (*privateDataXMLParse)(xmlXPathContextPtr, void *);
159
    bool hasWideScsiBus;
160
    const char *defaultInitPath;
161 162

    virDomainXMLNamespace ns;
163 164 165 166 167 168 169 170 171 172 173
};


extern virCapsPtr
virCapabilitiesNew(const char *arch,
                   int offlineMigrate,
                   int liveMigrate);

extern void
virCapabilitiesFree(virCapsPtr caps);

174 175 176
extern void
virCapabilitiesFreeNUMAInfo(virCapsPtr caps);

177 178
extern void
virCapabilitiesSetMacPrefix(virCapsPtr caps,
179
                            const unsigned char prefix[VIR_MAC_PREFIX_BUFLEN]);
180 181 182

extern void
virCapabilitiesGenerateMac(virCapsPtr caps,
183
                           virMacAddrPtr mac);
184

185 186 187 188 189 190
extern void
virCapabilitiesSetEmulatorRequired(virCapsPtr caps);

extern unsigned int
virCapabilitiesIsEmulatorRequired(virCapsPtr caps);

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

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


extern int
virCapabilitiesAddHostNUMACell(virCapsPtr caps,
                               int num,
                               int ncpus,
                               const int *cpus);


207 208 209 210
extern int
virCapabilitiesSetHostCPU(virCapsPtr caps,
                          virCPUDefPtr cpu);

211

212 213 214 215 216 217 218
extern virCapsGuestMachinePtr *
virCapabilitiesAllocMachines(const char *const *names,
                             int nnames);
extern void
virCapabilitiesFreeMachines(virCapsGuestMachinePtr *machines,
                            int nmachines);

219 220 221 222 223 224 225 226
extern virCapsGuestPtr
virCapabilitiesAddGuest(virCapsPtr caps,
                        const char *ostype,
                        const char *arch,
                        int wordsize,
                        const char *emulator,
                        const char *loader,
                        int nmachines,
227
                        virCapsGuestMachinePtr *machines);
228 229 230 231 232 233 234

extern virCapsGuestDomainPtr
virCapabilitiesAddGuestDomain(virCapsGuestPtr guest,
                              const char *hvtype,
                              const char *emulator,
                              const char *loader,
                              int nmachines,
235
                              virCapsGuestMachinePtr *machines);
236 237 238 239 240 241 242 243

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

extern int
244 245 246
virCapabilitiesSupportsGuestArch(virCapsPtr caps,
                                 const char *arch);
extern int
247 248
virCapabilitiesSupportsGuestOSType(virCapsPtr caps,
                                   const char *ostype);
249
extern int
250 251 252
virCapabilitiesSupportsGuestOSTypeArch(virCapsPtr caps,
                                       const char *ostype,
                                       const char *arch);
253 254


255 256
extern const char *
virCapabilitiesDefaultGuestArch(virCapsPtr caps,
257 258
                                const char *ostype,
                                const char *domain);
259 260 261
extern const char *
virCapabilitiesDefaultGuestMachine(virCapsPtr caps,
                                   const char *ostype,
262 263
                                   const char *arch,
                                   const char *domain);
264 265 266 267 268 269 270 271 272 273 274
extern const char *
virCapabilitiesDefaultGuestEmulator(virCapsPtr caps,
                                    const char *ostype,
                                    const char *arch,
                                    const char *domain);

extern char *
virCapabilitiesFormatXML(virCapsPtr caps);


#endif /* __VIR_CAPABILITIES_H */