[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH] schema: fix idmap validation



When idmap was added to LXC, we forgot to cover it in the testsuite.
The schema was missing an <element> layer, and as a result,
virt-xml-validate was failing on valid dumpxml output.

Reported by Eduard - Gabriel Munteanu on IRC.

* docs/schemas/domaincommon.rng (idmap): Include <idmap> element,
and support interleaves.
* tests/lxcxml2xmldata/lxc-idmap.xml: New file.
* tests/lxcxml2xmltest.c (mymain): Test it.

Signed-off-by: Eric Blake <eblake redhat com>
---

Eduard, please confirm I spelled your name correctly.

 docs/schemas/domaincommon.rng      | 58 +++++++++++++++++++++-----------------
 tests/lxcxml2xmldata/lxc-idmap.xml | 38 +++++++++++++++++++++++++
 tests/lxcxml2xmltest.c             |  1 +
 3 files changed, 71 insertions(+), 26 deletions(-)
 create mode 100644 tests/lxcxml2xmldata/lxc-idmap.xml

diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 86a60c9..a69f6b6 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -506,32 +506,38 @@
     </interleave>
   </define>
   <define name="idmap">
-    <zeroOrMore>
-      <element name="uid">
-        <attribute name="start">
-          <ref name="unsignedInt"/>
-        </attribute>
-        <attribute name="target">
-          <ref name="unsignedInt"/>
-        </attribute>
-        <attribute name="count">
-          <ref name="unsignedInt"/>
-        </attribute>
-      </element>
-    </zeroOrMore>
-    <zeroOrMore>
-      <element name="gid">
-        <attribute name="start">
-          <ref name="unsignedInt"/>
-        </attribute>
-        <attribute name="target">
-          <ref name="unsignedInt"/>
-        </attribute>
-        <attribute name="count">
-          <ref name="unsignedInt"/>
-        </attribute>
-      </element>
-    </zeroOrMore>
+    <element name="idmap">
+      <interleave>
+        <zeroOrMore>
+          <element name="uid">
+            <attribute name="start">
+              <ref name="unsignedInt"/>
+            </attribute>
+            <attribute name="target">
+              <ref name="unsignedInt"/>
+            </attribute>
+            <attribute name="count">
+              <ref name="unsignedInt"/>
+            </attribute>
+            <empty/>
+          </element>
+        </zeroOrMore>
+        <zeroOrMore>
+          <element name="gid">
+            <attribute name="start">
+              <ref name="unsignedInt"/>
+            </attribute>
+            <attribute name="target">
+              <ref name="unsignedInt"/>
+            </attribute>
+            <attribute name="count">
+              <ref name="unsignedInt"/>
+            </attribute>
+          <empty/>
+          </element>
+        </zeroOrMore>
+      </interleave>
+    </element>
   </define>
   <!--
       Resources usage defines the amount of memory (maximum and possibly
diff --git a/tests/lxcxml2xmldata/lxc-idmap.xml b/tests/lxcxml2xmldata/lxc-idmap.xml
new file mode 100644
index 0000000..3cced21
--- /dev/null
+++ b/tests/lxcxml2xmldata/lxc-idmap.xml
@@ -0,0 +1,38 @@
+<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>
+  <idmap>
+    <uid start='0' target='100000' count='100000'/>
+    <gid start='0' target='100000' count='100000'/>
+  </idmap>
+  <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>
+    <interface type='bridge'>
+      <mac address='00:16:3e:0f:ef:8a'/>
+      <source bridge='bri0'/>
+      <target dev='veth0'/>
+    </interface>
+    <console type='pty'>
+      <target type='lxc' port='0'/>
+    </console>
+  </devices>
+  <seclabel type='none'/>
+</domain>
diff --git a/tests/lxcxml2xmltest.c b/tests/lxcxml2xmltest.c
index a028e39..c6bb706 100644
--- a/tests/lxcxml2xmltest.c
+++ b/tests/lxcxml2xmltest.c
@@ -138,6 +138,7 @@ mymain(void)
     DO_TEST("disk-formats");
     DO_TEST_DIFFERENT("filesystem-ram");
     DO_TEST("filesystem-root");
+    DO_TEST("idmap");

     virObjectUnref(caps);
     virObjectUnref(xmlopt);
-- 
1.8.4.2


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]