From 251d75a86324b8de09a88c9289229ca88cf58892 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Bosdonnat?= Date: Wed, 30 Jul 2014 11:20:59 +0200 Subject: [PATCH] Domain config: write if some capabilities are set. If all features are set to default (including the capabilities policy), but some capabilities are toggled, we need to output the element when formatting the config. --- src/conf/domain_conf.c | 3 +- tests/lxcxml2xmldata/lxc-capabilities.xml | 34 +++++++++++++++++++++++ tests/lxcxml2xmltest.c | 1 + 3 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 tests/lxcxml2xmldata/lxc-capabilities.xml diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 2a8cdeb03b..421a44af6c 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -17860,7 +17860,8 @@ virDomainDefFormatInternal(virDomainDefPtr def, break; } - if (i != VIR_DOMAIN_FEATURE_LAST) { + if (i != VIR_DOMAIN_FEATURE_LAST || + virDomainDefHasCapabilitiesFeatures(def)) { virBufferAddLit(buf, "\n"); virBufferAdjustIndent(buf, 2); diff --git a/tests/lxcxml2xmldata/lxc-capabilities.xml b/tests/lxcxml2xmldata/lxc-capabilities.xml new file mode 100644 index 0000000000..04d64e3e41 --- /dev/null +++ b/tests/lxcxml2xmldata/lxc-capabilities.xml @@ -0,0 +1,34 @@ + + jessie + e21987a5-e98e-9c99-0e35-803e4d9ad1fe + 1048576 + 1048576 + 1 + + /machine + + + exe + /sbin/init + + + + + + + + destroy + restart + restart + + /usr/libexec/libvirt_lxc + + + + + + + + + + diff --git a/tests/lxcxml2xmltest.c b/tests/lxcxml2xmltest.c index 8144989660..6dce070db2 100644 --- a/tests/lxcxml2xmltest.c +++ b/tests/lxcxml2xmltest.c @@ -144,6 +144,7 @@ mymain(void) DO_TEST_DIFFERENT("filesystem-ram"); DO_TEST("filesystem-root"); DO_TEST("idmap"); + DO_TEST("capabilities"); virObjectUnref(caps); virObjectUnref(xmlopt); -- GitLab