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@xxxxxxxxxx> --- src/conf/domain_conf.c | 9 ++++++++- tests/lxcconf2xmldata/lxcconf2xml-blkiotune.xml | 3 +-- tests/lxcconf2xmldata/lxcconf2xml-cpusettune.xml | 3 +-- tests/lxcconf2xmldata/lxcconf2xml-cputune.xml | 3 +-- tests/lxcconf2xmldata/lxcconf2xml-idmap.xml | 3 +-- tests/lxcconf2xmldata/lxcconf2xml-macvlannetwork.xml | 3 +-- tests/lxcconf2xmldata/lxcconf2xml-memtune.xml | 3 +-- tests/lxcconf2xmldata/lxcconf2xml-miscnetwork.xml | 3 +-- tests/lxcconf2xmldata/lxcconf2xml-nonenetwork.xml | 3 +-- tests/lxcconf2xmldata/lxcconf2xml-nonetwork.xml | 3 +-- tests/lxcconf2xmldata/lxcconf2xml-physnetwork.xml | 3 +-- tests/lxcconf2xmldata/lxcconf2xml-vlannetwork.xml | 3 +-- 12 files changed, 19 insertions(+), 23 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index b42c63fb4d..90aa02a7ea 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -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) diff --git a/tests/lxcconf2xmldata/lxcconf2xml-blkiotune.xml b/tests/lxcconf2xmldata/lxcconf2xml-blkiotune.xml index 641edb94fa..ab07fb0e80 100644 --- a/tests/lxcconf2xmldata/lxcconf2xml-blkiotune.xml +++ b/tests/lxcconf2xmldata/lxcconf2xml-blkiotune.xml @@ -25,8 +25,7 @@ </os> <features> <privnet/> - <capabilities policy='allow'> - </capabilities> + <capabilities policy='allow'/> </features> <clock offset='utc'/> <on_poweroff>destroy</on_poweroff> diff --git a/tests/lxcconf2xmldata/lxcconf2xml-cpusettune.xml b/tests/lxcconf2xmldata/lxcconf2xml-cpusettune.xml index bafaa960f8..6df089d00f 100644 --- a/tests/lxcconf2xmldata/lxcconf2xml-cpusettune.xml +++ b/tests/lxcconf2xmldata/lxcconf2xml-cpusettune.xml @@ -13,8 +13,7 @@ </os> <features> <privnet/> - <capabilities policy='allow'> - </capabilities> + <capabilities policy='allow'/> </features> <clock offset='utc'/> <on_poweroff>destroy</on_poweroff> diff --git a/tests/lxcconf2xmldata/lxcconf2xml-cputune.xml b/tests/lxcconf2xmldata/lxcconf2xml-cputune.xml index f7f8041dd6..359c820a2d 100644 --- a/tests/lxcconf2xmldata/lxcconf2xml-cputune.xml +++ b/tests/lxcconf2xmldata/lxcconf2xml-cputune.xml @@ -15,8 +15,7 @@ </os> <features> <privnet/> - <capabilities policy='allow'> - </capabilities> + <capabilities policy='allow'/> </features> <clock offset='utc'/> <on_poweroff>destroy</on_poweroff> diff --git a/tests/lxcconf2xmldata/lxcconf2xml-idmap.xml b/tests/lxcconf2xmldata/lxcconf2xml-idmap.xml index dd3843d5cb..1efcc131cb 100644 --- a/tests/lxcconf2xmldata/lxcconf2xml-idmap.xml +++ b/tests/lxcconf2xmldata/lxcconf2xml-idmap.xml @@ -14,8 +14,7 @@ </idmap> <features> <privnet/> - <capabilities policy='allow'> - </capabilities> + <capabilities policy='allow'/> </features> <clock offset='utc'/> <on_poweroff>destroy</on_poweroff> diff --git a/tests/lxcconf2xmldata/lxcconf2xml-macvlannetwork.xml b/tests/lxcconf2xmldata/lxcconf2xml-macvlannetwork.xml index a345e8e019..cced2f25db 100644 --- a/tests/lxcconf2xmldata/lxcconf2xml-macvlannetwork.xml +++ b/tests/lxcconf2xmldata/lxcconf2xml-macvlannetwork.xml @@ -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> diff --git a/tests/lxcconf2xmldata/lxcconf2xml-memtune.xml b/tests/lxcconf2xmldata/lxcconf2xml-memtune.xml index 57e751aaba..24af021e49 100644 --- a/tests/lxcconf2xmldata/lxcconf2xml-memtune.xml +++ b/tests/lxcconf2xmldata/lxcconf2xml-memtune.xml @@ -15,8 +15,7 @@ </os> <features> <privnet/> - <capabilities policy='allow'> - </capabilities> + <capabilities policy='allow'/> </features> <clock offset='utc'/> <on_poweroff>destroy</on_poweroff> diff --git a/tests/lxcconf2xmldata/lxcconf2xml-miscnetwork.xml b/tests/lxcconf2xmldata/lxcconf2xml-miscnetwork.xml index 63189cfaec..9e41e408ee 100644 --- a/tests/lxcconf2xmldata/lxcconf2xml-miscnetwork.xml +++ b/tests/lxcconf2xmldata/lxcconf2xml-miscnetwork.xml @@ -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> diff --git a/tests/lxcconf2xmldata/lxcconf2xml-nonenetwork.xml b/tests/lxcconf2xmldata/lxcconf2xml-nonenetwork.xml index 0122ab05c7..1a8e51bb56 100644 --- a/tests/lxcconf2xmldata/lxcconf2xml-nonenetwork.xml +++ b/tests/lxcconf2xmldata/lxcconf2xml-nonenetwork.xml @@ -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> diff --git a/tests/lxcconf2xmldata/lxcconf2xml-nonetwork.xml b/tests/lxcconf2xmldata/lxcconf2xml-nonetwork.xml index 04ea280b3c..3c9f4474e5 100644 --- a/tests/lxcconf2xmldata/lxcconf2xml-nonetwork.xml +++ b/tests/lxcconf2xmldata/lxcconf2xml-nonetwork.xml @@ -10,8 +10,7 @@ </os> <features> <privnet/> - <capabilities policy='allow'> - </capabilities> + <capabilities policy='allow'/> </features> <clock offset='utc'/> <on_poweroff>destroy</on_poweroff> diff --git a/tests/lxcconf2xmldata/lxcconf2xml-physnetwork.xml b/tests/lxcconf2xmldata/lxcconf2xml-physnetwork.xml index 4fb3f954e0..fa3cf67fc3 100644 --- a/tests/lxcconf2xmldata/lxcconf2xml-physnetwork.xml +++ b/tests/lxcconf2xmldata/lxcconf2xml-physnetwork.xml @@ -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> diff --git a/tests/lxcconf2xmldata/lxcconf2xml-vlannetwork.xml b/tests/lxcconf2xmldata/lxcconf2xml-vlannetwork.xml index 47ed898b0f..08bea62f7f 100644 --- a/tests/lxcconf2xmldata/lxcconf2xml-vlannetwork.xml +++ b/tests/lxcconf2xmldata/lxcconf2xml-vlannetwork.xml @@ -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> -- 2.20.1 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list