2012-07-12 15:28:17 +00:00
|
|
|
/*
|
|
|
|
* cpu_arm.c: CPU driver for arm CPUs
|
|
|
|
*
|
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) 2013 Red Hat, Inc.
|
2012-07-12 15:28:17 +00:00
|
|
|
* Copyright (C) Canonical Ltd. 2012
|
|
|
|
*
|
|
|
|
* 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/>.
|
2012-07-12 15:28:17 +00:00
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Chuck Short <chuck.short@canonical.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
2012-12-12 18:06:53 +00:00
|
|
|
#include "viralloc.h"
|
2012-07-12 15:28:17 +00:00
|
|
|
#include "cpu.h"
|
2014-02-26 16:40:12 +00:00
|
|
|
#include "virstring.h"
|
2012-07-12 15:28:17 +00:00
|
|
|
|
|
|
|
#define VIR_FROM_THIS VIR_FROM_CPU
|
|
|
|
|
2016-06-24 16:21:50 +00:00
|
|
|
static const virArch archs[] = {
|
|
|
|
VIR_ARCH_ARMV6L,
|
|
|
|
VIR_ARCH_ARMV7B,
|
|
|
|
VIR_ARCH_ARMV7L,
|
|
|
|
VIR_ARCH_AARCH64,
|
|
|
|
};
|
2012-07-12 15:28:17 +00:00
|
|
|
|
2016-06-23 13:27:07 +00:00
|
|
|
|
2014-02-26 16:40:12 +00:00
|
|
|
static int
|
2016-06-23 13:27:07 +00:00
|
|
|
virCPUarmUpdate(virCPUDefPtr guest,
|
|
|
|
const virCPUDef *host)
|
2014-02-26 16:40:12 +00:00
|
|
|
{
|
2016-06-23 13:27:07 +00:00
|
|
|
int ret = -1;
|
|
|
|
virCPUDefPtr updated = NULL;
|
|
|
|
|
|
|
|
if (guest->mode != VIR_CPU_MODE_HOST_MODEL)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (!host) {
|
|
|
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
|
|
|
_("unknown host CPU model"));
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(updated = virCPUDefCopyWithoutModel(guest)))
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
updated->mode = VIR_CPU_MODE_CUSTOM;
|
|
|
|
if (virCPUDefCopyModel(updated, host, true) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
2016-11-10 09:26:03 +00:00
|
|
|
virCPUDefStealModel(guest, updated, false);
|
2016-06-23 13:27:07 +00:00
|
|
|
guest->mode = VIR_CPU_MODE_CUSTOM;
|
2014-02-26 16:40:12 +00:00
|
|
|
guest->match = VIR_CPU_MATCH_EXACT;
|
2016-06-23 13:27:07 +00:00
|
|
|
ret = 0;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
virCPUDefFree(updated);
|
|
|
|
return ret;
|
2014-02-26 16:40:12 +00:00
|
|
|
}
|
|
|
|
|
2016-06-23 13:27:07 +00:00
|
|
|
|
2014-03-03 13:41:03 +00:00
|
|
|
static virCPUDefPtr
|
2016-06-24 16:21:50 +00:00
|
|
|
armBaseline(virCPUDefPtr *cpus,
|
2014-03-03 13:41:03 +00:00
|
|
|
unsigned int ncpus ATTRIBUTE_UNUSED,
|
|
|
|
const char **models ATTRIBUTE_UNUSED,
|
|
|
|
unsigned int nmodels ATTRIBUTE_UNUSED,
|
2017-03-17 14:58:07 +00:00
|
|
|
bool migratable ATTRIBUTE_UNUSED)
|
2014-03-03 13:41:03 +00:00
|
|
|
{
|
|
|
|
virCPUDefPtr cpu = NULL;
|
|
|
|
|
|
|
|
if (VIR_ALLOC(cpu) < 0 ||
|
|
|
|
VIR_STRDUP(cpu->model, cpus[0]->model) < 0) {
|
|
|
|
virCPUDefFree(cpu);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
cpu->type = VIR_CPU_TYPE_GUEST;
|
|
|
|
cpu->match = VIR_CPU_MATCH_EXACT;
|
|
|
|
|
|
|
|
return cpu;
|
|
|
|
}
|
|
|
|
|
2014-05-07 16:38:10 +00:00
|
|
|
static virCPUCompareResult
|
2016-08-09 11:26:53 +00:00
|
|
|
virCPUarmCompare(virCPUDefPtr host ATTRIBUTE_UNUSED,
|
|
|
|
virCPUDefPtr cpu ATTRIBUTE_UNUSED,
|
|
|
|
bool failMessages ATTRIBUTE_UNUSED)
|
2014-05-07 16:38:10 +00:00
|
|
|
{
|
|
|
|
return VIR_CPU_COMPARE_IDENTICAL;
|
|
|
|
}
|
|
|
|
|
2012-07-12 15:28:17 +00:00
|
|
|
struct cpuArchDriver cpuDriverArm = {
|
|
|
|
.name = "arm",
|
|
|
|
.arch = archs,
|
|
|
|
.narch = ARRAY_CARDINALITY(archs),
|
2016-08-09 11:26:53 +00:00
|
|
|
.compare = virCPUarmCompare,
|
2016-06-21 14:02:07 +00:00
|
|
|
.decode = NULL,
|
2012-07-12 15:28:17 +00:00
|
|
|
.encode = NULL,
|
2016-06-24 16:21:50 +00:00
|
|
|
.baseline = armBaseline,
|
2016-06-23 13:27:07 +00:00
|
|
|
.update = virCPUarmUpdate,
|
2012-07-12 15:28:17 +00:00
|
|
|
};
|