1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-03-07 17:28:15 +00:00

conf: Refactor virDomainVcpuPinDefParseXML

Refactor the code to parse the vcpupin in a similar way the iothreadpin
code is now structured. This allows to get rid of some very strange
conditions and error messages.

Additionally since a existing bug
( https://bugzilla.redhat.com/show_bug.cgi?id=1208434 ) allows to add
vcpupin definitions for vcpus that don't exist, this patch makes the
parser to ignore all vcpupins that don't have a matching vCPU in the
definition rather than just offlined ones.
This commit is contained in:
Peter Krempa 2015-04-07 20:09:04 +02:00
parent 78d1b0f9b3
commit 3f9fb2b587

View File

@ -13180,36 +13180,30 @@ virDomainIdmapDefParseXML(xmlXPathContextPtr ctxt,
*/ */
static virDomainPinDefPtr static virDomainPinDefPtr
virDomainVcpuPinDefParseXML(xmlNodePtr node, virDomainVcpuPinDefParseXML(xmlNodePtr node,
xmlXPathContextPtr ctxt, xmlXPathContextPtr ctxt)
int maxvcpus)
{ {
virDomainPinDefPtr def; virDomainPinDefPtr def;
xmlNodePtr oldnode = ctxt->node; xmlNodePtr oldnode = ctxt->node;
int vcpuid = -1; unsigned int vcpuid;
char *tmp = NULL; char *tmp = NULL;
int ret;
if (VIR_ALLOC(def) < 0) if (VIR_ALLOC(def) < 0)
return NULL; return NULL;
ctxt->node = node; ctxt->node = node;
ret = virXPathInt("string(./@vcpu)", ctxt, &vcpuid); if (!(tmp = virXPathString("string(./@vcpu)", ctxt))) {
if ((ret == -2) || (vcpuid < -1)) { virReportError(VIR_ERR_XML_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing vcpu id in vcpupin"));
_("vcpu id must be an unsigned integer or -1"));
goto error;
} else if (vcpuid == -1) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("vcpu id value -1 is not allowed for vcpupin"));
goto error; goto error;
} }
if (vcpuid >= maxvcpus) { if (virStrToLong_uip(tmp, NULL, 10, &vcpuid) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", virReportError(VIR_ERR_XML_ERROR,
_("vcpu id must be less than maxvcpus")); _("invalid setting for vcpu '%s'"), tmp);
goto error; goto error;
} }
VIR_FREE(tmp);
def->id = vcpuid; def->id = vcpuid;
@ -14034,11 +14028,8 @@ virDomainDefParseXML(xmlDocPtr xml,
goto error; goto error;
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
virDomainPinDefPtr vcpupin = NULL; virDomainPinDefPtr vcpupin;
vcpupin = virDomainVcpuPinDefParseXML(nodes[i], ctxt, if (!(vcpupin = virDomainVcpuPinDefParseXML(nodes[i], ctxt)))
def->maxvcpus);
if (!vcpupin)
goto error; goto error;
if (virDomainPinIsDuplicate(def->cputune.vcpupin, if (virDomainPinIsDuplicate(def->cputune.vcpupin,
@ -14056,7 +14047,7 @@ virDomainDefParseXML(xmlDocPtr xml,
* <vcpupin> nodes greater than current vcpus, * <vcpupin> nodes greater than current vcpus,
* ignoring them instead. * ignoring them instead.
*/ */
VIR_WARN("Ignore vcpupin for not onlined vcpus"); VIR_WARN("Ignore vcpupin for missing vcpus");
virDomainPinDefFree(vcpupin); virDomainPinDefFree(vcpupin);
} else { } else {
def->cputune.vcpupin[def->cputune.nvcpupin++] = vcpupin; def->cputune.vcpupin[def->cputune.nvcpupin++] = vcpupin;