]> xenbits.xensource.com Git - libvirt.git/commitdiff
seclabel: Do not output relabel attribute for type 'none'
authorJiri Denemark <jdenemar@redhat.com>
Tue, 7 Feb 2012 18:19:01 +0000 (19:19 +0100)
committerJiri Denemark <jdenemar@redhat.com>
Wed, 8 Feb 2012 10:55:56 +0000 (11:55 +0100)
Security label type 'none' requires relabel to be set to 'no' so there's
no reason to output this extra attribute.  Moreover, since relabel is
internally stored in a negative from (norelabel), the default value for
relabel would be 'yes' in case there is no <seclabel> element in domain
configuration.  In case VIR_DOMAIN_SECLABEL_DEFAULT turns into
VIR_DOMAIN_SECLABEL_NONE, we would incorrectly output relabel='yes' for
seclabel type 'none'.

src/conf/domain_conf.c
tests/qemuxml2argvdata/qemuxml2argv-seclabel-none.xml

index 6949ecedc185b7d4d451e621d809e525c3c0c31a..81836e5d4f2dc052eeabae3ee70699b86336c8e4 100644 (file)
@@ -9948,16 +9948,17 @@ virSecurityLabelDefFormat(virBufferPtr buf, virSecurityLabelDefPtr def)
 
     virBufferAsprintf(buf, "<seclabel type='%s'",
                       sectype);
-    virBufferEscapeString(buf, " model='%s'", def->model);
-
-    virBufferAsprintf(buf, " relabel='%s'",
-                      def->norelabel ? "no" : "yes");
 
     if (def->type == VIR_DOMAIN_SECLABEL_NONE) {
         virBufferAddLit(buf, "/>\n");
         return;
     }
 
+    virBufferEscapeString(buf, " model='%s'", def->model);
+
+    virBufferAsprintf(buf, " relabel='%s'",
+                      def->norelabel ? "no" : "yes");
+
     if (def->label || def->imagelabel || def->baselabel) {
         virBufferAddLit(buf, ">\n");
 
index 1ef97ce1d82dba896ee8ffe6627769d5b8a2ef1c..9def692132f0c0ff2788319699fd2a4953f6b03f 100644 (file)
@@ -22,5 +22,5 @@
     <controller type='ide' index='0'/>
     <memballoon model='virtio'/>
   </devices>
-  <seclabel type='none' relabel='no'/>
+  <seclabel type='none'/>
 </domain>