libvirt/docs/schemas/basictypes.rng

401 lines
12 KiB
Plaintext
Raw Normal View History

<?xml version="1.0"?>
<!-- network-related definitions used in multiple grammars -->
<grammar xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
<!-- Our unsignedInt doesn"t allow a leading "+" in its lexical form -->
<define name="unsignedInt">
<data type="unsignedInt">
<param name="pattern">[0-9]+</param>
</data>
</define>
<define name='unsignedLong'>
<data type='unsignedLong'>
<param name='pattern'>[0-9]+</param>
</data>
</define>
<define name="positiveInteger">
<data type="positiveInteger">
<param name="pattern">[0-9]+</param>
</data>
</define>
<define name='octalMode'>
<data type="unsignedInt">
<param name='pattern'>[0-7]+</param>
</data>
</define>
<define name="uint8range">
<choice>
<data type="string">
<param name="pattern">0x[0-9a-fA-F]{1,2}</param>
</data>
<data type="int">
<param name="minInclusive">0</param>
<param name="maxInclusive">255</param>
</data>
</choice>
</define>
<define name="uint24range">
<choice>
<data type="string">
<param name="pattern">0x[0-9a-fA-F]{1,6}</param>
</data>
<data type="int">
<param name="minInclusive">0</param>
<param name="maxInclusive">16777215</param>
</data>
</choice>
</define>
<define name="UUID">
<choice>
<data type="string">
<param name="pattern">[a-fA-F0-9]{32}</param>
</data>
<data type="string">
<param name="pattern">[a-fA-F0-9]{8}\-([a-fA-F0-9]{4}\-){3}[a-fA-F0-9]{12}</param>
</data>
</choice>
</define>
<define name="pciaddress">
<optional>
<attribute name="domain">
<ref name="pciDomain"/>
</attribute>
</optional>
<attribute name="bus">
<ref name="pciBus"/>
</attribute>
<attribute name="slot">
<ref name="pciSlot"/>
</attribute>
<attribute name="function">
<ref name="pciFunc"/>
</attribute>
<optional>
<attribute name="multifunction">
<choice>
<value>on</value>
<value>off</value>
</choice>
</attribute>
</optional>
</define>
<!-- a 6 byte MAC address in ASCII-hex format, eg "12:34:56:78:9A:BC" -->
<!-- The lowest bit of the 1st byte is the "multicast" bit. a -->
<!-- uniMacAddr requires that bit to be 0, and a multiMacAddr -->
<!-- requires it to be 1. Plain macAddr will accept either. -->
<!-- Currently there is no use of multiMacAddr in libvirt, it -->
<!-- is included here for documentation/comparison purposes. -->
<define name="uniMacAddr">
<data type="string">
<param name="pattern">[a-fA-F0-9][02468aAcCeE](:[a-fA-F0-9]{2}){5}</param>
</data>
</define>
<define name="multiMacAddr">
<data type="string">
<param name="pattern">[a-fA-F0-9][13579bBdDfF](:[a-fA-F0-9]{2}){5}</param>
</data>
</define>
<define name="macAddr">
<data type="string">
<param name="pattern">[a-fA-F0-9]{2}(:[a-fA-F0-9]{2}){5}</param>
</data>
</define>
<!--====================================================================-->
<!--The duid is a unique identifier used in DHCPv6 to identity an -->
<!--interface on a device (system). The duid is often used by servers -->
<!--such as dnsmasq to assign a specific IP address (and optionally a -->
<!--name to an interface. The applicable standards are RFC3315 and -->
<!--RFC6355. These standards actualy require the duid to be fixed for -->
<!--the hardward device and applicable to all network interfaces on -->
<!--that device. It is not clear that any software currently enforces -->
<!--this requirement although it could be implemented manually. -->
<!--====================================================================-->
<!--There are currently four types of duids defined: -->
<!-- type 1, duid-LLT, link-layer (MAC) plus 32 bit time when the -->
<!-- duid-LLT was created in seconds from January 1, 2000 -->
<!-- type 2, duid-EN, 32 bit "enterprise number" followed by a -->
<!-- variable length unique identifier. -->
<!-- type 3, duid-LL, link-layer (MAC) -->
<!-- type 4, duid-UUID, a 128 bit UUID (16 bytes) -->
<!--RFC3315 states that the maximum length of a duid is 128 bytes plus -->
<!--the 16 bit type field. Often, the machine type is "1" which is the -->
<!--number assigned to ethernet. -->
<define name="duidLLT">
<data type="string">
<!-- 0======| type======| 0======| machine type======| time================| link-layer============| -->
<param name="pattern">[0]{1,2}:[0]{0,1}[1]:[0]{1,2}:[0]{0,1}[a-fA-F1-9](:[a-fA-F0-9]{1,2}){4}(:[a-fA-F0-9]{1,2}){6,8}</param>
</data>
</define>
<define name="duidEN">
<data type="string">
<!-- 0======| type======| Enterprise number===| unique id ==============| -->
<param name="pattern">[0]{1,2}:[0]{0,1}[2](:[a-fA-F0-9]{1,2}){4}(:[a-fA-F0-9]{1,2}){1,124}</param>
</data>
</define>
<define name="duidLL">
<data type="string">
<!-- 0======| type======| 0======| machine type======| link-layer============| -->
<param name="pattern">[0]{1,2}:[0]{0,1}[3]:[0]{1,2}:[0]{0,1}[a-fA-F1-9](:[a-fA-F0-9]{1,2}){6,8}</param>
</data>
</define>
<define name="duidUUID">
<data type="string">
<!-- 0======| type======| UUID=================| -->
<param name="pattern">[0]{1,2}:[0]{0,1}[4](:[a-fA-F0-9]{1,2}){16}</param>
</data>
</define>
<define name="DUID">
<choice>
<ref name="duidLLT"/>
<ref name="duidEN"/>
<ref name="duidLL"/>
<ref name="duidUUID"/>
</choice>
</define>
<!--======================================================================-->
<!-- An ipv4 "dotted quad" address -->
<define name="ipv4Addr">
<data type="string">
<param name="pattern">(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([1-9][0-9])|([0-9]))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([1-9][0-9])|([0-9]))</param>
</data>
</define>
<!-- Based on http://blog.mes-stats.fr/2008/10/09/regex-ipv4-et-ipv6 -->
<define name="ipv6Addr">
<data type="string">
<!-- To understand this better, take apart the toplevel "|"s -->
<param name="pattern">(([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){5}:([0-9A-Fa-f]{1,4}:)?[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){4}:([0-9A-Fa-f]{1,4}:){0,2}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){3}:([0-9A-Fa-f]{1,4}:){0,3}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){2}:([0-9A-Fa-f]{1,4}:){0,4}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([1-9][0-9])|([0-9]))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([1-9][0-9])|([0-9])))|(([0-9A-Fa-f]{1,4}:){0,5}:(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([1-9][0-9])|([0-9]))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([1-9][0-9])|([0-9])))|(::([0-9A-Fa-f]{1,4}:){0,5}(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([1-9][0-9])|([0-9]))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([1-9][0-9])|([0-9])))|([0-9A-Fa-f]{1,4}::([0-9A-Fa-f]{1,4}:){0,5}[0-9A-Fa-f]{1,4})|(::([0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,7}:)</param>
</data>
</define>
<define name="ipAddr">
<choice>
<ref name="ipv4Addr"/>
<ref name="ipv6Addr"/>
</choice>
</define>
<define name="ipv4Prefix">
<data type="unsignedInt">
<param name="maxInclusive">32</param>
</data>
</define>
<define name="ipv6Prefix">
<data type="unsignedInt">
<param name="maxInclusive">128</param>
</data>
</define>
<define name="ipPrefix">
<choice>
<ref name="ipv4Prefix"/>
<ref name="ipv6Prefix"/>
</choice>
</define>
<define name="genericName">
<data type="string">
<param name="pattern">[a-zA-Z0-9_\+\-]+</param>
</data>
</define>
<define name="dnsName">
<data type="string">
<param name="pattern">[a-zA-Z0-9\.\-]+</param>
</data>
</define>
<define name="deviceName">
<data type="string">
<param name="pattern">[a-zA-Z0-9_\.\-\\:/]+</param>
</data>
</define>
<define name="filePath">
<data type="string">
<param name="pattern">[a-zA-Z0-9_\.\+\-\\&amp;&quot;&apos;&lt;&gt;/%]+</param>
</data>
</define>
<define name="absFilePath">
<data type="string">
<param name="pattern">/[a-zA-Z0-9_\.\+\-\\&amp;&quot;&apos;&lt;&gt;/%,]+</param>
</data>
</define>
<define name="absDirPath">
<data type="string">
<param name="pattern">/[a-zA-Z0-9_\.\+\-\\&amp;&quot;&apos;&lt;&gt;/%]*</param>
</data>
</define>
<define name='unit'>
<data type='string'>
<param name='pattern'>([bB]([yY][tT][eE][sS]?)?)|([kKmMgGtTpPeE]([iI]?[bB])?)</param>
</data>
</define>
xml: output memory unit for clarity Make it obvious to 'dumpxml' readers what unit we are using, since our default of KiB for memory (1024) differs from qemu's default of MiB; and differs from our use of bytes for storage. Tests were updated via: $ find tests/*data tests/*out -name '*.xml' | \ xargs sed -i 's/<\(memory\|currentMemory\|hard_limit\|soft_limit\|min_guarantee\|swap_hard_limit\)>/<\1 unit='"'KiB'>/" $ find tests/*data tests/*out -name '*.xml' | \ xargs sed -i 's/<\(capacity\|allocation\|available\)>/<\1 unit='"'bytes'>/" followed by a few fixes for the stragglers. Note that with this patch, the RNG for <memory> still forbids validation of anything except unit='KiB', since the code silently ignores the attribute; a later patch will expand <memory> to allow scaled input in the code and update the RNG to match. * docs/schemas/basictypes.rng (unit): Add 'bytes'. (scaledInteger): New define. * docs/schemas/storagevol.rng (sizing): Use it. * docs/schemas/storagepool.rng (sizing): Likewise. * docs/schemas/domaincommon.rng (memoryKBElement): New define; use for memory elements. * src/conf/storage_conf.c (virStoragePoolDefFormat) (virStorageVolDefFormat): Likewise. * src/conf/domain_conf.h (_virDomainDef): Document unit used internally. * src/conf/storage_conf.h (_virStoragePoolDef, _virStorageVolDef): Likewise. * tests/*data/*.xml: Update all tests. * tests/*out/*.xml: Likewise. * tests/define-dev-segfault: Likewise. * tests/openvzutilstest.c (testReadNetworkConf): Likewise. * tests/qemuargv2xmltest.c (blankProblemElements): Likewise.
2012-02-23 00:48:38 +00:00
<define name='scaledInteger'>
<optional>
<attribute name='unit'>
<ref name='unit'/>
</attribute>
</optional>
<ref name='unsignedLong'/>
</define>
<define name="pciDomain">
<data type="string">
<param name="pattern">(0x)?[0-9a-fA-F]{1,4}</param>
</data>
</define>
<define name="pciBus">
<data type="string">
<param name="pattern">(0x)?[0-9a-fA-F]{1,2}</param>
</data>
</define>
<define name="pciSlot">
<data type="string">
<param name="pattern">(0x)?[0-1]?[0-9a-fA-F]</param>
</data>
</define>
<define name="pciFunc">
<data type="string">
<param name="pattern">(0x)?[0-7]</param>
</data>
</define>
<define name='wwn'>
<data type='string'>
<param name='pattern'>(0x)?[0-9a-fA-F]{16}</param>
</data>
</define>
<define name="cpuset">
<data type="string">
<param name="pattern">([0-9]+(-[0-9]+)?|\^[0-9]+)(,([0-9]+(-[0-9]+)?|\^[0-9]+))*</param>
</data>
</define>
<define name='volName'>
storage: use valid XML for awkward volume names $ touch /var/lib/libvirt/images/'a<b>c' $ virsh pool-refresh default $ virsh vol-dumpxml 'a<b>c' default | head -n2 <volume> <name>a<b>c</name> Oops. That's not valid XML. And when we fix the XML generation, it fails RelaxNG validation. I'm also tired of seeing <key>(null)</key> in the example output for volume xml; while we used NULLSTR() to avoid a NULL deref rather than relying on glibc's printf extension behavior, it's even better if we avoid the issue in the first place. But this requires being careful that we don't invalidate any storage backends that were relying on key being unassigned during virStoragVolCreateXML[From]. I would have split this into two patches (one for escaping, one for avoiding <key>(null)</key>), but since they both end up touching a lot of the same test files, I ended up merging it into one. Note that this patch allows pretty much any volume name that can appear in a directory (excluding . and .. because those are special), but does nothing to change the current (unenforced) RelaxNG claim that pool names will consist only of letters, numbers, _, -, and +. Tightening the C code to match RelaxNG patterns and/or relaxing the grammar to match the C code for pool names is a task for another day (but remember, we DID recently tighten C code for domain names to exclude a leading '.'). * src/conf/storage_conf.c (virStoragePoolSourceFormat) (virStoragePoolDefFormat, virStorageVolTargetDefFormat) (virStorageVolDefFormat): Escape user-controlled strings. (virStorageVolDefParseXML): Parse key, for use in unit tests. * src/storage/storage_driver.c (storageVolCreateXML) (storageVolCreateXMLFrom): Ensure parsed key doesn't confuse volume creation. * docs/schemas/basictypes.rng (volName): Relax definition. * tests/storagepoolxml2xmltest.c (mymain): Test it. * tests/storagevolxml2xmltest.c (mymain): Likewise. * tests/storagepoolxml2xmlin/pool-dir-naming.xml: New file. * tests/storagepoolxml2xmlout/pool-dir-naming.xml: Likewise. * tests/storagevolxml2xmlin/vol-file-naming.xml: Likewise. * tests/storagevolxml2xmlout/vol-file-naming.xml: Likewise. * tests/storagevolxml2xmlout/vol-*.xml: Fix fallout. Signed-off-by: Eric Blake <eblake@redhat.com>
2013-11-21 00:04:05 +00:00
<!-- directory pools allow almost any file name as a volume name -->
<data type='string'>
storage: use valid XML for awkward volume names $ touch /var/lib/libvirt/images/'a<b>c' $ virsh pool-refresh default $ virsh vol-dumpxml 'a<b>c' default | head -n2 <volume> <name>a<b>c</name> Oops. That's not valid XML. And when we fix the XML generation, it fails RelaxNG validation. I'm also tired of seeing <key>(null)</key> in the example output for volume xml; while we used NULLSTR() to avoid a NULL deref rather than relying on glibc's printf extension behavior, it's even better if we avoid the issue in the first place. But this requires being careful that we don't invalidate any storage backends that were relying on key being unassigned during virStoragVolCreateXML[From]. I would have split this into two patches (one for escaping, one for avoiding <key>(null)</key>), but since they both end up touching a lot of the same test files, I ended up merging it into one. Note that this patch allows pretty much any volume name that can appear in a directory (excluding . and .. because those are special), but does nothing to change the current (unenforced) RelaxNG claim that pool names will consist only of letters, numbers, _, -, and +. Tightening the C code to match RelaxNG patterns and/or relaxing the grammar to match the C code for pool names is a task for another day (but remember, we DID recently tighten C code for domain names to exclude a leading '.'). * src/conf/storage_conf.c (virStoragePoolSourceFormat) (virStoragePoolDefFormat, virStorageVolTargetDefFormat) (virStorageVolDefFormat): Escape user-controlled strings. (virStorageVolDefParseXML): Parse key, for use in unit tests. * src/storage/storage_driver.c (storageVolCreateXML) (storageVolCreateXMLFrom): Ensure parsed key doesn't confuse volume creation. * docs/schemas/basictypes.rng (volName): Relax definition. * tests/storagepoolxml2xmltest.c (mymain): Test it. * tests/storagevolxml2xmltest.c (mymain): Likewise. * tests/storagepoolxml2xmlin/pool-dir-naming.xml: New file. * tests/storagepoolxml2xmlout/pool-dir-naming.xml: Likewise. * tests/storagevolxml2xmlin/vol-file-naming.xml: Likewise. * tests/storagevolxml2xmlout/vol-file-naming.xml: Likewise. * tests/storagevolxml2xmlout/vol-*.xml: Fix fallout. Signed-off-by: Eric Blake <eblake@redhat.com>
2013-11-21 00:04:05 +00:00
<param name="pattern">[^/]+</param>
<except>
<choice>
<value>.</value>
<value>..</value>
</choice>
</except>
</data>
</define>
<define name='archnames'>
<choice>
<value>aarch64</value>
<value>alpha</value>
<value>armv7l</value>
<value>cris</value>
<value>i686</value>
<value>ia64</value>
<value>lm32</value>
<value>m68k</value>
<value>microblaze</value>
<value>microblazeel</value>
<value>mips</value>
<value>mipsel</value>
<value>mips64</value>
<value>mips64el</value>
<value>openrisc</value>
<value>parisc</value>
<value>parisc64</value>
<value>ppc</value>
<value>ppc64</value>
<value>ppcemb</value>
<value>s390</value>
<value>s390x</value>
<value>sh4</value>
<value>sh4eb</value>
<value>sparc</value>
<value>sparc64</value>
<value>unicore32</value>
<value>x86_64</value>
<value>xtensa</value>
<value>xtensaeb</value>
</choice>
</define>
<define name="PortNumber">
<data type="short">
<param name="minInclusive">-1</param>
</data>
</define>
<define name='sourceinfoadapter'>
<element name='adapter'>
<choice>
<group>
<!-- To keep back-compat, 'type' is not mandatory for
scsi_host adapter -->
<optional>
<attribute name='type'>
<value>scsi_host</value>
</attribute>
</optional>
<attribute name='name'>
<text/>
</attribute>
</group>
<group>
<attribute name='type'>
<value>fc_host</value>
</attribute>
<optional>
<attribute name='parent'>
<text/>
</attribute>
</optional>
<attribute name='wwnn'>
<ref name='wwn'/>
</attribute>
<attribute name='wwpn'>
<ref name='wwn'/>
</attribute>
</group>
</choice>
<empty/>
</element>
</define>
<define name="isaaddress">
<optional>
<attribute name="iobase">
<data type="string">
<param name="pattern">0x[a-fA-F0-9]{1,4}</param>
</data>
</attribute>
</optional>
<optional>
<attribute name="irq">
<data type="string">
<param name="pattern">0x[a-fA-F0-9]</param>
</data>
</attribute>
</optional>
</define>
</grammar>