capabilities.h 6.5 KB
Newer Older
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
/*
 * capabilities.h: hypervisor capabilities
 *
 * Copyright (C) 2006-2008 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, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
 *
 * Author: Daniel P. Berrange <berrange@redhat.com>
 */

#ifndef __VIR_CAPABILITIES_H
#define __VIR_CAPABILITIES_H

27 28 29
#include "internal.h"
#include "util.h"

30 31 32 33 34 35 36 37
typedef struct _virCapsGuestFeature virCapsGuestFeature;
typedef virCapsGuestFeature *virCapsGuestFeaturePtr;
struct _virCapsGuestFeature {
    char *name;
    int defaultOn;
    int toggle;
};

38 39 40 41 42 43 44
typedef struct _virCapsGuestMachine virCapsGuestMachine;
typedef virCapsGuestMachine *virCapsGuestMachinePtr;
struct _virCapsGuestMachine {
    char *name;
    char *canonical;
};

45 46 47 48 49 50
typedef struct _virCapsGuestDomainInfo virCapsGuestDomainInfo;
typedef virCapsGuestDomainInfo *virCapsGuestDomainInfoPtr;
struct _virCapsGuestDomainInfo {
    char *emulator;
    char *loader;
    int nmachines;
51
    virCapsGuestMachinePtr *machines;
52
    time_t emulator_mtime; /* do @machines need refreshing? */
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
};

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;
    int ndomains;
    virCapsGuestDomainPtr *domains;
};

typedef struct _virCapsGuest virCapsGuest;
typedef virCapsGuest *virCapsGuestPtr;
struct _virCapsGuest {
    char *ostype;
    virCapsGuestArch arch;
    int nfeatures;
    virCapsGuestFeaturePtr *features;
};

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

89 90 91 92 93 94
typedef struct _virCapsHostSecModel virCapsHostSecModel;
struct _virCapsHostSecModel {
    char *model;
    char *doi;
};

95 96 97 98 99 100 101 102 103 104 105 106
typedef struct _virCapsHost virCapsHost;
typedef virCapsHost *virCapsHostPtr;
struct _virCapsHost {
    char *arch;
    int nfeatures;
    char **features;
    int offlineMigrate;
    int liveMigrate;
    int nmigrateTrans;
    char **migrateTrans;
    int nnumaCell;
    virCapsHostNUMACellPtr *numaCell;
107
    virCapsHostSecModel secModel;
108 109 110 111 112 113 114 115
};

typedef struct _virCaps virCaps;
typedef virCaps* virCapsPtr;
struct _virCaps {
    virCapsHost host;
    int nguests;
    virCapsGuestPtr *guests;
116
    unsigned char macPrefix[VIR_MAC_PREFIX_BUFLEN];
117
    unsigned int emulatorRequired : 1;
118 119
    void *(*privateDataAllocFunc)(void);
    void (*privateDataFreeFunc)(void *);
120 121 122 123 124 125 126 127 128 129 130
};


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

extern void
virCapabilitiesFree(virCapsPtr caps);

131 132 133
extern void
virCapabilitiesFreeNUMAInfo(virCapsPtr caps);

134 135 136 137 138 139 140
extern void
virCapabilitiesSetMacPrefix(virCapsPtr caps,
                            unsigned char *prefix);

extern void
virCapabilitiesGenerateMac(virCapsPtr caps,
                           unsigned char *mac);
141

142 143 144 145 146 147
extern void
virCapabilitiesSetEmulatorRequired(virCapsPtr caps);

extern unsigned int
virCapabilitiesIsEmulatorRequired(virCapsPtr caps);

148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164
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);



165 166 167 168 169 170 171
extern virCapsGuestMachinePtr *
virCapabilitiesAllocMachines(const char *const *names,
                             int nnames);
extern void
virCapabilitiesFreeMachines(virCapsGuestMachinePtr *machines,
                            int nmachines);

172 173 174 175 176 177 178 179
extern virCapsGuestPtr
virCapabilitiesAddGuest(virCapsPtr caps,
                        const char *ostype,
                        const char *arch,
                        int wordsize,
                        const char *emulator,
                        const char *loader,
                        int nmachines,
180
                        virCapsGuestMachinePtr *machines);
181 182 183 184 185 186 187

extern virCapsGuestDomainPtr
virCapabilitiesAddGuestDomain(virCapsGuestPtr guest,
                              const char *hvtype,
                              const char *emulator,
                              const char *loader,
                              int nmachines,
188
                              virCapsGuestMachinePtr *machines);
189 190 191 192 193 194 195 196 197 198

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

extern int
virCapabilitiesSupportsGuestOSType(virCapsPtr caps,
                                   const char *ostype);
199 200 201 202 203 204
extern int
virCapabilitiesSupportsGuestArch(virCapsPtr caps,
                                 const char *ostype,
                                 const char *arch);


205 206
extern const char *
virCapabilitiesDefaultGuestArch(virCapsPtr caps,
207 208
                                const char *ostype,
                                const char *domain);
209 210 211
extern const char *
virCapabilitiesDefaultGuestMachine(virCapsPtr caps,
                                   const char *ostype,
212 213
                                   const char *arch,
                                   const char *domain);
214 215 216 217 218 219 220 221 222 223 224
extern const char *
virCapabilitiesDefaultGuestEmulator(virCapsPtr caps,
                                    const char *ostype,
                                    const char *arch,
                                    const char *domain);

extern char *
virCapabilitiesFormatXML(virCapsPtr caps);


#endif /* __VIR_CAPABILITIES_H */