[libvirt] [PATCH] Add the device alias element to the domain.rng schema

Matthias Bolte matthias.bolte at googlemail.com
Mon Oct 4 22:42:27 UTC 2010


Every device element that can contain an address element
can also contain an alias element, but the domain.rng didn't
reflect this. Therefore, running virt-xml-validate on the
virsh dumpxml output of an active domain failed. It doesn't
fail for inactive domains, because in that case dumpxml
doesn't include the alias elements.

Add the device alias element to the domain.rng schema and
add a new test case to cover this.

Indirectly reported by Jon Stanley.
---
 docs/schemas/domain.rng                   |   42 +++++++++++++++
 tests/domainschemadata/device-aliases.xml |   79 +++++++++++++++++++++++++++++
 2 files changed, 121 insertions(+), 0 deletions(-)
 create mode 100644 tests/domainschemadata/device-aliases.xml

diff --git a/docs/schemas/domain.rng b/docs/schemas/domain.rng
index 2e0457b..8fdf864 100644
--- a/docs/schemas/domain.rng
+++ b/docs/schemas/domain.rng
@@ -503,6 +503,9 @@
       <ref name="encryption"/>
     </optional>
     <optional>
+      <ref name="alias"/>
+    </optional>
+    <optional>
       <ref name="address"/>
     </optional>
   </define>
@@ -697,6 +700,9 @@
         </attribute>
       </optional>
       <optional>
+        <ref name="alias"/>
+      </optional>
+      <optional>
         <ref name="address"/>
       </optional>
     </element>
@@ -762,6 +768,9 @@
         </group>
       </choice>
       <optional>
+        <ref name="alias"/>
+      </optional>
+      <optional>
         <ref name="address"/>
       </optional>
     </element>
@@ -924,6 +933,9 @@
         </element>
       </optional>
       <optional>
+        <ref name="alias"/>
+      </optional>
+      <optional>
         <ref name="address"/>
       </optional>
       <optional>
@@ -1157,6 +1169,9 @@
         </element>
       </optional>
       <optional>
+        <ref name="alias"/>
+      </optional>
+      <optional>
         <ref name="address"/>
       </optional>
     </element>
@@ -1240,6 +1255,9 @@
         <ref name="qemucdevTgtDef"/>
       </optional>
       <optional>
+        <ref name="alias"/>
+      </optional>
+      <optional>
         <ref name="address"/>
       </optional>
     </interleave>
@@ -1345,6 +1363,9 @@
         </choice>
       </attribute>
       <optional>
+        <ref name="alias"/>
+      </optional>
+      <optional>
         <ref name="address"/>
       </optional>
     </element>
@@ -1369,6 +1390,9 @@
         </attribute>
       </optional>
       <optional>
+        <ref name="alias"/>
+      </optional>
+      <optional>
         <ref name="address"/>
       </optional>
     </element>
@@ -1383,6 +1407,9 @@
         </choice>
       </attribute>
       <optional>
+        <ref name="alias"/>
+      </optional>
+      <optional>
         <ref name="address"/>
       </optional>
     </element>
@@ -1426,6 +1453,9 @@
           <ref name="virtioTarget"/>
         </choice>
         <optional>
+          <ref name="alias"/>
+        </optional>
+        <optional>
           <ref name="address"/>
         </optional>
       </interleave>
@@ -1449,6 +1479,9 @@
         </attribute>
       </optional>
       <optional>
+        <ref name="alias"/>
+      </optional>
+      <optional>
         <ref name="address"/>
       </optional>
     </element>
@@ -1492,6 +1525,9 @@
         </element>
       </group>
       <optional>
+        <ref name="alias"/>
+      </optional>
+      <optional>
         <ref name="address"/>
       </optional>
     </element>
@@ -1728,6 +1764,12 @@
     </element>
   </define>
 
+  <define name="alias">
+    <element name="alias">
+      <attribute name="name"/>
+    </element>
+  </define>
+
   <define name="filterref-node-attributes">
     <attribute name="filter">
       <data type="NCName"/>
diff --git a/tests/domainschemadata/device-aliases.xml b/tests/domainschemadata/device-aliases.xml
new file mode 100644
index 0000000..6b0299e
--- /dev/null
+++ b/tests/domainschemadata/device-aliases.xml
@@ -0,0 +1,79 @@
+<domain type='qemu'>
+  <name>QEMUGuest1</name>
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+  <memory>219200</memory>
+  <currentMemory>219200</currentMemory>
+  <vcpu>1</vcpu>
+  <os>
+    <type arch='x86_64' machine='pc-0.12'>hvm</type>
+    <boot dev='cdrom'/>
+  </os>
+  <features>
+    <acpi/>
+    <apic/>
+    <pae/>
+  </features>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <emulator>/usr/bin/qemu</emulator>
+    <disk type='file' device='disk'>
+      <driver name='qemu' type='raw'/>
+      <source file='/var/lib/libvirt/images/QEMUGuest1.img'/>
+      <target dev='hda' bus='ide'/>
+      <alias name='ide0-0-0'/>
+      <address type='drive' controller='0' bus='0' unit='0'/>
+    </disk>
+    <disk type='file' device='cdrom'>
+      <driver name='qemu' type='raw'/>
+      <source file='/var/lib/libvirt/images/foobar.iso'/>
+      <target dev='hdc' bus='ide'/>
+      <readonly/>
+      <alias name='ide0-1-0'/>
+      <address type='drive' controller='0' bus='1' unit='0'/>
+    </disk>
+    <filesystem type='file'>
+      <source file='/var/lib/libvirt/images/foobar.iso'/>
+      <target dir='/var/lib/libvirt/images'/>
+      <alias name='filesystem0'/>
+    </filesystem>
+    <controller type='ide' index='0'>
+      <alias name='ide0'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
+    </controller>
+    <interface type='user'>
+      <mac address='52:54:00:b5:36:36'/>
+      <alias name='net0'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
+    </interface>
+    <serial type='pty'>
+      <source path='/dev/pts/15'/>
+      <target port='0'/>
+      <alias name='serial0'/>
+    </serial>
+    <console type='pty' tty='/dev/pts/15'>
+      <source path='/dev/pts/15'/>
+      <target type='serial' port='0'/>
+      <alias name='serial0'/>
+    </console>
+    <input type='mouse' bus='ps2'>
+      <alias name='input0'/>
+    </input>
+    <graphics type='vnc' port='5900' autoport='no' listen='0.0.0.0'/>
+    <video>
+      <model type='cirrus' vram='9216' heads='1'/>
+      <alias name='video0'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
+    </video>
+    <watchdog model='ib700' action='poweroff'>
+      <alias name='watchdog0'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x10' function='0x0'/>
+    </watchdog>
+    <memballoon model='virtio'>
+      <alias name='balloon0'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
+    </memballoon>
+  </devices>
+</domain>
-- 
1.7.0.4




More information about the libvir-list mailing list