mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 22:25:25 +00:00
cpu: Fail when CPU type cannot be detected from XML
When autodetecting whether XML describes guest or host CPU, the presence of <arch> element is checked. If it's present, we treat the XML as host CPU definition. Which is right, since guest CPU definitions do not contain <arch> element. However, if at the same time the root <cpu> element contains `match' attribute, we would silently ignore it and still treat the XML as host CPU. We should rather refuse such invalid XML.
This commit is contained in:
parent
ac3daf0899
commit
517aba9fac
@ -130,9 +130,15 @@ virCPUDefParseXML(const xmlNodePtr node,
|
||||
}
|
||||
|
||||
if (mode == VIR_CPU_TYPE_AUTO) {
|
||||
if (virXPathBoolean("boolean(./arch)", ctxt))
|
||||
if (virXPathBoolean("boolean(./arch)", ctxt)) {
|
||||
if (virXPathBoolean("boolean(./@match)", ctxt)) {
|
||||
virCPUReportError(VIR_ERR_XML_ERROR, "%s",
|
||||
_("'arch' element element cannot be used inside 'cpu'"
|
||||
" element with 'match' attribute'"));
|
||||
goto error;
|
||||
}
|
||||
def->type = VIR_CPU_TYPE_HOST;
|
||||
else
|
||||
} else
|
||||
def->type = VIR_CPU_TYPE_GUEST;
|
||||
} else
|
||||
def->type = mode;
|
||||
|
Loading…
Reference in New Issue
Block a user