2009-12-18 13:44:55 +00:00
|
|
|
/*
|
|
|
|
* cpu_conf.h: CPU XML handling
|
|
|
|
*
|
maint: avoid 'const fooPtr' in cpu files
'const fooPtr' is the same as 'foo * const' (the pointer won't
change, but it's contents can). But in general, if an interface
is trying to be const-correct, it should be using 'const foo *'
(the pointer is to data that can't be changed).
Fix up offenders in src/cpu.
* src/cpu/cpu.h (cpuArchDecode, cpuArchEncode, cpuArchUpdate)
(cpuArchHasFeature, cpuDecode, cpuEncode, cpuUpdate)
(cpuHasFeature): Use intended type.
* src/conf/cpu_conf.h (virCPUDefCopyModel, virCPUDefCopy):
Likewise.
(virCPUDefParseXML): Drop const.
* src/cpu/cpu.c (cpuDecode, cpuEncode, cpuUpdate, cpuHasFeature):
Fix fallout.
* src/cpu/cpu_x86.c (x86ModelFromCPU, x86ModelSubtractCPU)
(x86DecodeCPUData, x86EncodePolicy, x86Encode, x86UpdateCustom)
(x86UpdateHostModel, x86Update, x86HasFeature): Likewise.
* src/cpu/cpu_s390.c (s390Decode): Likewise.
* src/cpu/cpu_arm.c (ArmDecode): Likewise.
* src/cpu/cpu_powerpc.c (ppcModelFromCPU, ppcCompute, ppcDecode)
(ppcUpdate): Likewise.
* src/conf/cpu_conf.c (virCPUDefCopyModel, virCPUDefCopy)
(virCPUDefParseXML): Likewise.
Signed-off-by: Eric Blake <eblake@redhat.com>
2013-10-05 20:01:02 +00:00
|
|
|
* Copyright (C) 2009-2011, 2013 Red Hat, Inc.
|
2009-12-18 13:44:55 +00:00
|
|
|
*
|
|
|
|
* 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
|
2012-09-20 22:30:55 +00:00
|
|
|
* License along with this library. If not, see
|
2012-07-21 10:06:23 +00:00
|
|
|
* <http://www.gnu.org/licenses/>.
|
2009-12-18 13:44:55 +00:00
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Jiri Denemark <jdenemar@redhat.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __VIR_CPU_CONF_H__
|
2010-03-09 18:22:22 +00:00
|
|
|
# define __VIR_CPU_CONF_H__
|
2009-12-18 13:44:55 +00:00
|
|
|
|
2012-12-13 17:44:57 +00:00
|
|
|
# include "virutil.h"
|
2012-12-04 12:04:07 +00:00
|
|
|
# include "virbuffer.h"
|
2012-12-13 18:13:21 +00:00
|
|
|
# include "virxml.h"
|
2012-12-04 11:56:32 +00:00
|
|
|
# include "virbitmap.h"
|
2012-12-11 12:58:54 +00:00
|
|
|
# include "virarch.h"
|
2009-12-18 13:44:55 +00:00
|
|
|
|
2012-06-28 10:21:17 +00:00
|
|
|
# define VIR_CPU_VENDOR_ID_LENGTH 12
|
|
|
|
|
2009-12-18 13:44:55 +00:00
|
|
|
enum virCPUType {
|
|
|
|
VIR_CPU_TYPE_HOST,
|
|
|
|
VIR_CPU_TYPE_GUEST,
|
2011-05-27 09:47:30 +00:00
|
|
|
VIR_CPU_TYPE_AUTO,
|
|
|
|
|
|
|
|
VIR_CPU_TYPE_LAST
|
2009-12-18 13:44:55 +00:00
|
|
|
};
|
|
|
|
|
2011-05-27 09:47:30 +00:00
|
|
|
VIR_ENUM_DECL(virCPU)
|
|
|
|
|
2011-08-18 10:14:36 +00:00
|
|
|
enum virCPUMode {
|
|
|
|
VIR_CPU_MODE_CUSTOM,
|
|
|
|
VIR_CPU_MODE_HOST_MODEL,
|
|
|
|
VIR_CPU_MODE_HOST_PASSTHROUGH,
|
|
|
|
|
|
|
|
VIR_CPU_MODE_LAST
|
|
|
|
};
|
|
|
|
|
|
|
|
VIR_ENUM_DECL(virCPUMode)
|
|
|
|
|
2009-12-18 13:44:55 +00:00
|
|
|
enum virCPUMatch {
|
|
|
|
VIR_CPU_MATCH_MINIMUM,
|
|
|
|
VIR_CPU_MATCH_EXACT,
|
|
|
|
VIR_CPU_MATCH_STRICT,
|
|
|
|
|
|
|
|
VIR_CPU_MATCH_LAST
|
|
|
|
};
|
|
|
|
|
|
|
|
VIR_ENUM_DECL(virCPUMatch)
|
|
|
|
|
2011-12-21 13:27:16 +00:00
|
|
|
enum virCPUFallback {
|
|
|
|
VIR_CPU_FALLBACK_ALLOW,
|
|
|
|
VIR_CPU_FALLBACK_FORBID,
|
|
|
|
|
|
|
|
VIR_CPU_FALLBACK_LAST
|
|
|
|
};
|
|
|
|
|
|
|
|
VIR_ENUM_DECL(virCPUFallback)
|
|
|
|
|
2009-12-18 13:44:55 +00:00
|
|
|
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 */
|
|
|
|
};
|
|
|
|
|
2011-11-11 12:51:45 +00:00
|
|
|
typedef struct _virCellDef virCellDef;
|
|
|
|
typedef virCellDef *virCellDefPtr;
|
|
|
|
struct _virCellDef {
|
|
|
|
int cellid;
|
2012-09-14 07:47:02 +00:00
|
|
|
virBitmapPtr cpumask; /* CPUs that are part of this node */
|
2011-11-11 12:51:45 +00:00
|
|
|
char *cpustr; /* CPUs stored in string form for dumpxml */
|
|
|
|
unsigned int mem; /* Node memory in kB */
|
|
|
|
};
|
|
|
|
|
2009-12-18 13:44:55 +00:00
|
|
|
typedef struct _virCPUDef virCPUDef;
|
|
|
|
typedef virCPUDef *virCPUDefPtr;
|
|
|
|
struct _virCPUDef {
|
|
|
|
int type; /* enum virCPUType */
|
2011-08-18 10:14:36 +00:00
|
|
|
int mode; /* enum virCPUMode */
|
2009-12-18 13:44:55 +00:00
|
|
|
int match; /* enum virCPUMatch */
|
2012-12-11 12:58:54 +00:00
|
|
|
virArch arch;
|
2009-12-18 13:44:55 +00:00
|
|
|
char *model;
|
2012-06-28 10:21:17 +00:00
|
|
|
char *vendor_id; /* vendor id returned by CPUID in the guest */
|
2011-12-21 13:27:16 +00:00
|
|
|
int fallback; /* enum virCPUFallback */
|
2010-07-02 15:51:59 +00:00
|
|
|
char *vendor;
|
2009-12-18 13:44:55 +00:00
|
|
|
unsigned int sockets;
|
|
|
|
unsigned int cores;
|
|
|
|
unsigned int threads;
|
2010-08-17 21:41:51 +00:00
|
|
|
size_t nfeatures;
|
|
|
|
size_t nfeatures_max;
|
2009-12-18 13:44:55 +00:00
|
|
|
virCPUFeatureDefPtr features;
|
2011-11-11 12:51:45 +00:00
|
|
|
size_t ncells;
|
|
|
|
size_t ncells_max;
|
|
|
|
virCellDefPtr cells;
|
|
|
|
unsigned int cells_cpus;
|
2009-12-18 13:44:55 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-12-19 14:41:16 +00:00
|
|
|
void ATTRIBUTE_NONNULL(1)
|
|
|
|
virCPUDefFreeModel(virCPUDefPtr def);
|
|
|
|
|
2009-12-18 13:44:55 +00:00
|
|
|
void
|
|
|
|
virCPUDefFree(virCPUDefPtr def);
|
|
|
|
|
2011-12-19 14:41:16 +00:00
|
|
|
int ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2)
|
|
|
|
virCPUDefCopyModel(virCPUDefPtr dst,
|
maint: avoid 'const fooPtr' in cpu files
'const fooPtr' is the same as 'foo * const' (the pointer won't
change, but it's contents can). But in general, if an interface
is trying to be const-correct, it should be using 'const foo *'
(the pointer is to data that can't be changed).
Fix up offenders in src/cpu.
* src/cpu/cpu.h (cpuArchDecode, cpuArchEncode, cpuArchUpdate)
(cpuArchHasFeature, cpuDecode, cpuEncode, cpuUpdate)
(cpuHasFeature): Use intended type.
* src/conf/cpu_conf.h (virCPUDefCopyModel, virCPUDefCopy):
Likewise.
(virCPUDefParseXML): Drop const.
* src/cpu/cpu.c (cpuDecode, cpuEncode, cpuUpdate, cpuHasFeature):
Fix fallout.
* src/cpu/cpu_x86.c (x86ModelFromCPU, x86ModelSubtractCPU)
(x86DecodeCPUData, x86EncodePolicy, x86Encode, x86UpdateCustom)
(x86UpdateHostModel, x86Update, x86HasFeature): Likewise.
* src/cpu/cpu_s390.c (s390Decode): Likewise.
* src/cpu/cpu_arm.c (ArmDecode): Likewise.
* src/cpu/cpu_powerpc.c (ppcModelFromCPU, ppcCompute, ppcDecode)
(ppcUpdate): Likewise.
* src/conf/cpu_conf.c (virCPUDefCopyModel, virCPUDefCopy)
(virCPUDefParseXML): Likewise.
Signed-off-by: Eric Blake <eblake@redhat.com>
2013-10-05 20:01:02 +00:00
|
|
|
const virCPUDef *src,
|
2011-12-19 14:41:16 +00:00
|
|
|
bool resetPolicy);
|
|
|
|
|
2010-03-23 08:34:04 +00:00
|
|
|
virCPUDefPtr
|
maint: avoid 'const fooPtr' in cpu files
'const fooPtr' is the same as 'foo * const' (the pointer won't
change, but it's contents can). But in general, if an interface
is trying to be const-correct, it should be using 'const foo *'
(the pointer is to data that can't be changed).
Fix up offenders in src/cpu.
* src/cpu/cpu.h (cpuArchDecode, cpuArchEncode, cpuArchUpdate)
(cpuArchHasFeature, cpuDecode, cpuEncode, cpuUpdate)
(cpuHasFeature): Use intended type.
* src/conf/cpu_conf.h (virCPUDefCopyModel, virCPUDefCopy):
Likewise.
(virCPUDefParseXML): Drop const.
* src/cpu/cpu.c (cpuDecode, cpuEncode, cpuUpdate, cpuHasFeature):
Fix fallout.
* src/cpu/cpu_x86.c (x86ModelFromCPU, x86ModelSubtractCPU)
(x86DecodeCPUData, x86EncodePolicy, x86Encode, x86UpdateCustom)
(x86UpdateHostModel, x86Update, x86HasFeature): Likewise.
* src/cpu/cpu_s390.c (s390Decode): Likewise.
* src/cpu/cpu_arm.c (ArmDecode): Likewise.
* src/cpu/cpu_powerpc.c (ppcModelFromCPU, ppcCompute, ppcDecode)
(ppcUpdate): Likewise.
* src/conf/cpu_conf.c (virCPUDefCopyModel, virCPUDefCopy)
(virCPUDefParseXML): Likewise.
Signed-off-by: Eric Blake <eblake@redhat.com>
2013-10-05 20:01:02 +00:00
|
|
|
virCPUDefCopy(const virCPUDef *cpu);
|
2010-03-23 08:34:04 +00:00
|
|
|
|
2009-12-18 13:44:55 +00:00
|
|
|
virCPUDefPtr
|
maint: avoid 'const fooPtr' in cpu files
'const fooPtr' is the same as 'foo * const' (the pointer won't
change, but it's contents can). But in general, if an interface
is trying to be const-correct, it should be using 'const foo *'
(the pointer is to data that can't be changed).
Fix up offenders in src/cpu.
* src/cpu/cpu.h (cpuArchDecode, cpuArchEncode, cpuArchUpdate)
(cpuArchHasFeature, cpuDecode, cpuEncode, cpuUpdate)
(cpuHasFeature): Use intended type.
* src/conf/cpu_conf.h (virCPUDefCopyModel, virCPUDefCopy):
Likewise.
(virCPUDefParseXML): Drop const.
* src/cpu/cpu.c (cpuDecode, cpuEncode, cpuUpdate, cpuHasFeature):
Fix fallout.
* src/cpu/cpu_x86.c (x86ModelFromCPU, x86ModelSubtractCPU)
(x86DecodeCPUData, x86EncodePolicy, x86Encode, x86UpdateCustom)
(x86UpdateHostModel, x86Update, x86HasFeature): Likewise.
* src/cpu/cpu_s390.c (s390Decode): Likewise.
* src/cpu/cpu_arm.c (ArmDecode): Likewise.
* src/cpu/cpu_powerpc.c (ppcModelFromCPU, ppcCompute, ppcDecode)
(ppcUpdate): Likewise.
* src/conf/cpu_conf.c (virCPUDefCopyModel, virCPUDefCopy)
(virCPUDefParseXML): Likewise.
Signed-off-by: Eric Blake <eblake@redhat.com>
2013-10-05 20:01:02 +00:00
|
|
|
virCPUDefParseXML(xmlNodePtr node,
|
2009-12-18 13:44:55 +00:00
|
|
|
xmlXPathContextPtr ctxt,
|
|
|
|
enum virCPUType mode);
|
|
|
|
|
2011-05-27 09:47:30 +00:00
|
|
|
bool
|
|
|
|
virCPUDefIsEqual(virCPUDefPtr src,
|
|
|
|
virCPUDefPtr dst);
|
2009-12-18 13:44:55 +00:00
|
|
|
|
|
|
|
char *
|
2011-08-18 10:14:36 +00:00
|
|
|
virCPUDefFormat(virCPUDefPtr def,
|
|
|
|
unsigned int flags);
|
2009-12-18 13:44:55 +00:00
|
|
|
|
|
|
|
int
|
2010-02-10 12:22:36 +00:00
|
|
|
virCPUDefFormatBuf(virBufferPtr buf,
|
2011-08-18 10:14:36 +00:00
|
|
|
virCPUDefPtr def,
|
|
|
|
unsigned int flags);
|
2011-09-21 23:42:07 +00:00
|
|
|
int
|
|
|
|
virCPUDefFormatBufFull(virBufferPtr buf,
|
2011-08-18 10:14:36 +00:00
|
|
|
virCPUDefPtr def,
|
|
|
|
unsigned int flags);
|
2009-12-18 13:44:55 +00:00
|
|
|
|
|
|
|
int
|
2010-02-10 12:22:36 +00:00
|
|
|
virCPUDefAddFeature(virCPUDefPtr cpu,
|
2009-12-18 13:44:55 +00:00
|
|
|
const char *name,
|
|
|
|
int policy);
|
|
|
|
|
2013-07-15 12:36:09 +00:00
|
|
|
int
|
|
|
|
virCPUDefUpdateFeature(virCPUDefPtr cpu,
|
|
|
|
const char *name,
|
|
|
|
int policy);
|
|
|
|
|
2009-12-18 13:44:55 +00:00
|
|
|
#endif /* __VIR_CPU_CONF_H__ */
|