2009-12-18 13:44:55 +00:00
|
|
|
/*
|
|
|
|
* cpu_conf.h: CPU XML handling
|
|
|
|
*
|
2011-07-07 23:29:42 +00:00
|
|
|
* Copyright (C) 2009-2011 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>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
2012-12-13 18:21:53 +00:00
|
|
|
#include "virerror.h"
|
2012-12-12 18:06:53 +00:00
|
|
|
#include "viralloc.h"
|
2012-12-04 12:04:07 +00:00
|
|
|
#include "virbuffer.h"
|
2009-12-18 13:44:55 +00:00
|
|
|
#include "cpu_conf.h"
|
2011-11-11 12:51:45 +00:00
|
|
|
#include "domain_conf.h"
|
2013-04-03 10:36:23 +00:00
|
|
|
#include "virstring.h"
|
2009-12-18 13:44:55 +00:00
|
|
|
|
|
|
|
#define VIR_FROM_THIS VIR_FROM_CPU
|
|
|
|
|
2011-05-27 09:47:30 +00:00
|
|
|
VIR_ENUM_IMPL(virCPU, VIR_CPU_TYPE_LAST,
|
|
|
|
"host", "guest", "auto")
|
|
|
|
|
2011-08-18 10:14:36 +00:00
|
|
|
VIR_ENUM_IMPL(virCPUMode, VIR_CPU_MODE_LAST,
|
|
|
|
"custom",
|
|
|
|
"host-model",
|
|
|
|
"host-passthrough")
|
|
|
|
|
2009-12-18 13:44:55 +00:00
|
|
|
VIR_ENUM_IMPL(virCPUMatch, VIR_CPU_MATCH_LAST,
|
|
|
|
"minimum",
|
|
|
|
"exact",
|
|
|
|
"strict")
|
|
|
|
|
2011-12-21 13:27:16 +00:00
|
|
|
VIR_ENUM_IMPL(virCPUFallback, VIR_CPU_FALLBACK_LAST,
|
|
|
|
"allow",
|
|
|
|
"forbid")
|
|
|
|
|
2009-12-18 13:44:55 +00:00
|
|
|
VIR_ENUM_IMPL(virCPUFeaturePolicy, VIR_CPU_FEATURE_LAST,
|
|
|
|
"force",
|
|
|
|
"require",
|
|
|
|
"optional",
|
|
|
|
"disable",
|
|
|
|
"forbid")
|
|
|
|
|
|
|
|
|
2011-12-19 14:41:16 +00:00
|
|
|
void ATTRIBUTE_NONNULL(1)
|
|
|
|
virCPUDefFreeModel(virCPUDefPtr def)
|
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
VIR_FREE(def->model);
|
|
|
|
VIR_FREE(def->vendor);
|
2012-06-28 10:21:17 +00:00
|
|
|
VIR_FREE(def->vendor_id);
|
2011-12-19 14:41:16 +00:00
|
|
|
|
|
|
|
for (i = 0; i < def->nfeatures; i++)
|
|
|
|
VIR_FREE(def->features[i].name);
|
|
|
|
VIR_FREE(def->features);
|
|
|
|
}
|
|
|
|
|
2009-12-18 13:44:55 +00:00
|
|
|
void
|
|
|
|
virCPUDefFree(virCPUDefPtr def)
|
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
if (!def)
|
|
|
|
return;
|
|
|
|
|
2011-12-19 14:41:16 +00:00
|
|
|
virCPUDefFreeModel(def);
|
2009-12-18 13:44:55 +00:00
|
|
|
|
2013-05-21 07:21:17 +00:00
|
|
|
for (i = 0; i < def->ncells; i++) {
|
2012-09-14 07:47:02 +00:00
|
|
|
virBitmapFree(def->cells[i].cpumask);
|
2011-11-11 12:51:45 +00:00
|
|
|
VIR_FREE(def->cells[i].cpustr);
|
|
|
|
}
|
|
|
|
VIR_FREE(def->cells);
|
2012-12-17 10:48:37 +00:00
|
|
|
VIR_FREE(def->vendor_id);
|
2011-11-11 12:51:45 +00:00
|
|
|
|
2009-12-18 13:44:55 +00:00
|
|
|
VIR_FREE(def);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-12-19 14:41:16 +00:00
|
|
|
int ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2)
|
|
|
|
virCPUDefCopyModel(virCPUDefPtr dst,
|
|
|
|
const virCPUDefPtr src,
|
|
|
|
bool resetPolicy)
|
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
|
2013-05-03 12:40:46 +00:00
|
|
|
if (VIR_STRDUP(dst->model, src->model) < 0 ||
|
|
|
|
VIR_STRDUP(dst->vendor, src->vendor) < 0 ||
|
|
|
|
VIR_STRDUP(dst->vendor_id, src->vendor_id) < 0 ||
|
|
|
|
VIR_ALLOC_N(dst->features, src->nfeatures) < 0)
|
2013-07-04 10:02:00 +00:00
|
|
|
return -1;
|
2011-12-19 14:41:16 +00:00
|
|
|
dst->nfeatures_max = dst->nfeatures = src->nfeatures;
|
|
|
|
|
|
|
|
for (i = 0; i < dst->nfeatures; i++) {
|
|
|
|
if (dst->type != src->type && resetPolicy) {
|
|
|
|
if (dst->type == VIR_CPU_TYPE_HOST)
|
|
|
|
dst->features[i].policy = -1;
|
|
|
|
else if (src->features[i].policy == -1)
|
|
|
|
dst->features[i].policy = VIR_CPU_FEATURE_REQUIRE;
|
|
|
|
else
|
|
|
|
dst->features[i].policy = src->features[i].policy;
|
|
|
|
} else {
|
|
|
|
dst->features[i].policy = src->features[i].policy;
|
|
|
|
}
|
|
|
|
|
2013-05-03 12:40:46 +00:00
|
|
|
if (VIR_STRDUP(dst->features[i].name, src->features[i].name) < 0)
|
|
|
|
return -1;
|
2011-12-19 14:41:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-03-23 08:34:04 +00:00
|
|
|
virCPUDefPtr
|
|
|
|
virCPUDefCopy(const virCPUDefPtr cpu)
|
|
|
|
{
|
|
|
|
virCPUDefPtr copy;
|
|
|
|
unsigned int i;
|
|
|
|
|
2013-07-04 10:02:00 +00:00
|
|
|
if (!cpu || VIR_ALLOC(copy) < 0)
|
2010-03-23 08:34:04 +00:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
copy->type = cpu->type;
|
2011-08-18 10:14:36 +00:00
|
|
|
copy->mode = cpu->mode;
|
2010-03-23 08:34:04 +00:00
|
|
|
copy->match = cpu->match;
|
2011-12-21 13:27:16 +00:00
|
|
|
copy->fallback = cpu->fallback;
|
2010-03-23 08:34:04 +00:00
|
|
|
copy->sockets = cpu->sockets;
|
|
|
|
copy->cores = cpu->cores;
|
|
|
|
copy->threads = cpu->threads;
|
2012-12-11 12:58:54 +00:00
|
|
|
copy->arch = cpu->arch;
|
2011-12-19 14:41:16 +00:00
|
|
|
|
|
|
|
if (virCPUDefCopyModel(copy, cpu, false) < 0)
|
|
|
|
goto error;
|
2011-12-19 11:38:11 +00:00
|
|
|
|
|
|
|
if (cpu->ncells) {
|
|
|
|
if (VIR_ALLOC_N(copy->cells, cpu->ncells) < 0)
|
2013-07-04 10:02:00 +00:00
|
|
|
goto error;
|
2011-12-19 11:38:11 +00:00
|
|
|
copy->ncells_max = copy->ncells = cpu->ncells;
|
|
|
|
|
|
|
|
for (i = 0; i < cpu->ncells; i++) {
|
|
|
|
copy->cells[i].cellid = cpu->cells[i].cellid;
|
|
|
|
copy->cells[i].mem = cpu->cells[i].mem;
|
|
|
|
|
2012-09-14 07:47:02 +00:00
|
|
|
copy->cells[i].cpumask = virBitmapNewCopy(cpu->cells[i].cpumask);
|
|
|
|
|
|
|
|
if (!copy->cells[i].cpumask)
|
2013-07-04 10:02:00 +00:00
|
|
|
goto error;
|
2011-12-19 11:38:11 +00:00
|
|
|
|
2013-05-03 12:40:46 +00:00
|
|
|
if (VIR_STRDUP(copy->cells[i].cpustr, cpu->cells[i].cpustr) < 0)
|
|
|
|
goto error;
|
2011-12-19 11:38:11 +00:00
|
|
|
}
|
|
|
|
copy->cells_cpus = cpu->cells_cpus;
|
|
|
|
}
|
2010-03-23 08:34:04 +00:00
|
|
|
|
|
|
|
return copy;
|
|
|
|
|
2011-12-19 14:41:16 +00:00
|
|
|
error:
|
2010-03-23 08:34:04 +00:00
|
|
|
virCPUDefFree(copy);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2009-12-18 13:44:55 +00:00
|
|
|
virCPUDefPtr
|
2010-02-10 12:22:36 +00:00
|
|
|
virCPUDefParseXML(const xmlNodePtr node,
|
2009-12-18 13:44:55 +00:00
|
|
|
xmlXPathContextPtr ctxt,
|
|
|
|
enum virCPUType mode)
|
|
|
|
{
|
|
|
|
virCPUDefPtr def;
|
|
|
|
xmlNodePtr *nodes = NULL;
|
|
|
|
int n;
|
|
|
|
unsigned int i;
|
2011-08-18 10:14:36 +00:00
|
|
|
char *cpuMode;
|
2012-12-17 10:49:33 +00:00
|
|
|
char *fallback = NULL;
|
|
|
|
char *vendor_id = NULL;
|
2009-12-18 13:44:55 +00:00
|
|
|
|
2010-03-31 23:02:57 +00:00
|
|
|
if (!xmlStrEqual(node->name, BAD_CAST "cpu")) {
|
2012-07-18 10:50:44 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
"%s",
|
|
|
|
_("XML does not contain expected 'cpu' element"));
|
2010-03-31 23:02:57 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2013-07-04 10:02:00 +00:00
|
|
|
if (VIR_ALLOC(def) < 0)
|
2009-12-18 13:44:55 +00:00
|
|
|
return NULL;
|
|
|
|
|
2010-01-12 14:25:36 +00:00
|
|
|
if (mode == VIR_CPU_TYPE_AUTO) {
|
2010-07-12 14:08:00 +00:00
|
|
|
if (virXPathBoolean("boolean(./arch)", ctxt)) {
|
|
|
|
if (virXPathBoolean("boolean(./@match)", ctxt)) {
|
2012-07-18 10:50:44 +00:00
|
|
|
virReportError(VIR_ERR_XML_ERROR, "%s",
|
|
|
|
_("'arch' element element cannot be used inside 'cpu'"
|
|
|
|
" element with 'match' attribute'"));
|
2010-07-12 14:08:00 +00:00
|
|
|
goto error;
|
|
|
|
}
|
2010-01-12 14:25:36 +00:00
|
|
|
def->type = VIR_CPU_TYPE_HOST;
|
2011-08-18 10:14:36 +00:00
|
|
|
} else {
|
2010-01-12 14:25:36 +00:00
|
|
|
def->type = VIR_CPU_TYPE_GUEST;
|
2011-08-18 10:14:36 +00:00
|
|
|
}
|
|
|
|
} else {
|
2009-12-18 13:44:55 +00:00
|
|
|
def->type = mode;
|
2011-08-18 10:14:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ((cpuMode = virXMLPropString(node, "mode"))) {
|
|
|
|
if (def->type == VIR_CPU_TYPE_HOST) {
|
|
|
|
VIR_FREE(cpuMode);
|
2012-07-18 10:50:44 +00:00
|
|
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
|
|
|
_("Attribute mode is only allowed for guest CPU"));
|
2011-08-18 10:14:36 +00:00
|
|
|
goto error;
|
|
|
|
} else {
|
|
|
|
def->mode = virCPUModeTypeFromString(cpuMode);
|
|
|
|
|
|
|
|
if (def->mode < 0) {
|
2012-07-18 10:50:44 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("Invalid mode attribute '%s'"),
|
|
|
|
cpuMode);
|
2012-06-13 17:21:29 +00:00
|
|
|
VIR_FREE(cpuMode);
|
2011-08-18 10:14:36 +00:00
|
|
|
goto error;
|
|
|
|
}
|
2012-06-13 17:21:29 +00:00
|
|
|
VIR_FREE(cpuMode);
|
2011-08-18 10:14:36 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (def->type == VIR_CPU_TYPE_HOST)
|
|
|
|
def->mode = -1;
|
|
|
|
else
|
|
|
|
def->mode = VIR_CPU_MODE_CUSTOM;
|
|
|
|
}
|
2009-12-18 13:44:55 +00:00
|
|
|
|
|
|
|
if (def->type == VIR_CPU_TYPE_GUEST) {
|
2010-01-12 14:25:36 +00:00
|
|
|
char *match = virXMLPropString(node, "match");
|
|
|
|
|
|
|
|
if (!match) {
|
2010-09-22 11:47:48 +00:00
|
|
|
if (virXPathBoolean("boolean(./model)", ctxt))
|
|
|
|
def->match = VIR_CPU_MATCH_EXACT;
|
|
|
|
else
|
|
|
|
def->match = -1;
|
2010-01-12 14:25:36 +00:00
|
|
|
} else {
|
|
|
|
def->match = virCPUMatchTypeFromString(match);
|
|
|
|
VIR_FREE(match);
|
|
|
|
|
|
|
|
if (def->match < 0) {
|
2012-12-17 11:04:14 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("Invalid match attribute for CPU "
|
|
|
|
"specification"));
|
2010-01-12 14:25:36 +00:00
|
|
|
goto error;
|
|
|
|
}
|
2009-12-18 13:44:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (def->type == VIR_CPU_TYPE_HOST) {
|
2012-12-11 12:58:54 +00:00
|
|
|
char *arch = virXPathString("string(./arch[1])", ctxt);
|
|
|
|
if (!arch) {
|
2012-07-18 10:50:44 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
"%s", _("Missing CPU architecture"));
|
2009-12-18 13:44:55 +00:00
|
|
|
goto error;
|
|
|
|
}
|
2012-12-11 12:58:54 +00:00
|
|
|
if ((def->arch = virArchFromString(arch)) == VIR_ARCH_NONE) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("Unknown architecture %s"), arch);
|
|
|
|
VIR_FREE(arch);
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
VIR_FREE(arch);
|
2009-12-18 13:44:55 +00:00
|
|
|
}
|
|
|
|
|
2010-02-04 21:52:34 +00:00
|
|
|
if (!(def->model = virXPathString("string(./model[1])", ctxt)) &&
|
2010-01-12 14:25:36 +00:00
|
|
|
def->type == VIR_CPU_TYPE_HOST) {
|
2012-07-18 10:50:44 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
"%s", _("Missing CPU model name"));
|
2009-12-18 13:44:55 +00:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
2011-08-18 10:14:36 +00:00
|
|
|
if (def->type == VIR_CPU_TYPE_GUEST &&
|
2012-06-28 10:21:17 +00:00
|
|
|
def->mode != VIR_CPU_MODE_HOST_PASSTHROUGH) {
|
|
|
|
|
2012-12-17 10:49:33 +00:00
|
|
|
if ((fallback = virXPathString("string(./model[1]/@fallback)", ctxt))) {
|
|
|
|
if ((def->fallback = virCPUFallbackTypeFromString(fallback)) < 0) {
|
|
|
|
virReportError(VIR_ERR_XML_ERROR, "%s",
|
|
|
|
_("Invalid fallback attribute"));
|
|
|
|
goto error;
|
2012-06-28 10:21:17 +00:00
|
|
|
}
|
2012-12-17 08:05:59 +00:00
|
|
|
}
|
2012-06-28 10:21:17 +00:00
|
|
|
|
2012-12-17 10:49:33 +00:00
|
|
|
if ((vendor_id = virXPathString("string(./model[1]/@vendor_id)",
|
|
|
|
ctxt))) {
|
|
|
|
if (strlen(vendor_id) != VIR_CPU_VENDOR_ID_LENGTH) {
|
2012-12-17 08:05:59 +00:00
|
|
|
virReportError(VIR_ERR_XML_ERROR,
|
2012-12-17 10:49:33 +00:00
|
|
|
_("vendor_id must be exactly %d characters long"),
|
2012-12-17 08:05:59 +00:00
|
|
|
VIR_CPU_VENDOR_ID_LENGTH);
|
|
|
|
goto error;
|
|
|
|
}
|
2012-12-17 10:49:33 +00:00
|
|
|
|
2012-12-17 08:05:59 +00:00
|
|
|
/* ensure that the string can be passed to qemu*/
|
2012-12-17 10:49:33 +00:00
|
|
|
if (strchr(vendor_id, ',')) {
|
2012-12-17 08:05:59 +00:00
|
|
|
virReportError(VIR_ERR_XML_ERROR, "%s",
|
|
|
|
_("vendor id is invalid"));
|
2012-06-28 10:21:17 +00:00
|
|
|
goto error;
|
2011-12-21 13:27:16 +00:00
|
|
|
}
|
2012-12-17 10:49:33 +00:00
|
|
|
|
2012-12-17 08:05:59 +00:00
|
|
|
def->vendor_id = vendor_id;
|
2012-12-17 10:49:33 +00:00
|
|
|
vendor_id = NULL;
|
2011-12-21 13:27:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-07-02 15:51:59 +00:00
|
|
|
def->vendor = virXPathString("string(./vendor[1])", ctxt);
|
|
|
|
if (def->vendor && !def->model) {
|
2012-07-18 10:50:44 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
"%s", _("CPU vendor specified without CPU model"));
|
2010-07-02 15:51:59 +00:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
2010-02-04 21:52:34 +00:00
|
|
|
if (virXPathNode("./topology[1]", ctxt)) {
|
2009-12-18 13:44:55 +00:00
|
|
|
int ret;
|
|
|
|
unsigned long ul;
|
|
|
|
|
2010-02-04 21:52:34 +00:00
|
|
|
ret = virXPathULong("string(./topology[1]/@sockets)",
|
2009-12-18 13:44:55 +00:00
|
|
|
ctxt, &ul);
|
|
|
|
if (ret < 0) {
|
2012-12-17 11:04:14 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("Missing 'sockets' attribute in CPU topology"));
|
2009-12-18 13:44:55 +00:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
def->sockets = (unsigned int) ul;
|
|
|
|
|
2010-02-04 21:52:34 +00:00
|
|
|
ret = virXPathULong("string(./topology[1]/@cores)",
|
2009-12-18 13:44:55 +00:00
|
|
|
ctxt, &ul);
|
|
|
|
if (ret < 0) {
|
2012-12-17 11:04:14 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("Missing 'cores' attribute in CPU topology"));
|
2009-12-18 13:44:55 +00:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
def->cores = (unsigned int) ul;
|
|
|
|
|
2010-02-04 21:52:34 +00:00
|
|
|
ret = virXPathULong("string(./topology[1]/@threads)",
|
2009-12-18 13:44:55 +00:00
|
|
|
ctxt, &ul);
|
|
|
|
if (ret < 0) {
|
2012-12-17 11:04:14 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("Missing 'threads' attribute in CPU topology"));
|
2009-12-18 13:44:55 +00:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
def->threads = (unsigned int) ul;
|
|
|
|
|
|
|
|
if (!def->sockets || !def->cores || !def->threads) {
|
2012-07-18 10:50:44 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
"%s", _("Invalid CPU topology"));
|
2009-12-18 13:44:55 +00:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-02-04 21:52:34 +00:00
|
|
|
n = virXPathNodeSet("./feature", ctxt, &nodes);
|
2009-12-18 13:44:55 +00:00
|
|
|
if (n < 0)
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
if (n > 0) {
|
2010-01-12 14:25:36 +00:00
|
|
|
if (!def->model) {
|
2012-12-17 11:04:14 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("Non-empty feature list specified without "
|
|
|
|
"CPU model"));
|
2010-01-12 14:25:36 +00:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
2010-08-17 21:41:51 +00:00
|
|
|
if (VIR_RESIZE_N(def->features, def->nfeatures_max,
|
|
|
|
def->nfeatures, n) < 0)
|
2013-07-04 10:02:00 +00:00
|
|
|
goto error;
|
2009-12-18 13:44:55 +00:00
|
|
|
def->nfeatures = n;
|
|
|
|
}
|
|
|
|
|
2013-05-21 07:21:17 +00:00
|
|
|
for (i = 0; i < n; i++) {
|
2009-12-18 13:44:55 +00:00
|
|
|
char *name;
|
|
|
|
int policy; /* enum virDomainCPUFeaturePolicy */
|
|
|
|
unsigned int j;
|
|
|
|
|
|
|
|
if (def->type == VIR_CPU_TYPE_GUEST) {
|
|
|
|
char *strpolicy;
|
|
|
|
|
|
|
|
strpolicy = virXMLPropString(nodes[i], "policy");
|
2010-09-22 11:47:48 +00:00
|
|
|
if (strpolicy == NULL)
|
|
|
|
policy = VIR_CPU_FEATURE_REQUIRE;
|
|
|
|
else
|
|
|
|
policy = virCPUFeaturePolicyTypeFromString(strpolicy);
|
2009-12-18 13:44:55 +00:00
|
|
|
VIR_FREE(strpolicy);
|
|
|
|
|
|
|
|
if (policy < 0) {
|
2012-07-18 10:50:44 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
"%s", _("Invalid CPU feature policy"));
|
2009-12-18 13:44:55 +00:00
|
|
|
goto error;
|
|
|
|
}
|
2011-08-18 10:14:36 +00:00
|
|
|
} else {
|
2009-12-18 13:44:55 +00:00
|
|
|
policy = -1;
|
2011-08-18 10:14:36 +00:00
|
|
|
}
|
2009-12-18 13:44:55 +00:00
|
|
|
|
|
|
|
if (!(name = virXMLPropString(nodes[i], "name")) || *name == 0) {
|
|
|
|
VIR_FREE(name);
|
2012-07-18 10:50:44 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
"%s", _("Invalid CPU feature name"));
|
2009-12-18 13:44:55 +00:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
2013-05-21 07:21:17 +00:00
|
|
|
for (j = 0; j < i; j++) {
|
2009-12-18 13:44:55 +00:00
|
|
|
if (STREQ(name, def->features[j].name)) {
|
2012-07-18 10:50:44 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("CPU feature `%s' specified more than once"),
|
|
|
|
name);
|
2009-12-18 13:44:55 +00:00
|
|
|
VIR_FREE(name);
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
def->features[i].name = name;
|
|
|
|
def->features[i].policy = policy;
|
|
|
|
}
|
|
|
|
|
2011-11-11 12:51:45 +00:00
|
|
|
if (virXPathNode("./numa[1]", ctxt)) {
|
|
|
|
VIR_FREE(nodes);
|
|
|
|
n = virXPathNodeSet("./numa[1]/cell", ctxt, &nodes);
|
|
|
|
if (n <= 0) {
|
2012-07-18 10:50:44 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
"%s", _("NUMA topology defined without NUMA cells"));
|
2011-11-11 12:51:45 +00:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (VIR_RESIZE_N(def->cells, def->ncells_max,
|
|
|
|
def->ncells, n) < 0)
|
2013-07-04 10:02:00 +00:00
|
|
|
goto error;
|
2011-11-11 12:51:45 +00:00
|
|
|
|
|
|
|
def->ncells = n;
|
|
|
|
|
2013-05-21 07:21:17 +00:00
|
|
|
for (i = 0; i < n; i++) {
|
2011-11-18 18:27:24 +00:00
|
|
|
char *cpus, *memory;
|
2011-11-11 12:51:45 +00:00
|
|
|
int ret, ncpus = 0;
|
|
|
|
|
|
|
|
def->cells[i].cellid = i;
|
2011-11-18 18:27:24 +00:00
|
|
|
cpus = virXMLPropString(nodes[i], "cpus");
|
2011-11-11 12:51:45 +00:00
|
|
|
if (!cpus) {
|
2012-07-18 10:50:44 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
"%s", _("Missing 'cpus' attribute in NUMA cell"));
|
2011-11-11 12:51:45 +00:00
|
|
|
goto error;
|
|
|
|
}
|
2011-11-18 18:27:24 +00:00
|
|
|
def->cells[i].cpustr = cpus;
|
2011-11-11 12:51:45 +00:00
|
|
|
|
2012-09-14 07:47:02 +00:00
|
|
|
ncpus = virBitmapParse(cpus, 0, &def->cells[i].cpumask,
|
|
|
|
VIR_DOMAIN_CPUMASK_LEN);
|
2011-11-18 18:27:24 +00:00
|
|
|
if (ncpus <= 0)
|
2011-11-11 12:51:45 +00:00
|
|
|
goto error;
|
|
|
|
def->cells_cpus += ncpus;
|
|
|
|
|
|
|
|
memory = virXMLPropString(nodes[i], "memory");
|
|
|
|
if (!memory) {
|
2012-07-18 10:50:44 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
"%s", _("Missing 'memory' attribute in NUMA cell"));
|
2011-11-11 12:51:45 +00:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = virStrToLong_ui(memory, NULL, 10, &def->cells[i].mem);
|
|
|
|
if (ret == -1) {
|
2012-07-18 10:50:44 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
"%s", _("Invalid 'memory' attribute in NUMA cell"));
|
2011-11-11 12:51:45 +00:00
|
|
|
VIR_FREE(memory);
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
VIR_FREE(memory);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-12-18 13:44:55 +00:00
|
|
|
cleanup:
|
2012-12-17 10:49:33 +00:00
|
|
|
VIR_FREE(fallback);
|
|
|
|
VIR_FREE(vendor_id);
|
2009-12-18 13:44:55 +00:00
|
|
|
VIR_FREE(nodes);
|
|
|
|
return def;
|
|
|
|
|
|
|
|
error:
|
|
|
|
virCPUDefFree(def);
|
|
|
|
def = NULL;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
char *
|
2011-08-18 10:14:36 +00:00
|
|
|
virCPUDefFormat(virCPUDefPtr def,
|
|
|
|
unsigned int flags)
|
2009-12-18 13:44:55 +00:00
|
|
|
{
|
|
|
|
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
|
|
|
|
2011-08-18 10:14:36 +00:00
|
|
|
if (virCPUDefFormatBufFull(&buf, def, flags) < 0)
|
2009-12-18 13:44:55 +00:00
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
if (virBufferError(&buf))
|
|
|
|
goto no_memory;
|
|
|
|
|
|
|
|
return virBufferContentAndReset(&buf);
|
|
|
|
|
|
|
|
no_memory:
|
2010-02-04 18:19:08 +00:00
|
|
|
virReportOOMError();
|
2009-12-18 13:44:55 +00:00
|
|
|
cleanup:
|
2010-01-30 16:27:05 +00:00
|
|
|
virBufferFreeAndReset(&buf);
|
2009-12-18 13:44:55 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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)
|
2011-09-21 23:42:07 +00:00
|
|
|
{
|
|
|
|
if (!def)
|
|
|
|
return 0;
|
|
|
|
|
2011-08-18 10:14:36 +00:00
|
|
|
virBufferAddLit(buf, "<cpu");
|
|
|
|
if (def->type == VIR_CPU_TYPE_GUEST) {
|
|
|
|
const char *tmp;
|
|
|
|
|
|
|
|
if (def->mode != VIR_CPU_MODE_CUSTOM || def->model) {
|
|
|
|
if (!(tmp = virCPUModeTypeToString(def->mode))) {
|
2012-07-18 10:50:44 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("Unexpected CPU mode %d"), def->mode);
|
2011-08-18 10:14:36 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
virBufferAsprintf(buf, " mode='%s'", tmp);
|
2011-09-21 23:42:07 +00:00
|
|
|
}
|
|
|
|
|
2011-08-18 10:14:36 +00:00
|
|
|
if (def->model &&
|
|
|
|
(def->mode == VIR_CPU_MODE_CUSTOM ||
|
|
|
|
(flags & VIR_DOMAIN_XML_UPDATE_CPU))) {
|
|
|
|
if (!(tmp = virCPUMatchTypeToString(def->match))) {
|
2012-07-18 10:50:44 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("Unexpected CPU match policy %d"),
|
|
|
|
def->match);
|
2011-08-18 10:14:36 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
virBufferAsprintf(buf, " match='%s'", tmp);
|
|
|
|
}
|
2011-09-21 23:42:07 +00:00
|
|
|
}
|
2011-08-18 10:14:36 +00:00
|
|
|
virBufferAddLit(buf, ">\n");
|
2011-09-21 23:42:07 +00:00
|
|
|
|
|
|
|
if (def->arch)
|
2012-12-11 12:58:54 +00:00
|
|
|
virBufferAsprintf(buf, " <arch>%s</arch>\n",
|
|
|
|
virArchToString(def->arch));
|
2011-09-21 23:42:07 +00:00
|
|
|
|
|
|
|
virBufferAdjustIndent(buf, 2);
|
2011-08-18 10:14:36 +00:00
|
|
|
if (virCPUDefFormatBuf(buf, def, flags) < 0)
|
2011-09-21 23:42:07 +00:00
|
|
|
return -1;
|
|
|
|
virBufferAdjustIndent(buf, -2);
|
|
|
|
|
|
|
|
virBufferAddLit(buf, "</cpu>\n");
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
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)
|
2009-12-18 13:44:55 +00:00
|
|
|
{
|
|
|
|
unsigned int i;
|
2011-08-18 10:14:36 +00:00
|
|
|
bool formatModel;
|
|
|
|
bool formatFallback;
|
2009-12-18 13:44:55 +00:00
|
|
|
|
|
|
|
if (!def)
|
|
|
|
return 0;
|
|
|
|
|
2011-08-18 10:14:36 +00:00
|
|
|
formatModel = (def->mode == VIR_CPU_MODE_CUSTOM ||
|
|
|
|
(flags & VIR_DOMAIN_XML_UPDATE_CPU));
|
|
|
|
formatFallback = (def->type == VIR_CPU_TYPE_GUEST &&
|
|
|
|
(def->mode == VIR_CPU_MODE_HOST_MODEL ||
|
|
|
|
(def->mode == VIR_CPU_MODE_CUSTOM && def->model)));
|
|
|
|
|
2010-01-12 14:25:36 +00:00
|
|
|
if (!def->model && def->nfeatures) {
|
2012-07-18 10:50:44 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
"%s", _("Non-empty feature list specified without CPU model"));
|
2009-12-18 13:44:55 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2011-08-18 10:14:36 +00:00
|
|
|
if ((formatModel && def->model) || formatFallback) {
|
2011-12-21 13:27:16 +00:00
|
|
|
virBufferAddLit(buf, "<model");
|
2011-08-18 10:14:36 +00:00
|
|
|
if (formatFallback) {
|
2011-12-21 13:27:16 +00:00
|
|
|
const char *fallback;
|
|
|
|
|
|
|
|
fallback = virCPUFallbackTypeToString(def->fallback);
|
|
|
|
if (!fallback) {
|
2012-07-18 10:50:44 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("Unexpected CPU fallback value: %d"),
|
|
|
|
def->fallback);
|
2011-12-21 13:27:16 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
virBufferAsprintf(buf, " fallback='%s'", fallback);
|
2012-06-28 10:21:17 +00:00
|
|
|
if (def->vendor_id)
|
|
|
|
virBufferAsprintf(buf, " vendor_id='%s'", def->vendor_id);
|
2011-12-21 13:27:16 +00:00
|
|
|
}
|
2011-08-18 10:14:36 +00:00
|
|
|
if (formatModel && def->model) {
|
|
|
|
virBufferAsprintf(buf, ">%s</model>\n", def->model);
|
|
|
|
} else {
|
|
|
|
virBufferAddLit(buf, "/>\n");
|
|
|
|
}
|
2011-12-21 13:27:16 +00:00
|
|
|
}
|
2009-12-18 13:44:55 +00:00
|
|
|
|
2011-08-18 10:14:36 +00:00
|
|
|
if (formatModel && def->vendor)
|
2011-09-21 23:42:07 +00:00
|
|
|
virBufferAsprintf(buf, "<vendor>%s</vendor>\n", def->vendor);
|
2010-07-02 15:51:59 +00:00
|
|
|
|
2009-12-18 13:44:55 +00:00
|
|
|
if (def->sockets && def->cores && def->threads) {
|
2011-09-21 23:42:07 +00:00
|
|
|
virBufferAddLit(buf, "<topology");
|
2011-04-30 16:34:49 +00:00
|
|
|
virBufferAsprintf(buf, " sockets='%u'", def->sockets);
|
|
|
|
virBufferAsprintf(buf, " cores='%u'", def->cores);
|
|
|
|
virBufferAsprintf(buf, " threads='%u'", def->threads);
|
2009-12-18 13:44:55 +00:00
|
|
|
virBufferAddLit(buf, "/>\n");
|
|
|
|
}
|
|
|
|
|
2011-08-18 10:14:36 +00:00
|
|
|
if (formatModel) {
|
2013-05-21 07:21:17 +00:00
|
|
|
for (i = 0; i < def->nfeatures; i++) {
|
2011-08-18 10:14:36 +00:00
|
|
|
virCPUFeatureDefPtr feature = def->features + i;
|
2009-12-18 13:44:55 +00:00
|
|
|
|
2011-08-18 10:14:36 +00:00
|
|
|
if (!feature->name) {
|
2012-07-18 10:50:44 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
"%s", _("Missing CPU feature name"));
|
2009-12-18 13:44:55 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2011-08-18 10:14:36 +00:00
|
|
|
|
|
|
|
if (def->type == VIR_CPU_TYPE_GUEST) {
|
|
|
|
const char *policy;
|
|
|
|
|
|
|
|
policy = virCPUFeaturePolicyTypeToString(feature->policy);
|
|
|
|
if (!policy) {
|
2012-07-18 10:50:44 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("Unexpected CPU feature policy %d"),
|
|
|
|
feature->policy);
|
2011-08-18 10:14:36 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
virBufferAsprintf(buf, "<feature policy='%s' name='%s'/>\n",
|
|
|
|
policy, feature->name);
|
|
|
|
} else {
|
|
|
|
virBufferAsprintf(buf, "<feature name='%s'/>\n",
|
|
|
|
feature->name);
|
|
|
|
}
|
2009-12-18 13:44:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-11 12:51:45 +00:00
|
|
|
if (def->ncells) {
|
|
|
|
virBufferAddLit(buf, "<numa>\n");
|
|
|
|
for (i = 0; i < def->ncells; i++) {
|
|
|
|
virBufferAddLit(buf, " <cell");
|
|
|
|
virBufferAsprintf(buf, " cpus='%s'", def->cells[i].cpustr);
|
|
|
|
virBufferAsprintf(buf, " memory='%d'", def->cells[i].mem);
|
|
|
|
virBufferAddLit(buf, "/>\n");
|
|
|
|
}
|
|
|
|
virBufferAddLit(buf, "</numa>\n");
|
|
|
|
}
|
2009-12-18 13:44:55 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int
|
2010-02-10 12:22:36 +00:00
|
|
|
virCPUDefAddFeature(virCPUDefPtr def,
|
2009-12-18 13:44:55 +00:00
|
|
|
const char *name,
|
|
|
|
int policy)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2013-05-21 07:21:17 +00:00
|
|
|
for (i = 0; i < def->nfeatures; i++) {
|
2009-12-18 13:44:55 +00:00
|
|
|
if (STREQ(name, def->features[i].name)) {
|
2012-07-18 10:50:44 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("CPU feature `%s' specified more than once"), name);
|
2009-12-18 13:44:55 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-17 21:41:51 +00:00
|
|
|
if (VIR_RESIZE_N(def->features, def->nfeatures_max,
|
|
|
|
def->nfeatures, 1) < 0)
|
2013-07-04 10:02:00 +00:00
|
|
|
return -1;
|
2009-12-18 13:44:55 +00:00
|
|
|
|
|
|
|
if (def->type == VIR_CPU_TYPE_HOST)
|
|
|
|
policy = -1;
|
|
|
|
|
2013-05-03 12:40:46 +00:00
|
|
|
if (VIR_STRDUP(def->features[def->nfeatures].name, name) < 0)
|
|
|
|
return -1;
|
2009-12-18 13:44:55 +00:00
|
|
|
|
|
|
|
def->features[def->nfeatures].policy = policy;
|
|
|
|
def->nfeatures++;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2011-05-27 09:47:30 +00:00
|
|
|
|
|
|
|
bool
|
|
|
|
virCPUDefIsEqual(virCPUDefPtr src,
|
|
|
|
virCPUDefPtr dst)
|
|
|
|
{
|
|
|
|
bool identical = false;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (!src && !dst)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if ((src && !dst) || (!src && dst)) {
|
2012-07-18 10:50:44 +00:00
|
|
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
|
|
|
_("Target CPU does not match source"));
|
2011-05-27 09:47:30 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (src->type != dst->type) {
|
2012-07-18 10:50:44 +00:00
|
|
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
|
|
|
_("Target CPU type %s does not match source %s"),
|
|
|
|
virCPUTypeToString(dst->type),
|
|
|
|
virCPUTypeToString(src->type));
|
2011-05-27 09:47:30 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2011-08-18 10:14:36 +00:00
|
|
|
if (src->mode != dst->mode) {
|
2012-07-18 10:50:44 +00:00
|
|
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
|
|
|
_("Target CPU mode %s does not match source %s"),
|
|
|
|
virCPUModeTypeToString(dst->mode),
|
|
|
|
virCPUModeTypeToString(src->mode));
|
2011-08-18 10:14:36 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2012-12-11 12:58:54 +00:00
|
|
|
if (src->arch != dst->arch) {
|
2012-07-18 10:50:44 +00:00
|
|
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
|
|
|
_("Target CPU arch %s does not match source %s"),
|
2012-12-11 12:58:54 +00:00
|
|
|
virArchToString(dst->arch),
|
|
|
|
virArchToString(src->arch));
|
2011-05-27 09:47:30 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (STRNEQ_NULLABLE(src->model, dst->model)) {
|
2012-07-18 10:50:44 +00:00
|
|
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
|
|
|
_("Target CPU model %s does not match source %s"),
|
|
|
|
NULLSTR(dst->model), NULLSTR(src->model));
|
2011-05-27 09:47:30 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (STRNEQ_NULLABLE(src->vendor, dst->vendor)) {
|
2012-07-18 10:50:44 +00:00
|
|
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
|
|
|
_("Target CPU vendor %s does not match source %s"),
|
|
|
|
NULLSTR(dst->vendor), NULLSTR(src->vendor));
|
2011-05-27 09:47:30 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2012-06-28 10:21:17 +00:00
|
|
|
if (STRNEQ_NULLABLE(src->vendor_id, dst->vendor_id)) {
|
2012-07-18 10:50:44 +00:00
|
|
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
|
|
|
_("Target CPU model %s does not match source %s"),
|
|
|
|
NULLSTR(dst->vendor_id), NULLSTR(src->vendor_id));
|
2012-06-28 10:21:17 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2011-05-27 09:47:30 +00:00
|
|
|
if (src->sockets != dst->sockets) {
|
2012-07-18 10:50:44 +00:00
|
|
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
|
|
|
_("Target CPU sockets %d does not match source %d"),
|
|
|
|
dst->sockets, src->sockets);
|
2011-05-27 09:47:30 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (src->cores != dst->cores) {
|
2012-07-18 10:50:44 +00:00
|
|
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
|
|
|
_("Target CPU cores %d does not match source %d"),
|
|
|
|
dst->cores, src->cores);
|
2011-05-27 09:47:30 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (src->threads != dst->threads) {
|
2012-07-18 10:50:44 +00:00
|
|
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
|
|
|
_("Target CPU threads %d does not match source %d"),
|
|
|
|
dst->threads, src->threads);
|
2011-05-27 09:47:30 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (src->nfeatures != dst->nfeatures) {
|
2012-07-18 10:50:44 +00:00
|
|
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
|
|
|
_("Target CPU feature count %zu does not match source %zu"),
|
|
|
|
dst->nfeatures, src->nfeatures);
|
2011-05-27 09:47:30 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2013-05-21 07:21:17 +00:00
|
|
|
for (i = 0; i < src->nfeatures; i++) {
|
2011-05-27 09:47:30 +00:00
|
|
|
if (STRNEQ(src->features[i].name, dst->features[i].name)) {
|
2012-07-18 10:50:44 +00:00
|
|
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
|
|
|
_("Target CPU feature %s does not match source %s"),
|
|
|
|
dst->features[i].name, src->features[i].name);
|
2011-05-27 09:47:30 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (src->features[i].policy != dst->features[i].policy) {
|
2012-07-18 10:50:44 +00:00
|
|
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
|
|
|
_("Target CPU feature policy %s does not match source %s"),
|
|
|
|
virCPUFeaturePolicyTypeToString(dst->features[i].policy),
|
|
|
|
virCPUFeaturePolicyTypeToString(src->features[i].policy));
|
2011-05-27 09:47:30 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
identical = true;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
return identical;
|
|
|
|
}
|