[libvirt] [PATCH] update libvirt.rng

John Levon levon at movementarian.org
Sat Jul 5 15:43:04 UTC 2008


The below patch makes a significant update to libvirt.rng to bring it
into line with reality. This is an incremental improvement rather than a
full fix. In particular, various parts are still under-specified (e.g.
qemu char devices).

This version lets almost all of the XML files in tests/ validate. I'd
appreciate help getting the last few to validate - any volunteers?

One possible idea might be virsh validate: split out both the schema
validation and the additional checks in libvirt into one consolidated
place. This would help people check their definitions.

The question also arises on how to help avoid the schema getting so
badly out of date again. Some suggestions:

- add a validation phase to the test suite, and mark failures
- require any changes to the implicit schema to add a test suite entry
- and require such changes to update the schema too

Comments?

thanks,
john

Index: docs/libvirt.rng
===================================================================
RCS file: /data/cvs/libvirt/docs/libvirt.rng,v
retrieving revision 1.7
diff -u -r1.7 libvirt.rng
--- docs/libvirt.rng	14 Mar 2008 11:08:03 -0000	1.7
+++ docs/libvirt.rng	4 Jul 2008 22:22:52 -0000
@@ -50,6 +50,7 @@
 	    </optional>
 	  </group>
 	</choice>
+        <ref name='clock'/>
         <ref name='resources'/>
         <ref name='features'/>
         <ref name='termination'/>
@@ -82,8 +83,13 @@
 	    </choice>
 	    <value>hvm</value>
 	  </element>
+          <optional>
+            <ref name='bootdev'/>
+          </optional>
 	</element>
+        <ref name='clock'/>
         <ref name='resources'/>
+        <ref name='termination'/>
         <ref name='devices'/>
       </interleave>
     </group>
@@ -157,8 +163,14 @@
       <interleave>
         <element name='os'>
 	  <element name='type'>
-	    <value>hvm</value>
+            <choice>
+	      <value>hvm</value>
+	      <value>xen</value>
+            </choice>
 	  </element>
+          <optional>
+            <ref name='bootdev' />
+          </optional>
 	</element>
         <ref name='resources'/>
         <ref name='devices-with-emulator'/>
@@ -208,12 +220,29 @@
       </optional>
       <optional>
         <element name='vcpu'>
+          <optional>
+            <attribute name='cpuset' />
+          </optional>
           <ref name='countCPU'/>
         </element>
       </optional>
     </interleave>
   </define>
 
+  <define name='clock'>
+    <optional>
+      <element name='clock'>
+        <attribute name='offset'>
+          <choice>
+            <value>localtime</value>
+            <value>utc</value>
+          </choice>
+        </attribute>
+        <empty/>
+      </element>
+    </optional>
+  </define>
+
   <!--
       A bootloader may be used to extract the OS information instead of
       defining the OS parameter in the instance. It points just to the
@@ -238,14 +267,7 @@
     </element>
   </define>
 
-  <!--
-      A paravirtualized linux domain, this requires at least a kernel path
-      and the root device, the initrd and command line arguments are optional
-    -->
-  <define name='linux'>
-    <element name='type'>
-      <value>linux</value>
-    </element>
+  <define name='kernboot'>
     <interleave>
       <element name='kernel'>
         <ref name='absFilePath'/>
@@ -269,8 +291,39 @@
   </define>
 
   <!--
-      A fully virtualized domain, this requires the path to the loader and
-      an optional boot device (hd, fd or cdrom).
+      A paravirtualized linux domain, this requires at least a kernel path
+      and the root device, the initrd and command line arguments are optional
+    -->
+  <define name='linux'>
+    <element name='type'>
+      <value>linux</value>
+    </element>
+    <ref name='kernboot'/>
+  </define>
+
+  <define name='bootdev'>
+    <element name='boot'>
+      <attribute name='dev'>
+        <choice>
+          <value>hd</value>
+          <value>fd</value>
+          <value>cdrom</value>
+          <value>network</value>
+        </choice>
+      </attribute>
+      <empty/>
+    </element>
+  </define>
+
+  <define name='hvmboot'>
+    <choice>
+      <ref name='bootdev'/>
+      <ref name='kernboot'/>
+    </choice>
+  </define>
+
+  <!--
+      A fully virtualized domain and how to boot it.
     -->
   <define name='hvm'>
     <element name='type'>
@@ -281,20 +334,28 @@
         <ref name='absFilePath'/>
       </element>
       <optional>
-        <element name='boot'>
-	  <attribute name='dev'>
-	    <choice>
-	      <value>hd</value>
-	      <value>fd</value>
-	      <value>cdrom</value>
-	    </choice>
-	  </attribute>
-	  <empty/>
-	</element>
+        <ref name='hvmboot' />
       </optional>
     </interleave>
   </define>
 
+  <define name='diskspec'>
+    <optional>
+      <ref name='driver'/>
+    </optional>
+    <ref name='target'/>
+    <optional>
+      <element name='readonly'>
+        <empty/>
+      </element>
+    </optional>
+    <optional>
+      <element name='shareable'>
+        <empty/>
+      </element>
+    </optional>
+  </define>
+
   <!--
       A disk description can be either of type file or block
       The name of the attribute on the source element depends on the type
@@ -315,43 +376,32 @@
         <group>
           <attribute name='type'>
 	    <value>file</value>
-	  </attribute>
+          </attribute>
 	  <interleave>
-	    <element name='source'>
-	      <attribute name='file'>
-	        <ref name='absFilePath'/>
-	      </attribute>
-	      <empty/>
-	    </element>
-	    <optional>
-	      <ref name='driver'/>
-	    </optional>
-	    <ref name='target'/>
-	    <optional>
-	      <ref name='readonly'/>
-	    </optional>
-	  </interleave>
+  	    <element name='source'>
+  	      <attribute name='file'>
+  	        <ref name='absFilePath'/>
+  	      </attribute>
+  	      <empty/>
+  	    </element>
+            <ref name='diskspec'/>
+  	  </interleave>
         </group>
         <group>
           <attribute name='type'>
-	    <value>block</value>
-	  </attribute>
-	  <interleave>
-	    <element name='source'>
-	      <attribute name='dev'>
-	        <ref name='deviceName'/>
-	      </attribute>
-	      <empty/>
-	    </element>
-	    <optional>
-	      <ref name='driver'/>
-	    </optional>
-	    <ref name='target'/>
-	    <optional>
-	      <ref name='readonly'/>
-	    </optional>
-	  </interleave>
+  	    <value>block</value>
+  	  </attribute>
+  	  <interleave>
+  	    <element name='source'>
+  	      <attribute name='dev'>
+  	        <ref name='deviceName'/>
+  	      </attribute>
+  	      <empty/>
+  	    </element>
+            <ref name='diskspec'/>
+  	  </interleave>
         </group>
+        <ref name='diskspec'/>
       </choice>
     </element>
   </define>
@@ -361,12 +411,16 @@
       <attribute name='dev'>
 	<ref name='deviceName'/>
       </attribute>
-    </element>
-  </define>
-
-  <define name='readonly'>
-    <element name='readonly'>
-      <empty/>
+      <optional>
+         <attribute name='bus'>
+           <choice>
+             <value>ide</value>
+             <value>virtio</value>
+             <value>fdc</value>
+             <value>xen</value>
+           </choice>
+         </attribute>
+      </optional>
     </element>
   </define>
 
@@ -392,7 +446,7 @@
       An interface description can either be of type bridge in which case
       it will use a bridging source, or of type ethernet which uses a device
       source and a device target instead. They both share a set of interface
-      options.
+      options. FIXME
     -->
   <define name='interface'>
     <element name='interface'>
@@ -402,12 +456,14 @@
             <value>bridge</value>
           </attribute>
 	  <interleave>
-	    <element name='source'>
-	      <attribute name='bridge'>
-		<ref name='deviceName'/>
-	      </attribute>
-	      <empty/>
-	    </element>
+            <optional>
+	      <element name='source'>
+	        <attribute name='bridge'>
+	  	  <ref name='deviceName'/>
+	        </attribute>
+	        <empty/>
+	      </element>
+            </optional>
 	    <ref name='interface-options'/>
 	  </interleave>
 	</group>
@@ -416,8 +472,24 @@
             <value>ethernet</value>
           </attribute>
 	  <interleave>
+            <optional>
+	      <element name='source'>
+  	        <attribute name='dev'>
+	  	  <ref name='deviceName'/>
+	        </attribute>
+	        <empty/>
+	      </element>
+            </optional>
+	    <ref name='interface-options'/>
+	  </interleave>
+	</group>
+        <group>
+          <attribute name='type'>
+            <value>network</value>
+          </attribute>
+	  <interleave>
 	    <element name='source'>
-	      <attribute name='dev'>
+	      <attribute name='network'>
 		<ref name='deviceName'/>
 	      </attribute>
 	      <empty/>
@@ -478,11 +550,17 @@
 	    <empty/>
 	  </element>
 	</optional>
+	<optional>
+	  <element name='model'>
+	    <attribute name='type' />
+	    <empty/>
+	  </element>
+	</optional>
       </interleave>
   </define>
 
   <!--
-      An emulator descritpion is just a path to the binary used for the task
+      An emulator description is just a path to the binary used for the task
     -->
   <define name='emulator'>
     <element name='emulator'>
@@ -493,7 +571,8 @@
   <!--
       A graphic description, currently in Xen only 2 types are supported:
         - sdl without arguments
-	- vnc with a required port and optional listen IP address and password
+	- vnc with a required port and optional listen IP address, password
+          and keymap
     -->
   <define name='graphic'>
     <element name='graphics'>
@@ -518,6 +597,11 @@
 	      <text/>
 	    </attribute>
 	  </optional>
+          <optional>
+            <attribute name='keymap'>
+              <text/>
+            </attribute>
+          </optional>
 	</group>
       </choice>
     </element>
@@ -565,24 +649,134 @@
   </define>
 
   <!--
+      Specific setup for a qemu emulated character device.  Note: this
+      definition doesn't fully specify the constraints on this node.
+    -->
+  <define name='qemucdev'>
+    <attribute name='type'>
+      <choice>
+        <value>dev</value>
+        <value>file</value>
+        <value>pipe</value>
+        <value>unix</value>
+        <value>tcp</value>
+        <value>udp</value>
+        <value>null</value>
+        <value>stdio</value>
+        <value>vc</value>
+        <value>pty</value>
+      </choice>
+    </attribute>
+    
+    <interleave>
+      <optional>
+        <oneOrMore>
+          <element name='source'>
+            <optional>
+              <attribute name='mode' />
+            </optional>
+            <optional>
+              <attribute name='path' />
+            </optional>
+            <optional>
+              <attribute name='host' />
+            </optional>
+            <optional>
+              <attribute name='service' />
+            </optional>
+            <optional>
+              <attribute name='wiremode' />
+            </optional>
+          </element>
+        </oneOrMore>
+      </optional>
+      <optional>
+        <element name='protocol'>
+          <optional>
+            <attribute name='type' />
+          </optional>
+        </element>
+      </optional>
+      <optional>
+        <element name='target'>
+          <optional>
+            <attribute name='port' />
+          </optional>
+        </element>
+      </optional>
+    </interleave>
+  </define>
+
+  <!--
       The description for a console
       just a tty device
     -->
   <define name='console'>
     <element name='console'>
-      <attribute name='tty'>
-        <ref name='devicePath'/>
-      </attribute>
-      <empty/>
+      <choice>
+        <group>
+          <optional>
+            <attribute name='tty'>
+              <ref name='devicePath'/>
+            </attribute>
+          </optional>
+          <empty/>
+        </group>
+        <ref name='qemucdev' />
+      </choice>
+    </element>
+  </define>
+
+  <define name='sound'>
+    <oneOrMore>
+      <element name='sound'>
+        <attribute name='model'>
+          <choice>
+            <value>sb16</value>
+            <value>es1370</value>
+            <value>pcspk</value>
+          </choice>
+        </attribute>
+      </element>
+    </oneOrMore>
+  </define>
+
+  <define name='parallel'>
+    <element name='parallel'>
+      <ref name='qemucdev' />
+    </element>
+  </define>
+
+  <define name='serial'>
+    <element name='serial'>
+      <ref name='qemucdev' />
     </element>
   </define>
 
+  <define name='input'>
+    <oneOrMore>
+      <element name='input'>
+        <attribute name='type'>
+          <choice>
+            <value>tablet</value>
+            <value>mouse</value>
+          </choice>
+        </attribute>
+        <optional>
+          <attribute name='bus'>
+            <choice>
+              <value>ps2</value>
+              <value>usb</value>
+              <value>xen</value>
+            </choice>
+          </attribute>
+        </optional>
+      </element>
+    </oneOrMore>
+  </define>
+
   <!--
-      The devices bloc allows:
-      - an optional emulator path, restricted to hvm configs but hard to check
-      - an optional graphic description , restricted to hvm configs too
-      - zero or more disk devices
-      - zero or more interface devices
+      Devices attached to a domain.
     -->
   <define name='devices'>
     <element name='devices'>
@@ -602,6 +796,18 @@
 	<optional>
 	  <ref name='console'/>
 	</optional>
+        <optional>
+          <ref name='sound'/>
+        </optional>
+        <optional>
+          <ref name='parallel'/>
+        </optional>
+        <optional>
+          <ref name='serial'/>
+        </optional>
+        <optional>
+          <ref name='input'/>
+        </optional>
       </interleave>
     </element>
   </define>
@@ -625,6 +831,18 @@
 	<optional>
 	  <ref name='console'/>
 	</optional>
+        <optional>
+          <ref name='sound'/>
+        </optional>
+        <optional>
+          <ref name='parallel'/>
+        </optional>
+        <optional>
+          <ref name='serial'/>
+        </optional>
+        <optional>
+          <ref name='input'/>
+        </optional>
       </interleave>
     </element>
   </define>




More information about the libvir-list mailing list