domain_capabilities.h 8.1 KB
Newer Older
M
Michal Privoznik 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
/*
 * domain_capabilities.h: domain capabilities XML processing
 *
 * Copyright (C) 2014 Red Hat, Inc.
 *
 * 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/>.
 */

21 22
#ifndef LIBVIRT_DOMAIN_CAPABILITIES_H
# define LIBVIRT_DOMAIN_CAPABILITIES_H
M
Michal Privoznik 已提交
23 24 25

# include "internal.h"
# include "domain_conf.h"
26
# include "virautoclean.h"
M
Michal Privoznik 已提交
27 28 29 30 31 32 33 34 35

typedef const char * (*virDomainCapsValToStr)(int value);

typedef struct _virDomainCaps virDomainCaps;
typedef virDomainCaps *virDomainCapsPtr;

typedef struct _virDomainCapsEnum virDomainCapsEnum;
typedef virDomainCapsEnum *virDomainCapsEnumPtr;
struct _virDomainCapsEnum {
36
    bool report; /* Whether the format the enum at all */
M
Michal Privoznik 已提交
37 38 39
    unsigned int values; /* Bitmask of values supported in the corresponding enum */
};

40 41 42 43 44 45 46
typedef struct _virDomainCapsStringValues virDomainCapsStringValues;
typedef virDomainCapsStringValues *virDomainCapsStringValuesPtr;
struct _virDomainCapsStringValues {
    char **values;  /* raw string values */
    size_t nvalues; /* number of strings */
};

47 48 49
typedef struct _virDomainCapsLoader virDomainCapsLoader;
typedef virDomainCapsLoader *virDomainCapsLoaderPtr;
struct _virDomainCapsLoader {
50
    virTristateBool supported;
51
    virDomainCapsStringValues values;   /* Info about values for the element */
52 53 54 55 56 57 58
    virDomainCapsEnum type;     /* Info about virDomainLoader */
    virDomainCapsEnum readonly; /* Info about readonly:virTristateBool */
};

typedef struct _virDomainCapsOS virDomainCapsOS;
typedef virDomainCapsOS *virDomainCapsOSPtr;
struct _virDomainCapsOS {
59
    virTristateBool supported;
60 61 62
    virDomainCapsLoader loader;     /* Info about virDomainLoaderDef */
};

M
Michal Privoznik 已提交
63 64 65
typedef struct _virDomainCapsDeviceDisk virDomainCapsDeviceDisk;
typedef virDomainCapsDeviceDisk *virDomainCapsDeviceDiskPtr;
struct _virDomainCapsDeviceDisk {
66
    virTristateBool supported;
M
Michal Privoznik 已提交
67 68
    virDomainCapsEnum diskDevice;   /* Info about virDomainDiskDevice enum values */
    virDomainCapsEnum bus;          /* Info about virDomainDiskBus enum values */
69
    virDomainCapsEnum model;        /* Info about virDomainDiskModel enum values */
M
Michal Privoznik 已提交
70 71 72
    /* add new fields here */
};

73 74 75
typedef struct _virDomainCapsDeviceGraphics virDomainCapsDeviceGraphics;
typedef virDomainCapsDeviceGraphics *virDomainCapsDeviceGraphicsPtr;
struct _virDomainCapsDeviceGraphics {
76
    virTristateBool supported;
77 78 79
    virDomainCapsEnum type;   /* virDomainGraphicsType */
};

80 81 82
typedef struct _virDomainCapsDeviceVideo virDomainCapsDeviceVideo;
typedef virDomainCapsDeviceVideo *virDomainCapsDeviceVideoPtr;
struct _virDomainCapsDeviceVideo {
83
    virTristateBool supported;
84 85 86
    virDomainCapsEnum modelType;   /* virDomainVideoType */
};

M
Michal Privoznik 已提交
87 88 89
typedef struct _virDomainCapsDeviceHostdev virDomainCapsDeviceHostdev;
typedef virDomainCapsDeviceHostdev *virDomainCapsDeviceHostdevPtr;
struct _virDomainCapsDeviceHostdev {
90
    virTristateBool supported;
M
Michal Privoznik 已提交
91 92 93 94 95 96 97 98
    virDomainCapsEnum mode;             /* Info about virDomainHostdevMode */
    virDomainCapsEnum startupPolicy;    /* Info about virDomainStartupPolicy */
    virDomainCapsEnum subsysType;       /* Info about virDomainHostdevSubsysType */
    virDomainCapsEnum capsType;         /* Info about virDomainHostdevCapsType */
    virDomainCapsEnum pciBackend;       /* Info about virDomainHostdevSubsysPCIBackendType */
    /* add new fields here */
};

A
Andrea Bolognani 已提交
99 100 101
typedef struct _virDomainCapsFeatureGIC virDomainCapsFeatureGIC;
typedef virDomainCapsFeatureGIC *virDomainCapsFeatureGICPtr;
struct _virDomainCapsFeatureGIC {
102
    virTristateBool supported;
A
Andrea Bolognani 已提交
103 104 105
    virDomainCapsEnum version; /* Info about virGICVersion */
};

J
Jiri Denemark 已提交
106 107 108 109 110 111 112 113 114
typedef enum {
    VIR_DOMCAPS_CPU_USABLE_UNKNOWN,
    VIR_DOMCAPS_CPU_USABLE_YES,
    VIR_DOMCAPS_CPU_USABLE_NO,

    VIR_DOMCAPS_CPU_USABLE_LAST
} virDomainCapsCPUUsable;
VIR_ENUM_DECL(virDomainCapsCPUUsable);

115 116 117 118
typedef struct _virDomainCapsCPUModel virDomainCapsCPUModel;
typedef virDomainCapsCPUModel *virDomainCapsCPUModelPtr;
struct _virDomainCapsCPUModel {
    char *name;
J
Jiri Denemark 已提交
119
    virDomainCapsCPUUsable usable;
120
    char **blockers; /* NULL-terminated list of usability blockers */
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
};

typedef struct _virDomainCapsCPUModels virDomainCapsCPUModels;
typedef virDomainCapsCPUModels *virDomainCapsCPUModelsPtr;
struct _virDomainCapsCPUModels {
    virObject parent;

    size_t nmodels_max;
    size_t nmodels;
    virDomainCapsCPUModelPtr models;
};

typedef struct _virDomainCapsCPU virDomainCapsCPU;
typedef virDomainCapsCPU *virDomainCapsCPUPtr;
struct _virDomainCapsCPU {
    bool hostPassthrough;
137
    virCPUDefPtr hostModel;
138 139 140
    virDomainCapsCPUModelsPtr custom;
};

141 142 143 144 145 146 147 148 149
typedef struct _virSEVCapability virSEVCapability;
typedef virSEVCapability *virSEVCapabilityPtr;
struct _virSEVCapability {
    char *pdh;
    char *cert_chain;
    unsigned int cbitpos;
    unsigned int reduced_phys_bits;
};

M
Michal Privoznik 已提交
150 151 152 153 154 155 156 157 158 159
struct _virDomainCaps {
    virObjectLockable parent;

    char *path;                     /* path to emulator binary */
    virDomainVirtType virttype;     /* virtualization type */
    char *machine;                  /* machine type */
    virArch arch;                   /* domain architecture */

    /* Some machine specific info */
    int maxvcpus;
160
    virTristateBool iothreads;  /* Whether I/O threads are supported or not. */
M
Michal Privoznik 已提交
161

162
    virDomainCapsOS os;
163
    virDomainCapsCPU cpu;
M
Michal Privoznik 已提交
164
    virDomainCapsDeviceDisk disk;
165
    virDomainCapsDeviceGraphics graphics;
166
    virDomainCapsDeviceVideo video;
M
Michal Privoznik 已提交
167 168
    virDomainCapsDeviceHostdev hostdev;
    /* add new domain devices here */
A
Andrea Bolognani 已提交
169 170

    virDomainCapsFeatureGIC gic;
171 172
    virTristateBool vmcoreinfo;
    virTristateBool genid;
173
    virSEVCapabilityPtr sev;
A
Andrea Bolognani 已提交
174
    /* add new domain features here */
M
Michal Privoznik 已提交
175 176 177 178 179 180 181
};

virDomainCapsPtr virDomainCapsNew(const char *path,
                                  const char *machine,
                                  virArch arch,
                                  virDomainVirtType virttype);

182 183
virDomainCapsCPUModelsPtr virDomainCapsCPUModelsNew(size_t nmodels);
virDomainCapsCPUModelsPtr virDomainCapsCPUModelsCopy(virDomainCapsCPUModelsPtr old);
184
virDomainCapsCPUModelsPtr virDomainCapsCPUModelsFilter(virDomainCapsCPUModelsPtr old,
185 186
                                                       const char **models,
                                                       const char **blacklist);
187
int virDomainCapsCPUModelsAddSteal(virDomainCapsCPUModelsPtr cpuModels,
J
Jiri Denemark 已提交
188
                                   char **name,
189 190
                                   virDomainCapsCPUUsable usable,
                                   char ***blockers);
191 192
int virDomainCapsCPUModelsAdd(virDomainCapsCPUModelsPtr cpuModels,
                              const char *name,
J
Jiri Denemark 已提交
193
                              ssize_t nameLen,
194 195
                              virDomainCapsCPUUsable usable,
                              char **blockers);
196 197 198 199
virDomainCapsCPUModelPtr
virDomainCapsCPUModelsGet(virDomainCapsCPUModelsPtr cpuModels,
                          const char *name);

200

201 202 203 204 205 206
# define VIR_DOMAIN_CAPS_ENUM_SET(capsEnum, ...) \
    do { \
        unsigned int __values[] = {__VA_ARGS__}; \
        size_t __nvalues = ARRAY_CARDINALITY(__values); \
        virDomainCapsEnumSet(&(capsEnum), #capsEnum, \
                             __nvalues, __values); \
M
Michal Privoznik 已提交
207 208 209 210 211 212 213 214 215
    } while (0)

int virDomainCapsEnumSet(virDomainCapsEnumPtr capsEnum,
                         const char *capsEnumName,
                         size_t nvalues,
                         unsigned int *values);
void virDomainCapsEnumClear(virDomainCapsEnumPtr capsEnum);

char * virDomainCapsFormat(virDomainCapsPtr const caps);
216 217 218

void
virSEVCapabilitiesFree(virSEVCapability *capabilities);
219 220 221

VIR_DEFINE_AUTOPTR_FUNC(virSEVCapability, virSEVCapabilitiesFree);

222
#endif /* LIBVIRT_DOMAIN_CAPABILITIES_H */