rng: Forbid to validate mismatched <disk> 'device' and 'type' attributes

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
This commit is contained in:
Erik Skultety 2015-04-17 13:14:12 +02:00
parent e4725cdb12
commit cea1b86fa7
3 changed files with 49 additions and 8 deletions

View File

@ -1180,12 +1180,14 @@
</choice> </choice>
</attribute> </attribute>
</optional> </optional>
<interleave>
<ref name="diskSource"/>
<ref name="diskSpecsExtra"/>
</interleave>
</group> </group>
<group> <group>
<attribute name="device"> <attribute name="device">
<choice> <value>lun</value>
<value>lun</value>
</choice>
</attribute> </attribute>
<optional> <optional>
<ref name="rawIO"/> <ref name="rawIO"/>
@ -1198,19 +1200,28 @@
</choice> </choice>
</attribute> </attribute>
</optional> </optional>
<interleave>
<choice>
<ref name="diskSourceNetwork"/>
<ref name="diskSourceBlock"/>
</choice>
<ref name="diskSpecsExtra"/>
</interleave>
</group> </group>
</choice> </choice>
<optional> <optional>
<ref name="snapshot"/> <ref name="snapshot"/>
</optional> </optional>
<interleave>
<ref name="diskSource"/>
<ref name="storageSourceExtra"/>
<ref name="diskBackingChain"/>
</interleave>
</element> </element>
</define> </define>
<define name="diskSpecsExtra">
<interleave>
<ref name="storageSourceExtra"/>
<ref name="diskBackingChain"/>
</interleave>
</define>
<define name="diskBackingChain"> <define name="diskBackingChain">
<choice> <choice>
<ref name="diskBackingStore"/> <ref name="diskBackingStore"/>

View File

@ -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>

View File

@ -817,6 +817,8 @@ mymain(void)
QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_FORMAT); QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_FORMAT);
DO_TEST("disk-drive-no-boot", DO_TEST("disk-drive-no-boot",
QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_BOOTINDEX); 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", NONE);
DO_TEST("disk-usb-device", DO_TEST("disk-usb-device",
QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_DEVICE_USB_STORAGE, QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_DEVICE_USB_STORAGE,