[PATCH 02/12] virSecurityLabelDef: Declare 'type' as 'virDomainSeclabelType'

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 src/conf/domain_conf.c          | 14 +++++---------
 src/security/security_selinux.c |  3 ++-
 src/util/virseclabel.h          |  2 +-
 3 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 552d43b845..ba38d510dd 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -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)
diff --git a/src/security/security_selinux.c b/src/security/security_selinux.c
index 840a05844e..5682d2bb9d 100644
--- a/src/security/security_selinux.c
+++ b/src/security/security_selinux.c
@@ -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'"),
diff --git a/src/util/virseclabel.h b/src/util/virseclabel.h
index 77bf6da2c3..eca4d09d24 100644
--- a/src/util/virseclabel.h
+++ b/src/util/virseclabel.h
@@ -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 */
 };
-- 
2.31.1




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux