libvirt/src/conf/cpu_conf.h
Eric Blake d694ae0c55 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-14 13:11:20 -06:00

173 lines
4.0 KiB
C

/*
* cpu_conf.h: CPU XML handling
*
* Copyright (C) 2009-2011, 2013 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/>.
*
* Authors:
* Jiri Denemark <jdenemar@redhat.com>
*/
#ifndef __VIR_CPU_CONF_H__
# define __VIR_CPU_CONF_H__
# include "virutil.h"
# include "virbuffer.h"
# include "virxml.h"
# include "virbitmap.h"
# include "virarch.h"
# define VIR_CPU_VENDOR_ID_LENGTH 12
enum virCPUType {
VIR_CPU_TYPE_HOST,
VIR_CPU_TYPE_GUEST,
VIR_CPU_TYPE_AUTO,
VIR_CPU_TYPE_LAST
};
VIR_ENUM_DECL(virCPU)
enum virCPUMode {
VIR_CPU_MODE_CUSTOM,
VIR_CPU_MODE_HOST_MODEL,
VIR_CPU_MODE_HOST_PASSTHROUGH,
VIR_CPU_MODE_LAST
};
VIR_ENUM_DECL(virCPUMode)
enum virCPUMatch {
VIR_CPU_MATCH_MINIMUM,
VIR_CPU_MATCH_EXACT,
VIR_CPU_MATCH_STRICT,
VIR_CPU_MATCH_LAST
};
VIR_ENUM_DECL(virCPUMatch)
enum virCPUFallback {
VIR_CPU_FALLBACK_ALLOW,
VIR_CPU_FALLBACK_FORBID,
VIR_CPU_FALLBACK_LAST
};
VIR_ENUM_DECL(virCPUFallback)
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 */
};
typedef struct _virCellDef virCellDef;
typedef virCellDef *virCellDefPtr;
struct _virCellDef {
int cellid;
virBitmapPtr cpumask; /* CPUs that are part of this node */
char *cpustr; /* CPUs stored in string form for dumpxml */
unsigned int mem; /* Node memory in kB */
};
typedef struct _virCPUDef virCPUDef;
typedef virCPUDef *virCPUDefPtr;
struct _virCPUDef {
int type; /* enum virCPUType */
int mode; /* enum virCPUMode */
int match; /* enum virCPUMatch */
virArch arch;
char *model;
char *vendor_id; /* vendor id returned by CPUID in the guest */
int fallback; /* enum virCPUFallback */
char *vendor;
unsigned int sockets;
unsigned int cores;
unsigned int threads;
size_t nfeatures;
size_t nfeatures_max;
virCPUFeatureDefPtr features;
size_t ncells;
size_t ncells_max;
virCellDefPtr cells;
unsigned int cells_cpus;
};
void ATTRIBUTE_NONNULL(1)
virCPUDefFreeModel(virCPUDefPtr def);
void
virCPUDefFree(virCPUDefPtr def);
int ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2)
virCPUDefCopyModel(virCPUDefPtr dst,
const virCPUDef *src,
bool resetPolicy);
virCPUDefPtr
virCPUDefCopy(const virCPUDef *cpu);
virCPUDefPtr
virCPUDefParseXML(xmlNodePtr node,
xmlXPathContextPtr ctxt,
enum virCPUType mode);
bool
virCPUDefIsEqual(virCPUDefPtr src,
virCPUDefPtr dst);
char *
virCPUDefFormat(virCPUDefPtr def,
unsigned int flags);
int
virCPUDefFormatBuf(virBufferPtr buf,
virCPUDefPtr def,
unsigned int flags);
int
virCPUDefFormatBufFull(virBufferPtr buf,
virCPUDefPtr def,
unsigned int flags);
int
virCPUDefAddFeature(virCPUDefPtr cpu,
const char *name,
int policy);
int
virCPUDefUpdateFeature(virCPUDefPtr cpu,
const char *name,
int policy);
#endif /* __VIR_CPU_CONF_H__ */