cpu_conf.h 3.8 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 17 18 19 20 21 22 23 24
 *
 * 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
 *
 * Authors:
 *      Jiri Denemark <jdenemar@redhat.com>
 */

#ifndef __VIR_CPU_CONF_H__
25
# define __VIR_CPU_CONF_H__
26

27 28
# include "util.h"
# include "buf.h"
29
# include "xml.h"
30 31 32 33

enum virCPUType {
    VIR_CPU_TYPE_HOST,
    VIR_CPU_TYPE_GUEST,
34 35 36
    VIR_CPU_TYPE_AUTO,

    VIR_CPU_TYPE_LAST
37 38
};

39 40
VIR_ENUM_DECL(virCPU)

41 42 43 44 45 46 47 48 49 50
enum virCPUMode {
    VIR_CPU_MODE_CUSTOM,
    VIR_CPU_MODE_HOST_MODEL,
    VIR_CPU_MODE_HOST_PASSTHROUGH,

    VIR_CPU_MODE_LAST
};

VIR_ENUM_DECL(virCPUMode)

51 52 53 54 55 56 57 58 59 60
enum virCPUMatch {
    VIR_CPU_MATCH_MINIMUM,
    VIR_CPU_MATCH_EXACT,
    VIR_CPU_MATCH_STRICT,

    VIR_CPU_MATCH_LAST
};

VIR_ENUM_DECL(virCPUMatch)

61 62 63 64 65 66 67 68 69
enum virCPUFallback {
    VIR_CPU_FALLBACK_ALLOW,
    VIR_CPU_FALLBACK_FORBID,

    VIR_CPU_FALLBACK_LAST
};

VIR_ENUM_DECL(virCPUFallback)

70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
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 */
};

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

98 99 100 101
typedef struct _virCPUDef virCPUDef;
typedef virCPUDef *virCPUDefPtr;
struct _virCPUDef {
    int type;           /* enum virCPUType */
102
    int mode;           /* enum virCPUMode */
103 104 105
    int match;          /* enum virCPUMatch */
    char *arch;
    char *model;
106
    int fallback;       /* enum virCPUFallback */
J
Jiri Denemark 已提交
107
    char *vendor;
108 109 110
    unsigned int sockets;
    unsigned int cores;
    unsigned int threads;
E
Eric Blake 已提交
111 112
    size_t nfeatures;
    size_t nfeatures_max;
113
    virCPUFeatureDefPtr features;
114 115 116 117
    size_t ncells;
    size_t ncells_max;
    virCellDefPtr cells;
    unsigned int cells_cpus;
118 119 120
};


121 122 123
void ATTRIBUTE_NONNULL(1)
virCPUDefFreeModel(virCPUDefPtr def);

124 125 126
void
virCPUDefFree(virCPUDefPtr def);

127 128 129 130 131
int ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2)
virCPUDefCopyModel(virCPUDefPtr dst,
                   const virCPUDefPtr src,
                   bool resetPolicy);

132 133 134
virCPUDefPtr
virCPUDefCopy(const virCPUDefPtr cpu);

135
virCPUDefPtr
136
virCPUDefParseXML(const xmlNodePtr node,
137 138 139
                  xmlXPathContextPtr ctxt,
                  enum virCPUType mode);

140 141 142
bool
virCPUDefIsEqual(virCPUDefPtr src,
                 virCPUDefPtr dst);
143 144

char *
145 146
virCPUDefFormat(virCPUDefPtr def,
                unsigned int flags);
147 148

int
149
virCPUDefFormatBuf(virBufferPtr buf,
150 151
                   virCPUDefPtr def,
                   unsigned int flags);
152 153
int
virCPUDefFormatBufFull(virBufferPtr buf,
154 155
                       virCPUDefPtr def,
                       unsigned int flags);
156 157

int
158
virCPUDefAddFeature(virCPUDefPtr cpu,
159 160 161 162
                    const char *name,
                    int policy);

#endif /* __VIR_CPU_CONF_H__ */