virSecurityLabelDef: Declare 'type' as 'virDomainSeclabelType'

Use the appropriate enum type instead of an int and fix the XML parser
and one missing fully populated switch.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2021-11-22 16:31:44 +01:00
parent 396ce0b568
commit f7ff8556ad
3 changed files with 8 additions and 11 deletions

View File

@ -7813,15 +7813,11 @@ virSecurityLabelDefParseXML(xmlXPathContextPtr ctxt,
/* set default value */
seclabel->type = VIR_DOMAIN_SECLABEL_DYNAMIC;
p = virXMLPropString(ctxt->node, "type");
if (p) {
seclabel->type = virDomainSeclabelTypeFromString(p);
if (seclabel->type <= 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("invalid security type '%s'"), p);
goto error;
}
}
if (virXMLPropEnum(ctxt->node, "type",
virDomainSeclabelTypeFromString,
VIR_XML_PROP_NONZERO,
&seclabel->type) < 0)
goto error;
if (seclabel->type == VIR_DOMAIN_SECLABEL_STATIC ||
seclabel->type == VIR_DOMAIN_SECLABEL_NONE)

View File

@ -899,7 +899,8 @@ virSecuritySELinuxGenLabel(virSecurityManager *mgr,
mcs = g_strdup(sens);
break;
case VIR_DOMAIN_SECLABEL_DEFAULT:
case VIR_DOMAIN_SECLABEL_LAST:
default:
virReportError(VIR_ERR_INTERNAL_ERROR,
_("unexpected security label type '%s'"),

View File

@ -37,7 +37,7 @@ struct _virSecurityLabelDef {
char *label; /* security label string */
char *imagelabel; /* security image label string */
char *baselabel; /* base name of label string */
int type; /* virDomainSeclabelType */
virDomainSeclabelType type; /* virDomainSeclabelType */
bool relabel; /* true (default) for allowing relabels */
bool implicit; /* true if seclabel is auto-added */
};