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 | 42 ++++++++++++++--------
.../qemuxml2argv-disk-device-lun-type-invalid.xml | 28 +++++++++++++++
tests/qemuxml2argvtest.c | 2 ++
3 files changed, 58 insertions(+), 14 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-device-lun-type-invalid.xml
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 03fd541..ee32b73 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -1316,37 +1316,43 @@
</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"/>
</optional>
<optional>
- <attribute name="sgio">
- <choice>
- <value>filtered</value>
- <value>unfiltered</value>
- </choice>
- </attribute>
+ <ref name="sgIO"/>
</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"/>
@@ -5315,4 +5321,12 @@
<ref name="virYesNo"/>
</attribute>
</define>
+ <define name="sgIO">
+ <attribute name="sgio">
+ <choice>
+ <value>filtered</value>
+ <value>unfiltered</value>
+ </choice>
+ </attribute>
+ </define>
</grammar>
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
index 0000000..ed3c89e
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-device-lun-type-invalid.xml
@@ -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>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 8d0a4aa..63bf6ff 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -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,
--
1.9.3