mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-20 07:59:00 +00:00
Allow for CPU topology specification without model
Currently CPU topology may only be specified together with CPU model: <cpu match='exact'> <model>name</model> <topology sockets='1' cores='2' threads='3'/> </cpu> This patch allows for CPU topology specification without the need for also specifying CPU model: <cpu> <topology sockets='1' cores='2' threads='3'/> </cpu> 'match' attribute and 'model' element are made optional with the restriction that 'match' attribute has to be set when 'model' is present. Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
This commit is contained in:
parent
16a4d22b4b
commit
ce4896fb65
@ -1307,17 +1307,21 @@
|
|||||||
-->
|
-->
|
||||||
<define name="cpu">
|
<define name="cpu">
|
||||||
<element name="cpu">
|
<element name="cpu">
|
||||||
<attribute name="match">
|
<optional>
|
||||||
<choice>
|
<attribute name="match">
|
||||||
<value>minimum</value>
|
<choice>
|
||||||
<value>exact</value>
|
<value>minimum</value>
|
||||||
<value>strict</value>
|
<value>exact</value>
|
||||||
</choice>
|
<value>strict</value>
|
||||||
</attribute>
|
</choice>
|
||||||
|
</attribute>
|
||||||
|
</optional>
|
||||||
<interleave>
|
<interleave>
|
||||||
<element name="model">
|
<optional>
|
||||||
<text/>
|
<element name="model">
|
||||||
</element>
|
<text/>
|
||||||
|
</element>
|
||||||
|
</optional>
|
||||||
<optional>
|
<optional>
|
||||||
<element name="topology">
|
<element name="topology">
|
||||||
<attribute name="sockets">
|
<attribute name="sockets">
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* cpu_conf.h: CPU XML handling
|
* cpu_conf.h: CPU XML handling
|
||||||
*
|
*
|
||||||
* Copyright (C) 2009 Red Hat, Inc.
|
* Copyright (C) 2009, 2010 Red Hat, Inc.
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
@ -76,7 +76,6 @@ virCPUDefParseXML(virConnectPtr conn,
|
|||||||
{
|
{
|
||||||
virCPUDefPtr def;
|
virCPUDefPtr def;
|
||||||
xmlNodePtr *nodes = NULL;
|
xmlNodePtr *nodes = NULL;
|
||||||
char *match;
|
|
||||||
int n;
|
int n;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
@ -85,18 +84,33 @@ virCPUDefParseXML(virConnectPtr conn,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
match = virXMLPropString(node, "match");
|
if (mode == VIR_CPU_TYPE_AUTO) {
|
||||||
|
if (virXPathBoolean(conn, "boolean(./arch)", ctxt))
|
||||||
if (mode == VIR_CPU_TYPE_AUTO)
|
def->type = VIR_CPU_TYPE_HOST;
|
||||||
def->type = (match == NULL) ? VIR_CPU_TYPE_HOST : VIR_CPU_TYPE_GUEST;
|
else
|
||||||
else
|
def->type = VIR_CPU_TYPE_GUEST;
|
||||||
|
} else
|
||||||
def->type = mode;
|
def->type = mode;
|
||||||
|
|
||||||
if (def->type == VIR_CPU_TYPE_GUEST) {
|
if (def->type == VIR_CPU_TYPE_GUEST) {
|
||||||
if ((def->match = virCPUMatchTypeFromString(match)) < 0) {
|
char *match = virXMLPropString(node, "match");
|
||||||
virCPUReportError(conn, VIR_ERR_INTERNAL_ERROR,
|
|
||||||
"%s", _("Invalid match attribute for CPU specification"));
|
if (!match) {
|
||||||
goto error;
|
if (virXPathBoolean(conn, "boolean(./model)", ctxt)) {
|
||||||
|
virCPUReportError(conn, VIR_ERR_INTERNAL_ERROR,
|
||||||
|
"%s", _("Missing match attribute for CPU specification"));
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
def->match = -1;
|
||||||
|
} else {
|
||||||
|
def->match = virCPUMatchTypeFromString(match);
|
||||||
|
VIR_FREE(match);
|
||||||
|
|
||||||
|
if (def->match < 0) {
|
||||||
|
virCPUReportError(conn, VIR_ERR_INTERNAL_ERROR,
|
||||||
|
"%s", _("Invalid match attribute for CPU specification"));
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,7 +123,8 @@ virCPUDefParseXML(virConnectPtr conn,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(def->model = virXPathString(conn, "string(./model[1])", ctxt))) {
|
if (!(def->model = virXPathString(conn, "string(./model[1])", ctxt)) &&
|
||||||
|
def->type == VIR_CPU_TYPE_HOST) {
|
||||||
virCPUReportError(conn, VIR_ERR_INTERNAL_ERROR,
|
virCPUReportError(conn, VIR_ERR_INTERNAL_ERROR,
|
||||||
"%s", _("Missing CPU model name"));
|
"%s", _("Missing CPU model name"));
|
||||||
goto error;
|
goto error;
|
||||||
@ -158,6 +173,12 @@ virCPUDefParseXML(virConnectPtr conn,
|
|||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if (n > 0) {
|
if (n > 0) {
|
||||||
|
if (!def->model) {
|
||||||
|
virCPUReportError(conn, VIR_ERR_INTERNAL_ERROR,
|
||||||
|
"%s", _("Non-empty feature list specified without CPU model"));
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
if (VIR_ALLOC_N(def->features, n) < 0)
|
if (VIR_ALLOC_N(def->features, n) < 0)
|
||||||
goto no_memory;
|
goto no_memory;
|
||||||
def->nfeatures = n;
|
def->nfeatures = n;
|
||||||
@ -206,7 +227,6 @@ virCPUDefParseXML(virConnectPtr conn,
|
|||||||
}
|
}
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
VIR_FREE(match);
|
|
||||||
VIR_FREE(nodes);
|
VIR_FREE(nodes);
|
||||||
|
|
||||||
return def;
|
return def;
|
||||||
@ -263,14 +283,14 @@ virCPUDefFormatBuf(virConnectPtr conn,
|
|||||||
if (indent == NULL)
|
if (indent == NULL)
|
||||||
indent = "";
|
indent = "";
|
||||||
|
|
||||||
if (!def->model) {
|
if (!def->model && def->nfeatures) {
|
||||||
virCPUReportError(conn, VIR_ERR_INTERNAL_ERROR,
|
virCPUReportError(conn, VIR_ERR_INTERNAL_ERROR,
|
||||||
"%s", _("Missing CPU model"));
|
"%s", _("Non-empty feature list specified without CPU model"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(flags & VIR_CPU_FORMAT_EMBEDED)) {
|
if (!(flags & VIR_CPU_FORMAT_EMBEDED)) {
|
||||||
if (def->type == VIR_CPU_TYPE_GUEST) {
|
if (def->type == VIR_CPU_TYPE_GUEST && def->model) {
|
||||||
const char *match;
|
const char *match;
|
||||||
if (!(match = virCPUMatchTypeToString(def->match))) {
|
if (!(match = virCPUMatchTypeToString(def->match))) {
|
||||||
virCPUReportError(conn, VIR_ERR_INTERNAL_ERROR,
|
virCPUReportError(conn, VIR_ERR_INTERNAL_ERROR,
|
||||||
@ -287,7 +307,8 @@ virCPUDefFormatBuf(virConnectPtr conn,
|
|||||||
virBufferVSprintf(buf, "%s <arch>%s</arch>\n", indent, def->arch);
|
virBufferVSprintf(buf, "%s <arch>%s</arch>\n", indent, def->arch);
|
||||||
}
|
}
|
||||||
|
|
||||||
virBufferVSprintf(buf, "%s <model>%s</model>\n", indent, def->model);
|
if (def->model)
|
||||||
|
virBufferVSprintf(buf, "%s <model>%s</model>\n", indent, def->model);
|
||||||
|
|
||||||
if (def->sockets && def->cores && def->threads) {
|
if (def->sockets && def->cores && def->threads) {
|
||||||
virBufferVSprintf(buf, "%s <topology", indent);
|
virBufferVSprintf(buf, "%s <topology", indent);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user