mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 13:45:38 +00:00
conf: Catch invalid memory model earlier
Consider the following XML snippet: <memory model=''> <target> <size unit='KiB'>523264</size> <node>0</node> </target> </memory> Whats wrong you ask? The @model attribute. This should result in an error thrown into users faces during virDomainDefine phase. Except it doesn't. The XML validation catches this error, but if users chose to ignore that, they will end up with invalid XML. Well, they won't be able to start the machine - that's when error is produced currently. But it would be nice if we could catch the error like this earlier. Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
f5f32bcd1b
commit
1e05846373
@ -13215,7 +13215,7 @@ virDomainMemoryDefParseXML(xmlNodePtr memdevNode,
|
||||
goto error;
|
||||
}
|
||||
|
||||
if ((def->model = virDomainMemoryModelTypeFromString(tmp)) < 0) {
|
||||
if ((def->model = virDomainMemoryModelTypeFromString(tmp)) <= 0) {
|
||||
virReportError(VIR_ERR_XML_ERROR,
|
||||
_("invalid memory model '%s'"), tmp);
|
||||
goto error;
|
||||
|
@ -3397,8 +3397,6 @@ qemuBuildMemoryDeviceStr(virDomainMemoryDefPtr mem)
|
||||
|
||||
case VIR_DOMAIN_MEMORY_MODEL_NONE:
|
||||
case VIR_DOMAIN_MEMORY_MODEL_LAST:
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("invalid memory device type"));
|
||||
break;
|
||||
|
||||
}
|
||||
|
@ -5183,8 +5183,6 @@ qemuDomainDefValidateMemoryHotplugDevice(const virDomainMemoryDef *mem,
|
||||
|
||||
case VIR_DOMAIN_MEMORY_MODEL_NONE:
|
||||
case VIR_DOMAIN_MEMORY_MODEL_LAST:
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("invalid memory device type"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user