mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-02 01:45:17 +00:00
conf: better <disk> interleaving in schema
In general, we try to make virt-xml-validate tolerant of input elements in any order when possible. However, as written, the RNG grammar did not permit <source> unless there was an explicit type= attribute (even though the C code manages just fine by defaulting to type='file'). After making the attribute optional on the 'file' branch, I noticed that the use of diskspec was now redundant with the branch when no <source> was supplied. View this patch with 'git diff -b' for a better picture of the schema change. * docs/schemas/domaincommon.rng (disk): Hoist 'diskspec' out of choice, make type='file' default, and still preserve interleave. * tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-source-pool.xml: * tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-drive-discard.xml: New files. * tests/qemuxml2argvdata/qemuxml2argv-disk-source-pool.xml: * tests/qemuxml2argvdata/qemuxml2argv-disk-drive-discard.xml: Reorder XML. * tests/qemuxml2xmltest.c (mymain): Cover new files. Signed-off-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
parent
6077be466e
commit
a9efe2d70c
@ -1196,119 +1196,118 @@
|
|||||||
<optional>
|
<optional>
|
||||||
<ref name="snapshot"/>
|
<ref name="snapshot"/>
|
||||||
</optional>
|
</optional>
|
||||||
<choice>
|
<interleave>
|
||||||
<group>
|
<choice>
|
||||||
<attribute name="type">
|
<group>
|
||||||
<value>file</value>
|
|
||||||
</attribute>
|
|
||||||
<interleave>
|
|
||||||
<optional>
|
<optional>
|
||||||
<element name="source">
|
<attribute name="type">
|
||||||
<optional>
|
<value>file</value>
|
||||||
<attribute name="file">
|
</attribute>
|
||||||
|
</optional>
|
||||||
|
<interleave>
|
||||||
|
<optional>
|
||||||
|
<element name="source">
|
||||||
|
<optional>
|
||||||
|
<attribute name="file">
|
||||||
|
<ref name="absFilePath"/>
|
||||||
|
</attribute>
|
||||||
|
</optional>
|
||||||
|
<optional>
|
||||||
|
<ref name="startupPolicy"/>
|
||||||
|
</optional>
|
||||||
|
<optional>
|
||||||
|
<ref name='devSeclabel'/>
|
||||||
|
</optional>
|
||||||
|
</element>
|
||||||
|
</optional>
|
||||||
|
</interleave>
|
||||||
|
</group>
|
||||||
|
<group>
|
||||||
|
<attribute name="type">
|
||||||
|
<value>block</value>
|
||||||
|
</attribute>
|
||||||
|
<interleave>
|
||||||
|
<optional>
|
||||||
|
<element name="source">
|
||||||
|
<optional>
|
||||||
|
<attribute name="dev">
|
||||||
|
<ref name="absFilePath"/>
|
||||||
|
</attribute>
|
||||||
|
</optional>
|
||||||
|
<optional>
|
||||||
|
<ref name="startupPolicy"/>
|
||||||
|
</optional>
|
||||||
|
<optional>
|
||||||
|
<ref name='devSeclabel'/>
|
||||||
|
</optional>
|
||||||
|
</element>
|
||||||
|
</optional>
|
||||||
|
</interleave>
|
||||||
|
</group>
|
||||||
|
<group>
|
||||||
|
<attribute name="type">
|
||||||
|
<value>dir</value>
|
||||||
|
</attribute>
|
||||||
|
<interleave>
|
||||||
|
<optional>
|
||||||
|
<element name="source">
|
||||||
|
<attribute name="dir">
|
||||||
<ref name="absFilePath"/>
|
<ref name="absFilePath"/>
|
||||||
</attribute>
|
</attribute>
|
||||||
</optional>
|
<optional>
|
||||||
<optional>
|
<ref name="startupPolicy"/>
|
||||||
<ref name="startupPolicy"/>
|
</optional>
|
||||||
</optional>
|
<empty/>
|
||||||
<optional>
|
</element>
|
||||||
<ref name='devSeclabel'/>
|
</optional>
|
||||||
</optional>
|
</interleave>
|
||||||
</element>
|
</group>
|
||||||
</optional>
|
<group>
|
||||||
<ref name="diskspec"/>
|
<attribute name="type">
|
||||||
</interleave>
|
<value>network</value>
|
||||||
</group>
|
</attribute>
|
||||||
<group>
|
<interleave>
|
||||||
<attribute name="type">
|
<optional>
|
||||||
<value>block</value>
|
<element name="source">
|
||||||
</attribute>
|
<ref name='diskSourceNetwork'/>
|
||||||
<interleave>
|
</element>
|
||||||
<optional>
|
</optional>
|
||||||
<element name="source">
|
</interleave>
|
||||||
<optional>
|
</group>
|
||||||
<attribute name="dev">
|
<group>
|
||||||
<ref name="absFilePath"/>
|
<attribute name="type">
|
||||||
|
<value>volume</value>
|
||||||
|
</attribute>
|
||||||
|
<interleave>
|
||||||
|
<optional>
|
||||||
|
<element name="source">
|
||||||
|
<attribute name="pool">
|
||||||
|
<ref name="genericName"/>
|
||||||
</attribute>
|
</attribute>
|
||||||
</optional>
|
<attribute name="volume">
|
||||||
<optional>
|
<ref name="volName"/>
|
||||||
<ref name="startupPolicy"/>
|
|
||||||
</optional>
|
|
||||||
<optional>
|
|
||||||
<ref name='devSeclabel'/>
|
|
||||||
</optional>
|
|
||||||
</element>
|
|
||||||
</optional>
|
|
||||||
<ref name="diskspec"/>
|
|
||||||
</interleave>
|
|
||||||
</group>
|
|
||||||
<group>
|
|
||||||
<attribute name="type">
|
|
||||||
<value>dir</value>
|
|
||||||
</attribute>
|
|
||||||
<interleave>
|
|
||||||
<optional>
|
|
||||||
<element name="source">
|
|
||||||
<attribute name="dir">
|
|
||||||
<ref name="absFilePath"/>
|
|
||||||
</attribute>
|
|
||||||
<optional>
|
|
||||||
<ref name="startupPolicy"/>
|
|
||||||
</optional>
|
|
||||||
<empty/>
|
|
||||||
</element>
|
|
||||||
</optional>
|
|
||||||
<ref name="diskspec"/>
|
|
||||||
</interleave>
|
|
||||||
</group>
|
|
||||||
<group>
|
|
||||||
<attribute name="type">
|
|
||||||
<value>network</value>
|
|
||||||
</attribute>
|
|
||||||
<interleave>
|
|
||||||
<optional>
|
|
||||||
<element name="source">
|
|
||||||
<ref name='diskSourceNetwork'/>
|
|
||||||
</element>
|
|
||||||
</optional>
|
|
||||||
<ref name="diskspec"/>
|
|
||||||
</interleave>
|
|
||||||
</group>
|
|
||||||
<group>
|
|
||||||
<attribute name="type">
|
|
||||||
<value>volume</value>
|
|
||||||
</attribute>
|
|
||||||
<interleave>
|
|
||||||
<optional>
|
|
||||||
<element name="source">
|
|
||||||
<attribute name="pool">
|
|
||||||
<ref name="genericName"/>
|
|
||||||
</attribute>
|
|
||||||
<attribute name="volume">
|
|
||||||
<ref name="volName"/>
|
|
||||||
</attribute>
|
|
||||||
<optional>
|
|
||||||
<attribute name="mode">
|
|
||||||
<choice>
|
|
||||||
<value>host</value>
|
|
||||||
<value>direct</value>
|
|
||||||
</choice>
|
|
||||||
</attribute>
|
</attribute>
|
||||||
</optional>
|
<optional>
|
||||||
<optional>
|
<attribute name="mode">
|
||||||
<ref name="startupPolicy"/>
|
<choice>
|
||||||
</optional>
|
<value>host</value>
|
||||||
<optional>
|
<value>direct</value>
|
||||||
<ref name='devSeclabel'/>
|
</choice>
|
||||||
</optional>
|
</attribute>
|
||||||
</element>
|
</optional>
|
||||||
</optional>
|
<optional>
|
||||||
<ref name="diskspec"/>
|
<ref name="startupPolicy"/>
|
||||||
</interleave>
|
</optional>
|
||||||
</group>
|
<optional>
|
||||||
|
<ref name='devSeclabel'/>
|
||||||
|
</optional>
|
||||||
|
</element>
|
||||||
|
</optional>
|
||||||
|
</interleave>
|
||||||
|
</group>
|
||||||
|
</choice>
|
||||||
<ref name="diskspec"/>
|
<ref name="diskspec"/>
|
||||||
</choice>
|
</interleave>
|
||||||
</element>
|
</element>
|
||||||
</define>
|
</define>
|
||||||
<define name="diskSourceNetwork">
|
<define name="diskSourceNetwork">
|
||||||
|
@ -16,11 +16,13 @@
|
|||||||
<on_crash>restart</on_crash>
|
<on_crash>restart</on_crash>
|
||||||
<devices>
|
<devices>
|
||||||
<emulator>/usr/bin/qemu</emulator>
|
<emulator>/usr/bin/qemu</emulator>
|
||||||
<disk type='file' device='disk'>
|
<!-- For this disk, intentionally stress parser resilience to
|
||||||
<driver name='qemu' type='qcow2' discard='unmap'/>
|
atypical ordering -->
|
||||||
|
<disk device='disk'>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
|
||||||
<source file='/var/lib/libvirt/images/f14.img'/>
|
<source file='/var/lib/libvirt/images/f14.img'/>
|
||||||
<target dev='vda' bus='virtio'/>
|
<target dev='vda' bus='virtio'/>
|
||||||
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
|
<driver discard='unmap' name='qemu' type='qcow2'/>
|
||||||
</disk>
|
</disk>
|
||||||
<disk type='file' device='cdrom'>
|
<disk type='file' device='cdrom'>
|
||||||
<driver name='qemu' type='raw' discard='ignore'/>
|
<driver name='qemu' type='raw' discard='ignore'/>
|
||||||
|
@ -14,15 +14,17 @@
|
|||||||
<on_crash>destroy</on_crash>
|
<on_crash>destroy</on_crash>
|
||||||
<devices>
|
<devices>
|
||||||
<emulator>/usr/bin/qemu</emulator>
|
<emulator>/usr/bin/qemu</emulator>
|
||||||
<disk type='volume' device='cdrom'>
|
<!-- For this disk, intentionally stress parser resilience to
|
||||||
<source pool='pool-disk' volume='block+cdrom'>
|
atypical ordering -->
|
||||||
|
<disk device='cdrom' type='volume'>
|
||||||
|
<address type='drive' controller='0' bus='0' target='0' unit='1'/>
|
||||||
|
<readonly/>
|
||||||
|
<target bus='ide' dev='hda'/>
|
||||||
|
<source volume='block+cdrom' pool='pool-disk'>
|
||||||
<seclabel model='selinux' relabel='yes'>
|
<seclabel model='selinux' relabel='yes'>
|
||||||
<label>system_u:system_r:public_content_t:s0</label>
|
<label>system_u:system_r:public_content_t:s0</label>
|
||||||
</seclabel>
|
</seclabel>
|
||||||
</source>
|
</source>
|
||||||
<target dev='hda' bus='ide'/>
|
|
||||||
<readonly/>
|
|
||||||
<address type='drive' controller='0' bus='0' target='0' unit='1'/>
|
|
||||||
</disk>
|
</disk>
|
||||||
<disk type='volume' device='cdrom'>
|
<disk type='volume' device='cdrom'>
|
||||||
<driver name='qemu' type='raw'/>
|
<driver name='qemu' type='raw'/>
|
||||||
|
@ -0,0 +1,37 @@
|
|||||||
|
<domain type='qemu'>
|
||||||
|
<name>test</name>
|
||||||
|
<uuid>92d7a226-cfae-425b-a6d3-00bbf9ec5c9e</uuid>
|
||||||
|
<memory unit='KiB'>1048576</memory>
|
||||||
|
<currentMemory unit='KiB'>1048576</currentMemory>
|
||||||
|
<vcpu placement='static'>1</vcpu>
|
||||||
|
<os>
|
||||||
|
<type arch='x86_64' machine='pc-0.13'>hvm</type>
|
||||||
|
<boot dev='cdrom'/>
|
||||||
|
<boot dev='hd'/>
|
||||||
|
<bootmenu enable='yes'/>
|
||||||
|
</os>
|
||||||
|
<clock offset='utc'/>
|
||||||
|
<on_poweroff>destroy</on_poweroff>
|
||||||
|
<on_reboot>restart</on_reboot>
|
||||||
|
<on_crash>restart</on_crash>
|
||||||
|
<devices>
|
||||||
|
<emulator>/usr/bin/qemu</emulator>
|
||||||
|
<disk type='file' device='disk'>
|
||||||
|
<driver name='qemu' type='qcow2' discard='unmap'/>
|
||||||
|
<source file='/var/lib/libvirt/images/f14.img'/>
|
||||||
|
<target dev='vda' bus='virtio'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
|
||||||
|
</disk>
|
||||||
|
<disk type='file' device='cdrom'>
|
||||||
|
<driver name='qemu' type='raw' discard='ignore'/>
|
||||||
|
<source file='/var/lib/libvirt/Fedora-14-x86_64-Live-KDE.iso'/>
|
||||||
|
<target dev='hdc' bus='ide'/>
|
||||||
|
<readonly/>
|
||||||
|
<address type='drive' controller='0' bus='1' target='0' unit='0'/>
|
||||||
|
</disk>
|
||||||
|
<controller type='usb' index='0'/>
|
||||||
|
<controller type='ide' index='0'/>
|
||||||
|
<controller type='pci' index='0' model='pci-root'/>
|
||||||
|
<memballoon model='virtio'/>
|
||||||
|
</devices>
|
||||||
|
</domain>
|
44
tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-source-pool.xml
Normal file
44
tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-source-pool.xml
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
<domain type='qemu'>
|
||||||
|
<name>QEMUGuest1</name>
|
||||||
|
<uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
|
||||||
|
<memory unit='KiB'>219136</memory>
|
||||||
|
<currentMemory unit='KiB'>219136</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='volume' device='cdrom'>
|
||||||
|
<source pool='pool-disk' volume='block+cdrom'>
|
||||||
|
<seclabel model='selinux' relabel='yes'>
|
||||||
|
<label>system_u:system_r:public_content_t:s0</label>
|
||||||
|
</seclabel>
|
||||||
|
</source>
|
||||||
|
<target dev='hda' bus='ide'/>
|
||||||
|
<readonly/>
|
||||||
|
<address type='drive' controller='0' bus='0' target='0' unit='1'/>
|
||||||
|
</disk>
|
||||||
|
<disk type='volume' device='cdrom'>
|
||||||
|
<driver name='qemu' type='raw'/>
|
||||||
|
<target dev='hdc' bus='ide'/>
|
||||||
|
<readonly/>
|
||||||
|
<address type='drive' controller='0' bus='1' target='0' unit='0'/>
|
||||||
|
</disk>
|
||||||
|
<disk type='file' device='disk'>
|
||||||
|
<source file='/tmp/idedisk.img'/>
|
||||||
|
<target dev='hdc' bus='ide'/>
|
||||||
|
<address type='drive' controller='0' bus='0' target='0' unit='2'/>
|
||||||
|
</disk>
|
||||||
|
<controller type='usb' index='0'/>
|
||||||
|
<controller type='ide' index='0'/>
|
||||||
|
<controller type='ide' index='1'/>
|
||||||
|
<controller type='pci' index='0' model='pci-root'/>
|
||||||
|
<memballoon model='virtio'/>
|
||||||
|
</devices>
|
||||||
|
</domain>
|
@ -282,10 +282,10 @@ mymain(void)
|
|||||||
DO_TEST("disk-scsi-lun-passthrough-sgio");
|
DO_TEST("disk-scsi-lun-passthrough-sgio");
|
||||||
|
|
||||||
DO_TEST("disk-scsi-disk-vpd");
|
DO_TEST("disk-scsi-disk-vpd");
|
||||||
DO_TEST("disk-source-pool");
|
DO_TEST_DIFFERENT("disk-source-pool");
|
||||||
DO_TEST("disk-source-pool-mode");
|
DO_TEST("disk-source-pool-mode");
|
||||||
|
|
||||||
DO_TEST("disk-drive-discard");
|
DO_TEST_DIFFERENT("disk-drive-discard");
|
||||||
|
|
||||||
DO_TEST("virtio-rng-random");
|
DO_TEST("virtio-rng-random");
|
||||||
DO_TEST("virtio-rng-egd");
|
DO_TEST("virtio-rng-egd");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user