The Relax-NG schema for domains regarding <hostdev> doesn't match what's
implemented in src/conf/domain_conf.c#virDomainHostdevDefFormat(): The
implementation only requires @type, but the schema currently either
required none or all three attributes (@mode, @type, and @managed) to be
defined together, because they are declared in the same
<optional)-section. (@managed is currently even undocumented on
<http://libvirt.org/formatdomain.html#elementsUSB>).

Thus the following minimal <hostdev>-example fails to validate:
<domain type='test'>
        <name>N</name>
        <memory>4096</memory>
        <bootloader>/bin/false</bootloader>
        <os>
                <type arch='x86_64' machine='xenpv'>linux</type>
        </os>
        <devices>
                <hostdev type='pci'>
                        <source>
                                <address bus='0x06' slot='0x00' function='0x0'/>
                        </source>
                </hostdev>
        </devices>
</domain>

The schema is changed to match the current implementation:
1. @mode is optional (which defaults to 'subsystem')
2. @type is required
3. @managed is optional (which defaults to 'no')

Signed-off-by: Philipp Hahn <[email protected]>
---
 docs/schemas/domain.rng |   14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/docs/schemas/domain.rng b/docs/schemas/domain.rng
index 8b215f3..21c4380 100644
--- a/docs/schemas/domain.rng
+++ b/docs/schemas/domain.rng
@@ -1731,12 +1731,14 @@
             <value>capabilities</value>
           </choice>
         </attribute>
-        <attribute name="type">
-          <choice>
-            <value>usb</value>
-            <value>pci</value>
-          </choice>
-        </attribute>
+      </optional>
+      <attribute name="type">
+        <choice>
+          <value>usb</value>
+          <value>pci</value>
+        </choice>
+      </attribute>
+      <optional>
         <attribute name="managed">
           <choice>
             <value>yes</value>
-- 
1.7.1

--
libvir-list mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/libvir-list

Reply via email to