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

conf: Refactor virDomainDefOSValidate()

This makes it explicit that there are two possible scenarios
(whether or not firmware autoselection is in use) and will make
upcoming changes cleaner to implement.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Andrea Bolognani 2022-06-16 11:30:30 +02:00
parent 421d4f1fa8
commit f5dcd8b979

View File

@ -1598,22 +1598,24 @@ static int
virDomainDefOSValidate(const virDomainDef *def, virDomainDefOSValidate(const virDomainDef *def,
virDomainXMLOption *xmlopt) virDomainXMLOption *xmlopt)
{ {
if (def->os.firmware && virDomainLoaderDef *loader = def->os.loader;
!(xmlopt->config.features & VIR_DOMAIN_DEF_FEATURE_FW_AUTOSELECT)) {
if (def->os.firmware) {
if (!(xmlopt->config.features & VIR_DOMAIN_DEF_FEATURE_FW_AUTOSELECT)) {
virReportError(VIR_ERR_XML_DETAIL, "%s", virReportError(VIR_ERR_XML_DETAIL, "%s",
_("firmware auto selection not implemented for this driver")); _("firmware auto selection not implemented for this driver"));
return -1; return -1;
} }
} else {
if (!def->os.loader) if (!loader)
return 0; return 0;
if (!def->os.loader->path && if (!loader->path) {
def->os.firmware == VIR_DOMAIN_OS_DEF_FIRMWARE_NONE) {
virReportError(VIR_ERR_XML_DETAIL, "%s", virReportError(VIR_ERR_XML_DETAIL, "%s",
_("no loader path specified and firmware auto selection disabled")); _("no loader path specified and firmware auto selection disabled"));
return -1; return -1;
} }
}
return 0; return 0;
} }