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(a)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