[libvirt] [PATCH 0/6] RelaxNG improvements for virStorageSource

Part of extending the domain XML to show an entire backing chain is splitting the RelaxNG definitions so that the portion related to a single source within the chain can easily be reused. I'm still debating about the way to handle storage volumes using <format type='qcow2'/> vs. domain disks using <driver name='qcow2' type='qcow2'/>. The majority of the <driver> attributes are associated with the one disk device presented to the guest, rather than attributes for a file in the chain. So I'm thinking of having domain disks add a new <format> element; where we output the format under both elements but accept either spelling for new input (back-compat reasons require that we always provide the old spelling). Eric Blake (6): conf: create common storage RNG grammar file conf: better <disk> interleaving in schema conf: tighten <domainsnapshot> schema conf: split <disk> schema into more pieces conf: move storage source details to common RNG file conf: move <auth> and <encryption> to disk source docs/schemas/Makefile.am | 5 +- docs/schemas/domain.rng | 15 +- docs/schemas/domaincommon.rng | 268 ++---------------- docs/schemas/domainsnapshot.rng | 85 +++--- docs/schemas/storagecommon.rng | 312 +++++++++++++++++++++ docs/schemas/storageencryption.rng | 33 --- docs/schemas/storagefilefeatures.rng | 24 -- docs/schemas/storagevol.rng | 3 +- .../qemuxml2argv-disk-drive-discard.xml | 8 +- .../qemuxml2argv-disk-source-pool.xml | 12 +- .../qemuxml2xmlout-disk-drive-discard.xml | 37 +++ .../qemuxml2xmlout-disk-source-pool.xml | 44 +++ tests/qemuxml2xmltest.c | 4 +- 13 files changed, 477 insertions(+), 373 deletions(-) create mode 100644 docs/schemas/storagecommon.rng delete mode 100644 docs/schemas/storageencryption.rng delete mode 100644 docs/schemas/storagefilefeatures.rng create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-drive-discard.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-source-pool.xml -- 1.9.0

Having two tiny files with a couple definitions didn't make as much sense as one common file, especially since I plan to add more definitions and use it in more places. * docs/schemas/storageencryption.rng: Merge this... * docs/schemas/storagefilefeatures.rng: ...and this, into... * docs/schemas/storagecommon.rng: ...this new file. * docs/schemas/Makefile.am (schema_DATA): Reflect renames. * docs/schemas/storagevol.rng: Likewise. * docs/schemas/domaincommon.rng: Likewise. Signed-off-by: Eric Blake <eblake@redhat.com> --- docs/schemas/Makefile.am | 5 ++--- docs/schemas/domaincommon.rng | 2 +- .../{storageencryption.rng => storagecommon.rng} | 26 ++++++++++++++++++++-- docs/schemas/storagefilefeatures.rng | 24 -------------------- docs/schemas/storagevol.rng | 3 +-- 5 files changed, 28 insertions(+), 32 deletions(-) rename docs/schemas/{storageencryption.rng => storagecommon.rng} (52%) delete mode 100644 docs/schemas/storagefilefeatures.rng diff --git a/docs/schemas/Makefile.am b/docs/schemas/Makefile.am index 47d1941..d71c327 100644 --- a/docs/schemas/Makefile.am +++ b/docs/schemas/Makefile.am @@ -1,4 +1,4 @@ -## Copyright (C) 2005-2011, 2013 Red Hat, Inc. +## Copyright (C) 2005-2011, 2013-2014 Red Hat, Inc. ## ## This library is free software; you can redistribute it and/or ## modify it under the terms of the GNU Lesser General Public @@ -27,8 +27,7 @@ schema_DATA = \ nodedev.rng \ nwfilter.rng \ secret.rng \ - storageencryption.rng \ - storagefilefeatures.rng \ + storagecommon.rng \ storagepool.rng \ storagevol.rng diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index bcd8142..8c1724a 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -2,7 +2,7 @@ <grammar xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"> <!-- domain-related definitions used in multiple grammars --> <include href='basictypes.rng'/> - <include href='storageencryption.rng'/> + <include href='storagecommon.rng'/> <include href='networkcommon.rng'/> <!-- diff --git a/docs/schemas/storageencryption.rng b/docs/schemas/storagecommon.rng similarity index 52% rename from docs/schemas/storageencryption.rng rename to docs/schemas/storagecommon.rng index fa9a8d5..54cf6b4 100644 --- a/docs/schemas/storageencryption.rng +++ b/docs/schemas/storagecommon.rng @@ -1,8 +1,11 @@ <?xml version="1.0"?> -<!-- A Relax NG schema for the libvirt volume encryption XML format --> +<!-- A Relax NG schema for common libvirt XML storage elements --> <grammar xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"> + <!-- This schema is not designed for standalone use; another file + must include both this file and basictypes.rng --> + <define name='encryption'> <element name='encryption'> <attribute name='format'> @@ -25,9 +28,28 @@ </choice> </attribute> <attribute name='uuid'> - <ref name="UUID"/> + <ref name="UUID"/> </attribute> </element> </define> + <define name='compat'> + <element name='compat'> + <data type='string'> + <param name='pattern'>[0-9]+\.[0-9]+</param> + </data> + </element> + </define> + <define name='fileFormatFeatures'> + <element name='features'> + <interleave> + <optional> + <element name='lazy_refcounts'> + <empty/> + </element> + </optional> + </interleave> + </element> + </define> + </grammar> diff --git a/docs/schemas/storagefilefeatures.rng b/docs/schemas/storagefilefeatures.rng deleted file mode 100644 index 424b4e2..0000000 --- a/docs/schemas/storagefilefeatures.rng +++ /dev/null @@ -1,24 +0,0 @@ -<?xml version="1.0"?> -<!-- A Relax NG schema for the libvirt volume features XML format --> -<grammar xmlns="http://relaxng.org/ns/structure/1.0" - datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"> - - <define name='compat'> - <element name='compat'> - <data type='string'> - <param name='pattern'>[0-9]+\.[0-9]+</param> - </data> - </element> - </define> - <define name='fileFormatFeatures'> - <element name='features'> - <interleave> - <optional> - <element name='lazy_refcounts'> - <empty/> - </element> - </optional> - </interleave> - </element> - </define> -</grammar> diff --git a/docs/schemas/storagevol.rng b/docs/schemas/storagevol.rng index 8f07d8f..df8c1eb 100644 --- a/docs/schemas/storagevol.rng +++ b/docs/schemas/storagevol.rng @@ -7,8 +7,7 @@ <ref name='vol'/> </start> - <include href='storageencryption.rng'/> - <include href='storagefilefeatures.rng'/> + <include href='storagecommon.rng'/> <define name='vol'> -- 1.9.0

On 04/13/2014 04:27 AM, Eric Blake wrote:
Having two tiny files with a couple definitions didn't make as much sense as one common file, especially since I plan to add more definitions and use it in more places.
* docs/schemas/storageencryption.rng: Merge this... * docs/schemas/storagefilefeatures.rng: ...and this, into... * docs/schemas/storagecommon.rng: ...this new file. * docs/schemas/Makefile.am (schema_DATA): Reflect renames. * docs/schemas/storagevol.rng: Likewise. * docs/schemas/domaincommon.rng: Likewise.
Signed-off-by: Eric Blake <eblake@redhat.com> --- docs/schemas/Makefile.am | 5 ++--- docs/schemas/domaincommon.rng | 2 +- .../{storageencryption.rng => storagecommon.rng} | 26 ++++++++++++++++++++-- docs/schemas/storagefilefeatures.rng | 24 -------------------- docs/schemas/storagevol.rng | 3 +-- 5 files changed, 28 insertions(+), 32 deletions(-) rename docs/schemas/{storageencryption.rng => storagecommon.rng} (52%) delete mode 100644 docs/schemas/storagefilefeatures.rng
There are still some references to the old filenames: libvirt.spec.in:%{_datadir}/libvirt/schemas/storageencryption.rng libvirt.spec.in:%{_datadir}/libvirt/schemas/storagefilefeatures.rng mingw-libvirt.spec.in:%{mingw32_datadir}/libvirt/schemas/storageencryption.rng mingw-libvirt.spec.in:%{mingw32_datadir}/libvirt/schemas/storagefilefeatures.rng mingw-libvirt.spec.in:%{mingw64_datadir}/libvirt/schemas/storageencryption.rng mingw-libvirt.spec.in:%{mingw64_datadir}/libvirt/schemas/storagefilefeatures.rng ACK with that fixed. Jan

On 04/14/2014 01:22 AM, Ján Tomko wrote:
On 04/13/2014 04:27 AM, Eric Blake wrote:
Having two tiny files with a couple definitions didn't make as much sense as one common file, especially since I plan to add more definitions and use it in more places.
There are still some references to the old filenames:
libvirt.spec.in:%{_datadir}/libvirt/schemas/storageencryption.rng libvirt.spec.in:%{_datadir}/libvirt/schemas/storagefilefeatures.rng mingw-libvirt.spec.in:%{mingw32_datadir}/libvirt/schemas/storageencryption.rng mingw-libvirt.spec.in:%{mingw32_datadir}/libvirt/schemas/storagefilefeatures.rng mingw-libvirt.spec.in:%{mingw64_datadir}/libvirt/schemas/storageencryption.rng mingw-libvirt.spec.in:%{mingw64_datadir}/libvirt/schemas/storagefilefeatures.rng
ACK with that fixed.
Fixed and pushed. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

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> --- docs/schemas/domaincommon.rng | 213 ++++++++++----------- .../qemuxml2argv-disk-drive-discard.xml | 8 +- .../qemuxml2argv-disk-source-pool.xml | 12 +- .../qemuxml2xmlout-disk-drive-discard.xml | 37 ++++ .../qemuxml2xmlout-disk-source-pool.xml | 44 +++++ tests/qemuxml2xmltest.c | 4 +- 6 files changed, 201 insertions(+), 117 deletions(-) create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-drive-discard.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-source-pool.xml diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 8c1724a..7fc0cff 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -1196,119 +1196,118 @@ <optional> <ref name="snapshot"/> </optional> - <choice> - <group> - <attribute name="type"> - <value>file</value> - </attribute> - <interleave> + <interleave> + <choice> + <group> <optional> - <element name="source"> - <optional> - <attribute name="file"> - <ref name="absFilePath"/> - </attribute> - </optional> - <optional> - <ref name="startupPolicy"/> - </optional> - <optional> - <ref name='devSeclabel'/> - </optional> - </element> + <attribute name="type"> + <value>file</value> + </attribute> </optional> - <ref name="diskspec"/> - </interleave> - </group> - <group> - <attribute name="type"> - <value>block</value> - </attribute> - <interleave> - <optional> - <element name="source"> - <optional> - <attribute name="dev"> + <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"/> </attribute> - </optional> - <optional> - <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> + <optional> + <ref name="startupPolicy"/> + </optional> + <empty/> + </element> + </optional> + </interleave> + </group> + <group> + <attribute name="type"> + <value>network</value> + </attribute> + <interleave> + <optional> + <element name="source"> + <ref name='diskSourceNetwork'/> + </element> + </optional> + </interleave> + </group> + <group> + <attribute name="type"> + <value>volume</value> + </attribute> + <interleave> + <optional> + <element name="source"> + <attribute name="pool"> + <ref name="genericName"/> </attribute> - </optional> - <optional> - <ref name="startupPolicy"/> - </optional> - <optional> - <ref name='devSeclabel'/> - </optional> - </element> - </optional> - <ref name="diskspec"/> - </interleave> - </group> + <attribute name="volume"> + <ref name="volName"/> + </attribute> + <optional> + <attribute name="mode"> + <choice> + <value>host</value> + <value>direct</value> + </choice> + </attribute> + </optional> + <optional> + <ref name="startupPolicy"/> + </optional> + <optional> + <ref name='devSeclabel'/> + </optional> + </element> + </optional> + </interleave> + </group> + </choice> <ref name="diskspec"/> - </choice> + </interleave> </element> </define> <define name="diskSourceNetwork"> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-discard.xml b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-discard.xml index f01312f..b15fd63 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-discard.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-discard.xml @@ -16,11 +16,13 @@ <on_crash>restart</on_crash> <devices> <emulator>/usr/bin/qemu</emulator> - <disk type='file' device='disk'> - <driver name='qemu' type='qcow2' discard='unmap'/> + <!-- For this disk, intentionally stress parser resilience to + atypical ordering --> + <disk device='disk'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/> <source file='/var/lib/libvirt/images/f14.img'/> <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 type='file' device='cdrom'> <driver name='qemu' type='raw' discard='ignore'/> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-source-pool.xml b/tests/qemuxml2argvdata/qemuxml2argv-disk-source-pool.xml index e96f76e..95d5be2 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-source-pool.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-source-pool.xml @@ -14,15 +14,17 @@ <on_crash>destroy</on_crash> <devices> <emulator>/usr/bin/qemu</emulator> - <disk type='volume' device='cdrom'> - <source pool='pool-disk' volume='block+cdrom'> + <!-- For this disk, intentionally stress parser resilience to + 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'> <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'/> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-drive-discard.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-drive-discard.xml new file mode 100644 index 0000000..f01312f --- /dev/null +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-drive-discard.xml @@ -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> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-source-pool.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-source-pool.xml new file mode 100644 index 0000000..e96f76e --- /dev/null +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-source-pool.xml @@ -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> diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index c8a1c10..788adbe 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -282,10 +282,10 @@ mymain(void) DO_TEST("disk-scsi-lun-passthrough-sgio"); 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-drive-discard"); + DO_TEST_DIFFERENT("disk-drive-discard"); DO_TEST("virtio-rng-random"); DO_TEST("virtio-rng-egd"); -- 1.9.0

This patch is my first experience playing with nested grammars, as documented in http://relaxng.org/tutorial-20011203.html#IDA3PZR. I plan on doing more overrides in order to make the RelaxNG grammar mirror the C code refactoring into a common virStorageSource, but where different clients of that source do not support the same subset of functionality. By starting with something fairly easy to validate, I can make sure my later patches will be possible. One way to test this patch: s/qed/raw/ in the file tests/domainsnapshotxml2xmlin/disk_snapshot.xml, then run make -C tests check TESTS=domainsnapshotschematest. Pre-patch, the file will pass the schema, even though attempts to use that description with virDomainSnapshotCreateXML will fail because raw files cannot have a backing store. Post-patch, the file will fail virt-xml-validate. * docs/schemas/domainsnapshot.rng (domain): Use nested grammar to avoid restricting <domain>. (storageFormat): Override for tighter usage. * docs/schemas/storagecommon.rng (startupPolicy): Create a no-op default. * docs/schemas/domaincommon.rng (storageFormat): Cross-reference. (startupPolicy): Move the non-trivial define... * docs/schemas/domain.rng (startupPolicy): ...here. Signed-off-by: Eric Blake <eblake@redhat.com> --- docs/schemas/domain.rng | 15 ++++++++++++++- docs/schemas/domaincommon.rng | 12 ++---------- docs/schemas/domainsnapshot.rng | 21 +++++++++++++++++++-- docs/schemas/storagecommon.rng | 5 +++++ 4 files changed, 40 insertions(+), 13 deletions(-) diff --git a/docs/schemas/domain.rng b/docs/schemas/domain.rng index cf0be68..41bd95b 100644 --- a/docs/schemas/domain.rng +++ b/docs/schemas/domain.rng @@ -1,9 +1,22 @@ <?xml version="1.0"?> <grammar xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"> - <!-- We handle only document defining a domain --> + <!-- Grammar for accepting a domain element, both as top level, and + also suitable for inclusion in domainsnapshot.rng --> <start> <ref name="domain"/> </start> <include href='domaincommon.rng'/> + + <define name="startupPolicy" combine='choice'> + <!-- overrides the no-op version in storagecommon.rng --> + <attribute name="startupPolicy"> + <choice> + <value>mandatory</value> + <value>requisite</value> + <value>optional</value> + </choice> + </attribute> + </define> + </grammar> diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 7fc0cff..6c92848 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -1140,16 +1140,6 @@ </element> </define> - <define name="startupPolicy"> - <attribute name="startupPolicy"> - <choice> - <value>mandatory</value> - <value>requisite</value> - <value>optional</value> - </choice> - </attribute> - </define> - <!-- A disk description can be either of type file or block The name of the attribute on the source element depends on the type @@ -1501,6 +1491,8 @@ </optional> </define> <define name='storageFormat'> + <!-- See also domainsnapshot.rng which overrides this for a + smaller set of choices in snapshots --> <choice> <value>raw</value> <value>dir</value> diff --git a/docs/schemas/domainsnapshot.rng b/docs/schemas/domainsnapshot.rng index 824a186..b0ac854 100644 --- a/docs/schemas/domainsnapshot.rng +++ b/docs/schemas/domainsnapshot.rng @@ -5,7 +5,19 @@ <ref name='domainsnapshot'/> </start> - <include href='domaincommon.rng'/> + <include href='domaincommon.rng'> + <!-- override storageFormat to limit to just those formats known + to have backing file --> + <define name='storageFormat'> + <choice> + <value>cow</value> + <value>qcow</value> + <value>qcow2</value> + <value>qed</value> + <value>vmdk</value> + </choice> + </define> + </include> <define name='domainsnapshot'> <element name='domainsnapshot'> @@ -75,7 +87,12 @@ <ref name="UUID"/> </element> </element> - <ref name='domain'/> + <!-- Nested grammar ensures that any of our overrides of + domaincommon defines do not impact the domain.rng + usage of domaincommon. --> + <grammar> + <include href='domain.rng'/> + </grammar> </choice> </optional> <optional> diff --git a/docs/schemas/storagecommon.rng b/docs/schemas/storagecommon.rng index 54cf6b4..0fa90b8 100644 --- a/docs/schemas/storagecommon.rng +++ b/docs/schemas/storagecommon.rng @@ -52,4 +52,9 @@ </element> </define> + <!-- overridden in domain.rng to allow non-empty use --> + <define name='startupPolicy'> + <notAllowed/> + </define> + </grammar> -- 1.9.0

On 04/12/2014 08:27 PM, Eric Blake wrote:
This patch is my first experience playing with nested grammars, as documented in http://relaxng.org/tutorial-20011203.html#IDA3PZR. I plan on doing more overrides in order to make the RelaxNG grammar mirror the C code refactoring into a common virStorageSource, but where different clients of that source do not support the same subset of functionality. By starting with something fairly easy to validate, I can make sure my later patches will be possible.
One way to test this patch: s/qed/raw/ in the file tests/domainsnapshotxml2xmlin/disk_snapshot.xml, then run make -C tests check TESTS=domainsnapshotschematest. Pre-patch, the file will pass the schema, even though attempts to use that description with virDomainSnapshotCreateXML will fail because raw files cannot have a backing store. Post-patch, the file will fail virt-xml-validate.
* docs/schemas/domainsnapshot.rng (domain): Use nested grammar to avoid restricting <domain>. (storageFormat): Override for tighter usage. * docs/schemas/storagecommon.rng (startupPolicy): Create a no-op default. * docs/schemas/domaincommon.rng (storageFormat): Cross-reference. (startupPolicy): Move the non-trivial define... * docs/schemas/domain.rng (startupPolicy): ...here.
Please wait for a v2 on this patch; I'm running into issues with storageFormat that need to be resolved in a better way. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

Disk snapshots use a subset of <disk> sources (no directory or pool support yet, and while domain disks support a startupPolicy, it doesn't make sense for snapshots). This patch lets the two RelaxNG grammars share a bit more code, as well as factoring things into pieces that will be easier to move to a common file for sharing with storage volumes. It relies on the ability to override definitions as part of an include. The diff is a bit hard to read, because it mixes reindentation with refactoring; 'git diff -b --patience' may help. * docs/schemas/domaincommon.rng (disk): Refactor into pieces. (diskSource, diskSourceFile, diskSourceBlock, diskSourceDir) (diskSourceVolume: New defines. (diskSourceNetwork): Revise scope. * docs/schemas/domainsnapshot.rng (disksnapshot): Adjust. (disksnapshotsource): New define. (diskspec): Override the domaincommon version. Signed-off-by: Eric Blake <eblake@redhat.com> --- docs/schemas/domaincommon.rng | 331 +++++++++++++++++++++------------------- docs/schemas/domainsnapshot.rng | 67 ++------ 2 files changed, 188 insertions(+), 210 deletions(-) diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 6c92848..6de41b0 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -1033,6 +1033,7 @@ <empty/> </element> </define> + <define name="diskspec"> <interleave> <optional> @@ -1186,175 +1187,187 @@ <optional> <ref name="snapshot"/> </optional> - <interleave> - <choice> - <group> - <optional> - <attribute name="type"> - <value>file</value> - </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"/> - </attribute> - <optional> - <ref name="startupPolicy"/> - </optional> - <empty/> - </element> - </optional> - </interleave> - </group> - <group> - <attribute name="type"> - <value>network</value> + <ref name="diskSource"/> + </element> + </define> + + <define name="diskSource"> + <choice> + <ref name="diskSourceFile"/> + <ref name="diskSourceBlock"/> + <ref name="diskSourceDir"/> + <ref name="diskSourceNetwork"/> + <ref name="diskSourceVolume"/> + </choice> + </define> + + <define name="diskSourceFile"> + <optional> + <attribute name="type"> + <value>file</value> + </attribute> + </optional> + <interleave> + <optional> + <element name="source"> + <optional> + <attribute name="file"> + <ref name="absFilePath"/> </attribute> - <interleave> - <optional> - <element name="source"> - <ref name='diskSourceNetwork'/> - </element> - </optional> - </interleave> - </group> - <group> - <attribute name="type"> - <value>volume</value> + </optional> + <optional> + <ref name="startupPolicy"/> + </optional> + <optional> + <ref name='devSeclabel'/> + </optional> + </element> + </optional> + <ref name='diskspec'/> + </interleave> + </define> + + <define name="diskSourceBlock"> + <attribute name="type"> + <value>block</value> + </attribute> + <interleave> + <optional> + <element name="source"> + <optional> + <attribute name="dev"> + <ref name="absFilePath"/> </attribute> - <interleave> - <optional> - <element name="source"> - <attribute name="pool"> - <ref name="genericName"/> + </optional> + <optional> + <ref name="startupPolicy"/> + </optional> + <optional> + <ref name='devSeclabel'/> + </optional> + </element> + </optional> + <ref name='diskspec'/> + </interleave> + </define> + + <define name="diskSourceDir"> + <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> + </define> + + <define name="diskSourceNetwork"> + <attribute name="type"> + <value>network</value> + </attribute> + <interleave> + <element name="source"> + <attribute name="protocol"> + <choice> + <value>nbd</value> + <value>rbd</value> + <value>sheepdog</value> + <value>gluster</value> + <value>iscsi</value> + <value>http</value> + <value>https</value> + <value>ftp</value> + <value>ftps</value> + <value>tftp</value> + </choice> + </attribute> + <optional> + <attribute name="name"/> + </optional> + <zeroOrMore> + <element name="host"> + <choice> + <group> + <optional> + <attribute name="transport"> + <choice> + <value>tcp</value> + <value>rdma</value> + </choice> </attribute> - <attribute name="volume"> - <ref name="volName"/> + </optional> + <attribute name="name"> + <choice> + <ref name="dnsName"/> + <ref name="ipAddr"/> + </choice> + </attribute> + <optional> + <attribute name="port"> + <ref name="unsignedInt"/> </attribute> - <optional> - <attribute name="mode"> - <choice> - <value>host</value> - <value>direct</value> - </choice> - </attribute> - </optional> - <optional> - <ref name="startupPolicy"/> - </optional> - <optional> - <ref name='devSeclabel'/> - </optional> - </element> - </optional> - </interleave> - </group> - </choice> - <ref name="diskspec"/> - </interleave> - </element> + </optional> + </group> + <group> + <attribute name="transport"> + <value>unix</value> + </attribute> + <attribute name="socket"> + <ref name="absFilePath"/> + </attribute> + </group> + </choice> + </element> + </zeroOrMore> + <empty/> + </element> + <ref name='diskspec'/> + </interleave> </define> - <define name="diskSourceNetwork"> - <attribute name="protocol"> - <choice> - <value>nbd</value> - <value>rbd</value> - <value>sheepdog</value> - <value>gluster</value> - <value>iscsi</value> - <value>http</value> - <value>https</value> - <value>ftp</value> - <value>ftps</value> - <value>tftp</value> - </choice> + + <define name="diskSourceVolume"> + <attribute name="type"> + <value>volume</value> </attribute> - <optional> - <attribute name="name"/> - </optional> - <zeroOrMore> - <element name="host"> - <choice> - <group> - <optional> - <attribute name="transport"> - <choice> - <value>tcp</value> - <value>rdma</value> - </choice> - </attribute> - </optional> - <attribute name="name"> + <interleave> + <optional> + <element name="source"> + <attribute name="pool"> + <ref name="genericName"/> + </attribute> + <attribute name="volume"> + <ref name="volName"/> + </attribute> + <optional> + <attribute name="mode"> <choice> - <ref name="dnsName"/> - <ref name="ipAddr"/> + <value>host</value> + <value>direct</value> </choice> </attribute> - <optional> - <attribute name="port"> - <ref name="unsignedInt"/> - </attribute> - </optional> - </group> - <group> - <attribute name="transport"> - <value>unix</value> - </attribute> - <attribute name="socket"> - <ref name="absFilePath"/> - </attribute> - </group> - </choice> - </element> - </zeroOrMore> - <empty/> + </optional> + <optional> + <ref name="startupPolicy"/> + </optional> + <optional> + <ref name='devSeclabel'/> + </optional> + </element> + </optional> + <ref name='diskspec'/> + </interleave> </define> + <define name="diskTarget"> <data type="string"> <param name="pattern">(ioemu:)?(fd|hd|sd|vd|xvd|ubd)[a-zA-Z0-9_]+</param> diff --git a/docs/schemas/domainsnapshot.rng b/docs/schemas/domainsnapshot.rng index b0ac854..5764e77 100644 --- a/docs/schemas/domainsnapshot.rng +++ b/docs/schemas/domainsnapshot.rng @@ -17,6 +17,13 @@ <value>vmdk</value> </choice> </define> + + <define name="diskspec"> + <!-- Override the domaincommon definition to select just the + extra elements needed for a snapshot --> + <ref name='disksnapshotdriver'/> + </define> + </include> <define name='domainsnapshot'> @@ -140,62 +147,20 @@ <value>external</value> </attribute> </optional> - <choice> - <group> - <optional> - <attribute name='type'> - <value>file</value> - </attribute> - </optional> - <interleave> - <optional> - <element name='source'> - <optional> - <attribute name='file'> - <ref name='absFilePath'/> - </attribute> - </optional> - <empty/> - </element> - </optional> - <ref name='disksnapshotdriver'/> - </interleave> - </group> - <group> - <attribute name='type'> - <value>block</value> - </attribute> - <interleave> - <optional> - <element name="source"> - <attribute name="dev"> - <ref name="absFilePath"/> - </attribute> - <empty/> - </element> - </optional> - <ref name='disksnapshotdriver'/> - </interleave> - </group> - <group> - <attribute name="type"> - <value>network</value> - </attribute> - <interleave> - <optional> - <element name="source"> - <ref name='diskSourceNetwork'/> - </element> - </optional> - <ref name='disksnapshotdriver'/> - </interleave> - </group> - </choice> + <ref name="disksnapshotsource"/> </group> </choice> </element> </define> + <define name='disksnapshotsource'> + <choice> + <ref name='diskSourceFile'/> + <ref name='diskSourceBlock'/> + <ref name='diskSourceNetwork'/> + </choice> + </define> + <define name='disksnapshotdriver'> <optional> <element name='driver'> -- 1.9.0

Start reflecting the C source code by moving RelaxNG grammar for virStorageSource into a common file. There's still more to move, but doing it in pieces makes it easier to validate. * docs/schemas/domaincommon.rng (diskSourceFile, diskSourceBlock) (diskSourceDir, diskSourceNetwork, diskSourceVolume) (devSeclabel): Move... * docs/schemas/storagecommon.rng (storageSourceFile) (storageSourceBlock, storageSourceDir, storageSourceNetwork) (storageSourceVolume, devSeclabel): ...and rename. (storageSourceExtra): New define. * docs/schemas/domainsnapshot.rng (disksnapshotsource): Update client. (diskspec): Change override... (storageSourceExtra): ...into combine. Signed-off-by: Eric Blake <eblake@redhat.com> --- docs/schemas/domaincommon.rng | 215 ++-------------------------------------- docs/schemas/domainsnapshot.rng | 17 ++-- docs/schemas/storagecommon.rng | 212 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 228 insertions(+), 216 deletions(-) diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 6de41b0..80b58e8 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -71,6 +71,7 @@ </element> </define> <define name="seclabel"> + <!-- see also devseclabel in storagecommon.rng --> <element name="seclabel"> <optional> <attribute name='model'> @@ -149,42 +150,7 @@ </choice> </element> </define> - <define name="devSeclabel"> - <element name="seclabel"> - <!-- A per-device seclabel override is more limited, either - relabel=no or a <label> must be present on input; - output also can include labelskip=yes. --> - <optional> - <attribute name='model'> - <text/> - </attribute> - </optional> - <choice> - <group> - <attribute name='relabel'> - <value>no</value> - </attribute> - </group> - <group> - <attribute name='labelskip'> - <value>yes</value> - </attribute> - </group> - <group> - <optional> - <attribute name='relabel'> - <value>yes</value> - </attribute> - </optional> - <oneOrMore> - <element name='label'> - <text/> - </element> - </oneOrMore> - </group> - </choice> - </element> - </define> + <define name="hvs"> <attribute name="type"> <choice> @@ -1193,179 +1159,16 @@ <define name="diskSource"> <choice> - <ref name="diskSourceFile"/> - <ref name="diskSourceBlock"/> - <ref name="diskSourceDir"/> - <ref name="diskSourceNetwork"/> - <ref name="diskSourceVolume"/> + <ref name="storageSourceFile"/> + <ref name="storageSourceBlock"/> + <ref name="storageSourceDir"/> + <ref name="storageSourceNetwork"/> + <ref name="storageSourceVolume"/> </choice> </define> - <define name="diskSourceFile"> - <optional> - <attribute name="type"> - <value>file</value> - </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> - <ref name='diskspec'/> - </interleave> - </define> - - <define name="diskSourceBlock"> - <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> - <ref name='diskspec'/> - </interleave> - </define> - - <define name="diskSourceDir"> - <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> - </define> - - <define name="diskSourceNetwork"> - <attribute name="type"> - <value>network</value> - </attribute> - <interleave> - <element name="source"> - <attribute name="protocol"> - <choice> - <value>nbd</value> - <value>rbd</value> - <value>sheepdog</value> - <value>gluster</value> - <value>iscsi</value> - <value>http</value> - <value>https</value> - <value>ftp</value> - <value>ftps</value> - <value>tftp</value> - </choice> - </attribute> - <optional> - <attribute name="name"/> - </optional> - <zeroOrMore> - <element name="host"> - <choice> - <group> - <optional> - <attribute name="transport"> - <choice> - <value>tcp</value> - <value>rdma</value> - </choice> - </attribute> - </optional> - <attribute name="name"> - <choice> - <ref name="dnsName"/> - <ref name="ipAddr"/> - </choice> - </attribute> - <optional> - <attribute name="port"> - <ref name="unsignedInt"/> - </attribute> - </optional> - </group> - <group> - <attribute name="transport"> - <value>unix</value> - </attribute> - <attribute name="socket"> - <ref name="absFilePath"/> - </attribute> - </group> - </choice> - </element> - </zeroOrMore> - <empty/> - </element> - <ref name='diskspec'/> - </interleave> - </define> - - <define name="diskSourceVolume"> - <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> - </optional> - <optional> - <ref name="startupPolicy"/> - </optional> - <optional> - <ref name='devSeclabel'/> - </optional> - </element> - </optional> - <ref name='diskspec'/> - </interleave> + <define name='storageSourceExtra' combine='choice'> + <ref name='diskspec'/> </define> <define name="diskTarget"> diff --git a/docs/schemas/domainsnapshot.rng b/docs/schemas/domainsnapshot.rng index 5764e77..dc404ef 100644 --- a/docs/schemas/domainsnapshot.rng +++ b/docs/schemas/domainsnapshot.rng @@ -17,13 +17,6 @@ <value>vmdk</value> </choice> </define> - - <define name="diskspec"> - <!-- Override the domaincommon definition to select just the - extra elements needed for a snapshot --> - <ref name='disksnapshotdriver'/> - </define> - </include> <define name='domainsnapshot'> @@ -155,12 +148,16 @@ <define name='disksnapshotsource'> <choice> - <ref name='diskSourceFile'/> - <ref name='diskSourceBlock'/> - <ref name='diskSourceNetwork'/> + <ref name='storageSourceFile'/> + <ref name='storageSourceBlock'/> + <ref name='storageSourceNetwork'/> </choice> </define> + <define name='storageSourceExtra' combine='choice'> + <ref name='disksnapshotdriver'/> + </define> + <define name='disksnapshotdriver'> <optional> <element name='driver'> diff --git a/docs/schemas/storagecommon.rng b/docs/schemas/storagecommon.rng index 0fa90b8..ef0f62f 100644 --- a/docs/schemas/storagecommon.rng +++ b/docs/schemas/storagecommon.rng @@ -57,4 +57,216 @@ <notAllowed/> </define> + <define name="devSeclabel"> + <element name="seclabel"> + <!-- A per-device seclabel override is more limited than + seclabel in domaincommon.rng. Either + relabel=no or a <label> must be present on input; + output also can include labelskip=yes. --> + <optional> + <attribute name='model'> + <text/> + </attribute> + </optional> + <choice> + <group> + <attribute name='relabel'> + <value>no</value> + </attribute> + </group> + <group> + <attribute name='labelskip'> + <value>yes</value> + </attribute> + </group> + <group> + <optional> + <attribute name='relabel'> + <value>yes</value> + </attribute> + </optional> + <oneOrMore> + <element name='label'> + <text/> + </element> + </oneOrMore> + </group> + </choice> + </element> + </define> + + <define name='storageSourceExtra'> + <!-- Use a combine='choice' in each client file that includes this + grammar in order to allow additional elements as siblings of + a storage <source> element. --> + <notAllowed/> + </define> + + <define name="storageSourceFile"> + <optional> + <attribute name="type"> + <value>file</value> + </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> + <ref name='storageSourceExtra'/> + </interleave> + </define> + + <define name="storageSourceBlock"> + <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> + <ref name='storageSourceExtra'/> + </interleave> + </define> + + <define name="storageSourceDir"> + <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='storageSourceExtra'/> + </interleave> + </define> + + <define name="storageSourceNetwork"> + <attribute name="type"> + <value>network</value> + </attribute> + <interleave> + <element name="source"> + <attribute name="protocol"> + <choice> + <value>nbd</value> + <value>rbd</value> + <value>sheepdog</value> + <value>gluster</value> + <value>iscsi</value> + <value>http</value> + <value>https</value> + <value>ftp</value> + <value>ftps</value> + <value>tftp</value> + </choice> + </attribute> + <optional> + <attribute name="name"/> + </optional> + <zeroOrMore> + <element name="host"> + <choice> + <group> + <optional> + <attribute name="transport"> + <choice> + <value>tcp</value> + <value>rdma</value> + </choice> + </attribute> + </optional> + <attribute name="name"> + <choice> + <ref name="dnsName"/> + <ref name="ipAddr"/> + </choice> + </attribute> + <optional> + <attribute name="port"> + <ref name="unsignedInt"/> + </attribute> + </optional> + </group> + <group> + <attribute name="transport"> + <value>unix</value> + </attribute> + <attribute name="socket"> + <ref name="absFilePath"/> + </attribute> + </group> + </choice> + </element> + </zeroOrMore> + <empty/> + </element> + <ref name='storageSourceExtra'/> + </interleave> + </define> + + <define name="storageSourceVolume"> + <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> + </optional> + <optional> + <ref name="startupPolicy"/> + </optional> + <optional> + <ref name='devSeclabel'/> + </optional> + </element> + </optional> + <ref name='storageSourceExtra'/> + </interleave> + </define> + </grammar> -- 1.9.0

In a backing chain, each file of the chain can have a different authorization or encryption; therefore, this information should be associated with the common storage source elements. * docs/schemas/domaincommon.rng (diskspec): Drop source-related portions... (disksource): ...and include common types here instead. (diskAuth, diskAuthSecret): Move... * docs/schemas/storagecommon.rng (diskAuth, diskAuthSecret): ...here. (storageSourceCommon): New define. Signed-off-by: Eric Blake <eblake@redhat.com> --- docs/schemas/domaincommon.rng | 33 ---------------------------- docs/schemas/storagecommon.rng | 50 +++++++++++++++++++++++++++++++++++++----- 2 files changed, 45 insertions(+), 38 deletions(-) diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 80b58e8..b302433 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -1008,9 +1008,6 @@ <optional> <ref name='diskMirror'/> </optional> - <optional> - <ref name="diskAuth"/> - </optional> <ref name="target"/> <optional> <ref name="deviceBoot"/> @@ -1036,9 +1033,6 @@ </element> </optional> <optional> - <ref name="encryption"/> - </optional> - <optional> <ref name="diskIoTune"/> </optional> <optional> @@ -3974,33 +3968,6 @@ </optional> </element> </define> - <define name="diskAuth"> - <element name="auth"> - <attribute name="username"> - <ref name="genericName"/> - </attribute> - <ref name="diskAuthSecret"/> - </element> - </define> - - <define name='diskAuthSecret'> - <element name='secret'> - <attribute name='type'> - <choice> - <value>ceph</value> - <value>iscsi</value> - </choice> - </attribute> - <choice> - <attribute name='uuid'> - <ref name="UUID"/> - </attribute> - <attribute name='usage'> - <ref name='genericName'/> - </attribute> - </choice> - </element> - </define> <define name='diskIoTune'> <element name="iotune"> diff --git a/docs/schemas/storagecommon.rng b/docs/schemas/storagecommon.rng index ef0f62f..5a4633a 100644 --- a/docs/schemas/storagecommon.rng +++ b/docs/schemas/storagecommon.rng @@ -6,6 +6,34 @@ <!-- This schema is not designed for standalone use; another file must include both this file and basictypes.rng --> + <define name='diskAuthSecret'> + <element name='secret'> + <attribute name='type'> + <choice> + <value>ceph</value> + <value>iscsi</value> + </choice> + </attribute> + <choice> + <attribute name='uuid'> + <ref name="UUID"/> + </attribute> + <attribute name='usage'> + <ref name='genericName'/> + </attribute> + </choice> + </element> + </define> + + <define name="diskAuth"> + <element name="auth"> + <attribute name="username"> + <ref name="genericName"/> + </attribute> + <ref name="diskAuthSecret"/> + </element> + </define> + <define name='encryption'> <element name='encryption'> <attribute name='format'> @@ -102,6 +130,18 @@ <notAllowed/> </define> + <define name='storageSourceCommon'> + <interleave> + <optional> + <ref name="encryption"/> + </optional> + <optional> + <ref name="diskAuth"/> + </optional> + <ref name='storageSourceExtra'/> + </interleave> + </define> + <define name="storageSourceFile"> <optional> <attribute name="type"> @@ -124,7 +164,7 @@ </optional> </element> </optional> - <ref name='storageSourceExtra'/> + <ref name='storageSourceCommon'/> </interleave> </define> @@ -148,7 +188,7 @@ </optional> </element> </optional> - <ref name='storageSourceExtra'/> + <ref name='storageSourceCommon'/> </interleave> </define> @@ -168,7 +208,7 @@ <empty/> </element> </optional> - <ref name='storageSourceExtra'/> + <ref name='storageSourceCommon'/> </interleave> </define> @@ -232,7 +272,7 @@ </zeroOrMore> <empty/> </element> - <ref name='storageSourceExtra'/> + <ref name='storageSourceCommon'/> </interleave> </define> @@ -265,7 +305,7 @@ </optional> </element> </optional> - <ref name='storageSourceExtra'/> + <ref name='storageSourceCommon'/> </interleave> </define> -- 1.9.0
participants (2)
-
Eric Blake
-
Ján Tomko