conf: Avoid formatting empty <capabilities> element

If none of the 'capabilities' features are enabled we'd still format the
opening and closing tag for the <capabilities element.

The implementation is suboptimal but will be refactored for a better
approach. This is done prior to the refactor to show that tests are not
impacted.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2019-03-05 13:56:46 +01:00
parent c7637521d6
commit 89dda12b8d
12 changed files with 19 additions and 23 deletions

View File

@ -27933,8 +27933,15 @@ virDomainDefFormatFeatures(virBufferPtr buf,
break;
}
virBufferAsprintf(buf, "<capabilities policy='%s'>\n",
virBufferAsprintf(buf, "<capabilities policy='%s'",
virDomainCapabilitiesPolicyTypeToString(def->features[i]));
if (!virDomainDefHasCapabilitiesFeatures(def)) {
virBufferAddLit(buf, "/>\n");
break;
} else {
virBufferAddLit(buf, ">\n");
}
virBufferAdjustIndent(buf, 2);
for (j = 0; j < VIR_DOMAIN_CAPS_FEATURE_LAST; j++) {
if (def->caps_features[j] != VIR_TRISTATE_SWITCH_ABSENT)

View File

@ -25,8 +25,7 @@
</os>
<features>
<privnet/>
<capabilities policy='allow'>
</capabilities>
<capabilities policy='allow'/>
</features>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>

View File

@ -13,8 +13,7 @@
</os>
<features>
<privnet/>
<capabilities policy='allow'>
</capabilities>
<capabilities policy='allow'/>
</features>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>

View File

@ -15,8 +15,7 @@
</os>
<features>
<privnet/>
<capabilities policy='allow'>
</capabilities>
<capabilities policy='allow'/>
</features>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>

View File

@ -14,8 +14,7 @@
</idmap>
<features>
<privnet/>
<capabilities policy='allow'>
</capabilities>
<capabilities policy='allow'/>
</features>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>

View File

@ -9,8 +9,7 @@
<init>/sbin/init</init>
</os>
<features>
<capabilities policy='allow'>
</capabilities>
<capabilities policy='allow'/>
</features>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>

View File

@ -15,8 +15,7 @@
</os>
<features>
<privnet/>
<capabilities policy='allow'>
</capabilities>
<capabilities policy='allow'/>
</features>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>

View File

@ -9,8 +9,7 @@
<init>/sbin/init</init>
</os>
<features>
<capabilities policy='allow'>
</capabilities>
<capabilities policy='allow'/>
</features>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>

View File

@ -9,8 +9,7 @@
<init>/sbin/init</init>
</os>
<features>
<capabilities policy='allow'>
</capabilities>
<capabilities policy='allow'/>
</features>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>

View File

@ -10,8 +10,7 @@
</os>
<features>
<privnet/>
<capabilities policy='allow'>
</capabilities>
<capabilities policy='allow'/>
</features>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>

View File

@ -9,8 +9,7 @@
<init>/sbin/init</init>
</os>
<features>
<capabilities policy='allow'>
</capabilities>
<capabilities policy='allow'/>
</features>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>

View File

@ -9,8 +9,7 @@
<init>/sbin/init</init>
</os>
<features>
<capabilities policy='allow'>
</capabilities>
<capabilities policy='allow'/>
</features>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>