]> xenbits.xensource.com Git - libvirt.git/commitdiff
Domain config: write <features/> if some capabilities are set.
authorCédric Bosdonnat <cbosdonnat@suse.com>
Wed, 30 Jul 2014 09:20:59 +0000 (11:20 +0200)
committerCédric Bosdonnat <cbosdonnat@suse.com>
Wed, 30 Jul 2014 12:21:55 +0000 (14:21 +0200)
If all features are set to default (including the capabilities policy),
but some capabilities are toggled, we need to output the <features>
element when formatting the config.

src/conf/domain_conf.c
tests/lxcxml2xmldata/lxc-capabilities.xml [new file with mode: 0644]
tests/lxcxml2xmltest.c

index 2a8cdeb03b901e9470be6eecc287a9cf22304847..421a44af6cd9858841c5d71e93af58e7eee18c7f 100644 (file)
@@ -17860,7 +17860,8 @@ virDomainDefFormatInternal(virDomainDefPtr def,
             break;
     }
 
-    if (i != VIR_DOMAIN_FEATURE_LAST) {
+    if (i != VIR_DOMAIN_FEATURE_LAST ||
+        virDomainDefHasCapabilitiesFeatures(def)) {
         virBufferAddLit(buf, "<features>\n");
         virBufferAdjustIndent(buf, 2);
 
diff --git a/tests/lxcxml2xmldata/lxc-capabilities.xml b/tests/lxcxml2xmldata/lxc-capabilities.xml
new file mode 100644 (file)
index 0000000..04d64e3
--- /dev/null
@@ -0,0 +1,34 @@
+<domain type='lxc'>
+  <name>jessie</name>
+  <uuid>e21987a5-e98e-9c99-0e35-803e4d9ad1fe</uuid>
+  <memory unit='KiB'>1048576</memory>
+  <currentMemory unit='KiB'>1048576</currentMemory>
+  <vcpu placement='static'>1</vcpu>
+  <resource>
+    <partition>/machine</partition>
+  </resource>
+  <os>
+    <type arch='x86_64'>exe</type>
+    <init>/sbin/init</init>
+  </os>
+  <features>
+    <capabilities policy='default'>
+      <mknod state='on'/>
+    </capabilities>
+  </features>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>restart</on_crash>
+  <devices>
+    <emulator>/usr/libexec/libvirt_lxc</emulator>
+    <filesystem type='mount' accessmode='passthrough'>
+      <source dir='/mach/jessie'/>
+      <target dir='/'/>
+    </filesystem>
+    <console type='pty'>
+      <target type='lxc' port='0'/>
+    </console>
+  </devices>
+  <seclabel type='none'/>
+</domain>
index 81449896608b6c9e399a5a8ccfeb03072da7fbcb..6dce070db2db605a6ca2e60d73ae3163f8e99374 100644 (file)
@@ -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);