cpu_conf.h 4.0 KB
Newer Older
1 2 3
/*
 * cpu_conf.h: CPU XML handling
 *
E
Eric Blake 已提交
4
 * Copyright (C) 2009-2011 Red Hat, Inc.
5 6 7 8 9 10 11 12 13 14 15 16
 *
 * 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
17
 * License along with this library.  If not, see
O
Osier Yang 已提交
18
 * <http://www.gnu.org/licenses/>.
19 20 21 22 23 24
 *
 * Authors:
 *      Jiri Denemark <jdenemar@redhat.com>
 */

#ifndef __VIR_CPU_CONF_H__
25
# define __VIR_CPU_CONF_H__
26

27
# include "virutil.h"
28
# include "virbuffer.h"
29
# include "virxml.h"
30
# include "virbitmap.h"
31
# include "virarch.h"
32

33 34
# define VIR_CPU_VENDOR_ID_LENGTH 12

35 36 37
enum virCPUType {
    VIR_CPU_TYPE_HOST,
    VIR_CPU_TYPE_GUEST,
38 39 40
    VIR_CPU_TYPE_AUTO,

    VIR_CPU_TYPE_LAST
41 42
};

43 44
VIR_ENUM_DECL(virCPU)

45 46 47 48 49 50 51 52 53 54
enum virCPUMode {
    VIR_CPU_MODE_CUSTOM,
    VIR_CPU_MODE_HOST_MODEL,
    VIR_CPU_MODE_HOST_PASSTHROUGH,

    VIR_CPU_MODE_LAST
};

VIR_ENUM_DECL(virCPUMode)

55 56 57 58 59 60 61 62 63 64
enum virCPUMatch {
    VIR_CPU_MATCH_MINIMUM,
    VIR_CPU_MATCH_EXACT,
    VIR_CPU_MATCH_STRICT,

    VIR_CPU_MATCH_LAST
};

VIR_ENUM_DECL(virCPUMatch)

65 66 67 68 69 70 71 72 73
enum virCPUFallback {
    VIR_CPU_FALLBACK_ALLOW,
    VIR_CPU_FALLBACK_FORBID,

    VIR_CPU_FALLBACK_LAST
};

VIR_ENUM_DECL(virCPUFallback)

74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
enum virCPUFeaturePolicy {
    VIR_CPU_FEATURE_FORCE,
    VIR_CPU_FEATURE_REQUIRE,
    VIR_CPU_FEATURE_OPTIONAL,
    VIR_CPU_FEATURE_DISABLE,
    VIR_CPU_FEATURE_FORBID,

    VIR_CPU_FEATURE_LAST
};

VIR_ENUM_DECL(virCPUFeaturePolicy)

typedef struct _virCPUFeatureDef virCPUFeatureDef;
typedef virCPUFeatureDef *virCPUFeatureDefPtr;
struct _virCPUFeatureDef {
    char *name;
    int policy;         /* enum virCPUFeaturePolicy */
};

93 94 95 96
typedef struct _virCellDef virCellDef;
typedef virCellDef *virCellDefPtr;
struct _virCellDef {
   int cellid;
97
   virBitmapPtr cpumask;	/* CPUs that are part of this node */
98 99 100 101
   char *cpustr;	/* CPUs stored in string form for dumpxml */
   unsigned int mem;	/* Node memory in kB */
};

102 103 104 105
typedef struct _virCPUDef virCPUDef;
typedef virCPUDef *virCPUDefPtr;
struct _virCPUDef {
    int type;           /* enum virCPUType */
106
    int mode;           /* enum virCPUMode */
107
    int match;          /* enum virCPUMatch */
108
    virArch arch;
109
    char *model;
110
    char *vendor_id;    /* vendor id returned by CPUID in the guest */
111
    int fallback;       /* enum virCPUFallback */
J
Jiri Denemark 已提交
112
    char *vendor;
113 114 115
    unsigned int sockets;
    unsigned int cores;
    unsigned int threads;
E
Eric Blake 已提交
116 117
    size_t nfeatures;
    size_t nfeatures_max;
118
    virCPUFeatureDefPtr features;
119 120 121 122
    size_t ncells;
    size_t ncells_max;
    virCellDefPtr cells;
    unsigned int cells_cpus;
123 124 125
};


126 127 128
void ATTRIBUTE_NONNULL(1)
virCPUDefFreeModel(virCPUDefPtr def);

129 130 131
void
virCPUDefFree(virCPUDefPtr def);

132 133 134 135 136
int ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2)
virCPUDefCopyModel(virCPUDefPtr dst,
                   const virCPUDefPtr src,
                   bool resetPolicy);

137 138 139
virCPUDefPtr
virCPUDefCopy(const virCPUDefPtr cpu);

140
virCPUDefPtr
141
virCPUDefParseXML(const xmlNodePtr node,
142 143 144
                  xmlXPathContextPtr ctxt,
                  enum virCPUType mode);

145 146 147
bool
virCPUDefIsEqual(virCPUDefPtr src,
                 virCPUDefPtr dst);
148 149

char *
150 151
virCPUDefFormat(virCPUDefPtr def,
                unsigned int flags);
152 153

int
154
virCPUDefFormatBuf(virBufferPtr buf,
155 156
                   virCPUDefPtr def,
                   unsigned int flags);
157 158
int
virCPUDefFormatBufFull(virBufferPtr buf,
159 160
                       virCPUDefPtr def,
                       unsigned int flags);
161 162

int
163
virCPUDefAddFeature(virCPUDefPtr cpu,
164 165 166
                    const char *name,
                    int policy);

P
Peter Krempa 已提交
167 168 169 170 171
int
virCPUDefUpdateFeature(virCPUDefPtr cpu,
                       const char *name,
                       int policy);

172
#endif /* __VIR_CPU_CONF_H__ */