[libvirt] [PATCH 04/15] schema: allow pci address attributes to be in decimal

Laine Stump laine at laine.org
Thu Mar 24 19:25:39 UTC 2016


This is especially useful for "bus", since the bus of a device's pci
address is matched to the "index" of a controller to determine which
bus it will be connected to, and "index" is always specified in
decimal - being able to specify both in decimal at least makes it
easier to assure a device is being assigned to the correct bus when it
is added. For the other attributes, it is just a convenience.

(MB: the parser already allows for any of these attributes to be given
in decimal, and there are even examples floating around on the
internet that give them in decimal rather than hex (written in the
days before virsh did schema validation on all XML). This only updates
the schema to match the parser.)
---
 docs/schemas/basictypes.rng | 32 ++++++++++++++++++++------------
 1 file changed, 20 insertions(+), 12 deletions(-)

diff --git a/docs/schemas/basictypes.rng b/docs/schemas/basictypes.rng
index 64babaf..e2936d8 100644
--- a/docs/schemas/basictypes.rng
+++ b/docs/schemas/basictypes.rng
@@ -282,24 +282,32 @@
   </define>
 
   <define name="pciDomain">
-    <data type="string">
-      <param name="pattern">(0x)?[0-9a-fA-F]{1,4}</param>
-    </data>
+    <ref name="uint16"/>
   </define>
   <define name="pciBus">
-    <data type="string">
-      <param name="pattern">(0x)?[0-9a-fA-F]{1,2}</param>
-    </data>
+    <ref name="uint8"/>
   </define>
   <define name="pciSlot">
-    <data type="string">
-      <param name="pattern">(0x)?[0-1]?[0-9a-fA-F]</param>
-    </data>
+    <choice>
+      <data type="string">
+        <param name="pattern">(0x)?[0-1]?[0-9a-fA-F]</param>
+      </data>
+      <data type="int">
+        <param name="minInclusive">0</param>
+        <param name="maxInclusive">31</param>
+      </data>
+    </choice>
   </define>
   <define name="pciFunc">
-    <data type="string">
-      <param name="pattern">(0x)?[0-7]</param>
-    </data>
+    <choice>
+      <data type="string">
+        <param name="pattern">(0x)?[0-7]</param>
+      </data>
+      <data type="int">
+        <param name="minInclusive">0</param>
+        <param name="maxInclusive">7</param>
+      </data>
+    </choice>
   </define>
 
   <define name='wwn'>
-- 
2.5.5




More information about the libvir-list mailing list