From: Jiri Denemark Date: Tue, 7 Feb 2012 18:19:01 +0000 (+0100) Subject: seclabel: Do not output relabel attribute for type 'none' X-Git-Tag: v0.9.10~27 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f6957617c55ba7d5e6ca672b6d86f4352fd0119f;p=thirdparty%2Flibvirt.git 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 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'. --- diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 6949ecedc1..81836e5d4f 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -9948,16 +9948,17 @@ virSecurityLabelDefFormat(virBufferPtr buf, virSecurityLabelDefPtr def) virBufferAsprintf(buf, "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 1ef97ce1d8..9def692132 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-seclabel-none.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-seclabel-none.xml @@ -22,5 +22,5 @@ - +