aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJiri Denemark <jdenemar@redhat.com>2012-02-07 19:19:01 +0100
committerJiri Denemark <jdenemar@redhat.com>2012-02-08 11:55:56 +0100
commitf6957617c55ba7d5e6ca672b6d86f4352fd0119f (patch)
tree428139db2af9137e77621bf0e6e672309f80eb4e
parentqemu: Always use iohelper for dumping domain core (diff)
downloadlibvirt-f6957617c55ba7d5e6ca672b6d86f4352fd0119f.tar.gz
libvirt-f6957617c55ba7d5e6ca672b6d86f4352fd0119f.tar.bz2
libvirt-f6957617c55ba7d5e6ca672b6d86f4352fd0119f.zip
seclabel: Do not output relabel attribute for type 'none'
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'.
-rw-r--r--src/conf/domain_conf.c9
-rw-r--r--tests/qemuxml2argvdata/qemuxml2argv-seclabel-none.xml2
2 files changed, 6 insertions, 5 deletions
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 6949ecedc..81836e5d4 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -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");
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-seclabel-none.xml b/tests/qemuxml2argvdata/qemuxml2argv-seclabel-none.xml
index 1ef97ce1d..9def69213 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-seclabel-none.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-seclabel-none.xml
@@ -22,5 +22,5 @@
<controller type='ide' index='0'/>
<memballoon model='virtio'/>
</devices>
- <seclabel type='none' relabel='no'/>
+ <seclabel type='none'/>
</domain>