]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
rng: Forbid to validate mismatched <disk> 'device' and 'type' attributes
authorErik Skultety <eskultet@redhat.com>
Fri, 17 Apr 2015 11:14:12 +0000 (13:14 +0200)
committerErik Skultety <eskultet@redhat.com>
Mon, 20 Apr 2015 08:04:06 +0000 (10:04 +0200)
According to docs, using 'lun' as a value for device attribute is only valid
with disk types 'block' and 'network'. However current RNG schema also allows
a combination type='file' device='lun' which results in a successfull
xml validation, but fails at qemuBuildCommandLine.
Besides fixing the RNG schema, this patch also adds a qemuxml2argvtest
for this case.

https://bugzilla.redhat.com/show_bug.cgi?id=1210669

docs/schemas/domaincommon.rng
tests/qemuxml2argvdata/qemuxml2argv-disk-device-lun-type-invalid.xml [new file with mode: 0644]
tests/qemuxml2argvtest.c

index e35323f3ca4664fe72091791e97145904d0abf68..9cc5e769aa8716dab8f54a98701b196d58059dd6 100644 (file)
               </choice>
             </attribute>
           </optional>
+          <interleave>
+            <ref name="diskSource"/>
+            <ref name="diskSpecsExtra"/>
+          </interleave>
         </group>
         <group>
           <attribute name="device">
-            <choice>
-              <value>lun</value>
-            </choice>
+            <value>lun</value>
           </attribute>
           <optional>
             <ref name="rawIO"/>
               </choice>
             </attribute>
           </optional>
+          <interleave>
+            <choice>
+              <ref name="diskSourceNetwork"/>
+              <ref name="diskSourceBlock"/>
+            </choice>
+            <ref name="diskSpecsExtra"/>
+          </interleave>
         </group>
       </choice>
       <optional>
         <ref name="snapshot"/>
       </optional>
-      <interleave>
-        <ref name="diskSource"/>
-        <ref name="storageSourceExtra"/>
-        <ref name="diskBackingChain"/>
-      </interleave>
     </element>
   </define>
 
+  <define name="diskSpecsExtra">
+    <interleave>
+      <ref name="storageSourceExtra"/>
+      <ref name="diskBackingChain"/>
+    </interleave>
+  </define>
+
   <define name="diskBackingChain">
     <choice>
       <ref name="diskBackingStore"/>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-device-lun-type-invalid.xml b/tests/qemuxml2argvdata/qemuxml2argv-disk-device-lun-type-invalid.xml
new file mode 100644 (file)
index 0000000..ed3c89e
--- /dev/null
@@ -0,0 +1,28 @@
+<domain type='qemu'>
+  <name>QEMUGuest1</name>
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+  <memory unit='KiB'>219100</memory>
+  <currentMemory unit='KiB'>219100</currentMemory>
+  <vcpu placement='static'>1</vcpu>
+  <os>
+    <type arch='i686' machine='pc'>hvm</type>
+    <boot dev='hd'/>
+  </os>
+  <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='lun' rawio='yes'>
+      <driver name='qemu' type='qcow2'/>
+      <source file='/dev/HostVG/QEMUGuest1'/>
+      <target dev='vda' bus='virtio'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
+    </disk>
+    <controller type='usb' index='0'/>
+    <controller type='ide' index='0'/>
+    <controller type='pci' index='0' model='pci-root'/>
+    <memballoon model='virtio'/>
+  </devices>
+</domain>
index 8d0a4aa319347e62649b46d5b6a6a0263fd996f7..63bf6ff7100fc972211fc8e3d0225541786837fc 100644 (file)
@@ -817,6 +817,8 @@ mymain(void)
                     QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_FORMAT);
     DO_TEST("disk-drive-no-boot",
             QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_BOOTINDEX);
+    DO_TEST_FAILURE("disk-device-lun-type-invalid",
+                    QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_VIRTIO_SCSI);
     DO_TEST("disk-usb",  NONE);
     DO_TEST("disk-usb-device",
             QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_DEVICE_USB_STORAGE,