<?xml version="1.0"?>
<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="storagecommon.rng"/>
  <include href="networkcommon.rng"/>
  <include href="cputypes.rng"/>
  <include href="nwfilter_params.rng"/>
  <include href="privatedata.rng"/>
  <include href="sysinfocommon.rng"/>

  <define name="createMode">
    <data type="unsignedInt">
      <param name="pattern">0[0-7]{3}|[0-7]{1,3}</param>
    </data>
  </define>

  <!--
      We handle only document defining a domain
    -->
  <define name="domain">
    <element name="domain">
      <ref name="domaincontents"/>
    </element>
  </define>

  <!-- this element is used as a child of a snapshot definition -->
  <define name="inactiveDomain">
    <element name="inactiveDomain">
      <ref name="domaincontents"/>
    </element>
  </define>

  <define name="domaincontents">
    <ref name="virttype"/>
    <optional>
      <attribute name="id">
        <ref name="unsignedInt"/>
      </attribute>
    </optional>
    <interleave>
      <element name="name">
        <ref name="objectNameWithSlash"/>
      </element>
      <optional>
        <element name="uuid">
          <ref name="UUID"/>
        </element>
      </optional>
      <optional>
        <element name="hwuuid">
          <ref name="UUID"/>
        </element>
      </optional>
      <optional>
        <element name="genid">
          <choice>
            <ref name="UUID"/>
            <empty/>
          </choice>
        </element>
      </optional>
      <optional>
        <ref name="title"/>
      </optional>
      <optional>
        <ref name="description"/>
      </optional>
      <optional>
        <ref name="metadata"/>
      </optional>
      <optional>
        <ref name="guestcpu"/>
      </optional>
      <zeroOrMore>
        <ref name="sysinfo"/>
      </zeroOrMore>
      <ref name="os"/>
      <ref name="clock"/>
      <ref name="throttlegroups"/>
      <ref name="resources"/>
      <ref name="features"/>
      <ref name="events"/>
      <optional>
        <ref name="pm"/>
      </optional>
      <optional>
        <ref name="perf"/>
      </optional>
      <optional>
        <ref name="idmap"/>
      </optional>
      <optional>
        <ref name="devices"/>
      </optional>
      <zeroOrMore>
        <ref name="seclabel"/>
      </zeroOrMore>
      <optional>
        <ref name="qemucmdline"/>
      </optional>
      <optional>
        <ref name="qemucapabilities"/>
      </optional>
      <optional>
        <ref name="qemudeprecation"/>
      </optional>
      <optional>
        <ref name="qemuoverride"/>
      </optional>
      <optional>
        <ref name="lxcsharens"/>
      </optional>
      <optional>
        <ref name="keywrap"/>
      </optional>
      <optional>
        <ref name="launchSecurity"/>
      </optional>
      <optional>
        <ref name="bhyvecmdline"/>
      </optional>
      <optional>
        <ref name="xencmdline"/>
      </optional>
      <optional>
        <ref name="vmwaredatacenterpath"/>
      </optional>
    </interleave>
  </define>

  <define name="seclabel">
    <element name="seclabel">
      <optional>
        <attribute name="model">
          <text/>
        </attribute>
      </optional>
      <choice>
        <group>
          <!-- with dynamic label (default), relabel must be yes, baselabel
               is optional, and label and imagelabel are output-only -->
          <optional>
            <attribute name="type">
              <value>dynamic</value>
            </attribute>
          </optional>
          <optional>
            <attribute name="relabel">
              <value>yes</value>
            </attribute>
          </optional>
          <interleave>
            <optional>
              <element name="label">
                <text/>
              </element>
            </optional>
            <optional>
              <element name="imagelabel">
                <text/>
              </element>
            </optional>
            <optional>
              <element name="baselabel">
                <text/>
              </element>
            </optional>
          </interleave>
        </group>
        <group>
          <!-- with static label, relabel can be either format (default
               no), label is required, imagelabel is output-only, and no
               baselabel is present -->
          <attribute name="type">
            <value>static</value>
          </attribute>
          <optional>
            <attribute name="relabel">
              <ref name="virYesNo"/>
            </attribute>
          </optional>
          <interleave>
            <element name="label">
              <text/>
            </element>
            <optional>
              <element name="imagelabel">
                <text/>
              </element>
            </optional>
          </interleave>
        </group>
        <group>
          <!-- with none, relabel must be no if present -->
          <attribute name="type">
            <value>none</value>
          </attribute>
          <optional>
            <attribute name="relabel">
              <value>no</value>
            </attribute>
          </optional>
        </group>
      </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="os">
    <choice>
      <ref name="osxen"/>
      <ref name="oshvm"/>
      <ref name="osexe"/>
    </choice>
  </define>

  <define name="osxen">
    <choice>
      <group>
        <interleave>
          <optional>
            <ref name="bootloader"/>
          </optional>
          <element name="os">
            <interleave>
              <ref name="ostypexen"/>
              <ref name="osbootkernel"/>
            </interleave>
          </element>
        </interleave>
      </group>
      <group>
        <interleave>
          <ref name="bootloader"/>
          <optional>
            <element name="os">
              <interleave>
                <ref name="ostypexen"/>
                <optional>
                  <ref name="osbootkernel"/>
                </optional>
              </interleave>
            </element>
          </optional>
        </interleave>
      </group>
    </choice>
  </define>

  <define name="oshvm">
    <interleave>
      <optional>
        <ref name="bootloader"/>
      </optional>
      <element name="os">
        <interleave>
          <optional>
            <attribute name="firmware">
              <choice>
                <value>bios</value>
                <value>efi</value>
              </choice>
            </attribute>
          </optional>
          <ref name="ostypehvm"/>
          <optional>
            <element name="firmware">
              <oneOrMore>
                <element name="feature">
                  <attribute name="enabled">
                    <ref name="virYesNo"/>
                  </attribute>
                  <attribute name="name">
                    <choice>
                      <value>enrolled-keys</value>
                      <value>secure-boot</value>
                    </choice>
                  </attribute>
                </element>
              </oneOrMore>
            </element>
          </optional>
          <optional>
            <element name="loader">
              <optional>
                <attribute name="readonly">
                  <ref name="virYesNo"/>
                </attribute>
              </optional>
              <optional>
                <attribute name="secure">
                  <ref name="virYesNo"/>
                </attribute>
              </optional>
              <optional>
                <attribute name="type">
                  <choice>
                    <value>rom</value>
                    <value>pflash</value>
                  </choice>
                </attribute>
              </optional>
              <optional>
                <attribute name="stateless">
                  <ref name="virYesNo"/>
                </attribute>
              </optional>
              <optional>
                <ref name="pflashFormat"/>
              </optional>
              <optional>
                <ref name="absFilePath"/>
              </optional>
            </element>
          </optional>
          <optional>
            <choice>
              <ref name="osnvram"/>
              <ref name="osvarstore"/>
            </choice>
          </optional>
          <optional>
            <ref name="osbootkernel"/>
          </optional>
          <zeroOrMore>
            <ref name="osbootdev"/>
          </zeroOrMore>
          <optional>
            <element name="bootmenu">
              <attribute name="enable">
                <ref name="virYesNo"/>
              </attribute>
              <optional>
                <attribute name="timeout">
                  <ref name="unsignedShort"/>
                </attribute>
              </optional>
            </element>
          </optional>
          <optional>
            <ref name="smbios"/>
          </optional>
          <optional>
            <ref name="bios"/>
          </optional>
          <optional>
            <ref name="acpiTable"/>
          </optional>
        </interleave>
      </element>
    </interleave>
  </define>

  <define name="ostypexen">
    <element name="type">
      <optional>
        <attribute name="arch">
          <choice>
            <value>i686</value>
            <value>x86_64</value>
            <value>ia64</value>
          </choice>
        </attribute>
      </optional>
      <optional>
        <attribute name="machine">
          <choice>
            <value>xenpv</value>
            <value>xenfv</value>
            <value>xenpvh</value>
          </choice>
        </attribute>
      </optional>
      <choice>
        <value>xen</value>
        <value>linux</value>
        <value>xenpvh</value>
      </choice>
    </element>
  </define>
  <define name="ostypehvm">
    <element name="type">
      <optional>
        <attribute name="arch">
          <ref name="archnames"/>
        </attribute>
      </optional>
      <optional>
        <attribute name="machine">
          <data type="string">
            <param name="pattern">[a-zA-Z0-9_\.\-]+</param>
          </data>
        </attribute>
      </optional>
      <value>hvm</value>
    </element>
  </define>

  <define name="osnvram">
    <element name="nvram">
      <optional>
        <attribute name="template">
          <ref name="absFilePath"/>
        </attribute>
      </optional>
      <optional>
        <attribute name="templateFormat">
          <ref name="pflashFormatTypes"/>
        </attribute>
      </optional>
      <optional>
        <ref name="pflashFormat"/>
      </optional>
      <optional>
        <choice>
          <group>
            <ref name="absFilePath"/>
          </group>
          <group>
            <ref name="diskSource"/>
          </group>
          <group>
            <ref name="vmwarePath"/>
          </group>
        </choice>
      </optional>
    </element>
  </define>

  <define name="osvarstore">
    <element name="varstore">
      <interleave>
        <optional>
          <attribute name="template">
            <ref name="absFilePath"/>
          </attribute>
        </optional>
        <optional>
          <attribute name="path">
            <ref name="absFilePath"/>
          </attribute>
        </optional>
      </interleave>
    </element>
  </define>

  <define name="osexe">
    <element name="os">
      <interleave>
        <element name="type">
          <optional>
            <attribute name="arch">
              <ref name="archnames"/>
            </attribute>
          </optional>
          <value>exe</value>
        </element>
        <optional>
          <element name="init">
            <ref name="absFilePath"/>
          </element>
        </optional>
        <zeroOrMore>
          <element name="initarg">
            <text/>
          </element>
        </zeroOrMore>
        <zeroOrMore>
          <element name="initenv">
            <attribute name="name">
              <data type="string">
                <param name="pattern">[a-zA-Z_]+[a-zA-Z0-9_]*</param>
              </data>
            </attribute>
            <text/>
          </element>
        </zeroOrMore>
        <optional>
          <element name="initdir">
            <ref name="absFilePath"/>
          </element>
        </optional>
        <optional>
          <interleave>
            <element name="inituser">
              <ref name="genericName"/>
            </element>
            <element name="initgroup">
              <ref name="genericName"/>
            </element>
          </interleave>
        </optional>
      </interleave>
    </element>
  </define>

  <define name="keywrap">
    <element name="keywrap">
      <oneOrMore>
        <element name="cipher">
          <attribute name="name">
            <choice>
              <value>aes</value>
              <value>dea</value>
            </choice>
          </attribute>
          <attribute name="state">
            <ref name="virOnOff"/>
          </attribute>
        </element>
      </oneOrMore>
    </element>
  </define>

  <define name="launchSecurity">
    <element name="launchSecurity">
      <choice>
        <group>
          <ref name="launchSecuritySEV"/>
        </group>
        <group>
          <ref name="launchSecuritySEVSNP"/>
        </group>
        <group>
          <attribute name="type">
            <value>s390-pv</value>
          </attribute>
        </group>
        <group>
          <ref name="launchSecurityTDX"/>
        </group>
      </choice>
    </element>
  </define>

  <define name="launchSecuritySEVCommon">
    <optional>
      <element name="cbitpos">
        <data type="unsignedInt"/>
      </element>
    </optional>
    <optional>
      <element name="reducedPhysBits">
        <data type="unsignedInt"/>
      </element>
    </optional>
  </define>

  <define name="launchSecuritySEV">
    <attribute name="type">
      <value>sev</value>
    </attribute>
    <optional>
      <attribute name="kernelHashes">
        <ref name="virYesNo"/>
      </attribute>
    </optional>
    <interleave>
      <ref name="launchSecuritySEVCommon"/>
      <element name="policy">
        <ref name="hexuint"/>
      </element>
      <optional>
        <element name="handle">
          <ref name="unsignedInt"/>
        </element>
      </optional>
      <optional>
        <element name="dhCert">
          <data type="string"/>
        </element>
      </optional>
      <optional>
        <element name="session">
          <data type="string"/>
        </element>
      </optional>
    </interleave>
  </define>

  <define name="launchSecuritySEVSNP">
    <attribute name="type">
      <value>sev-snp</value>
    </attribute>
    <optional>
      <attribute name="kernelHashes">
        <ref name="virYesNo"/>
      </attribute>
    </optional>
    <optional>
      <attribute name="authorKey">
        <ref name="virYesNo"/>
      </attribute>
    </optional>
    <optional>
      <attribute name="vcek">
        <ref name="virYesNo"/>
      </attribute>
    </optional>
    <interleave>
      <ref name="launchSecuritySEVCommon"/>
      <element name="policy">
        <ref name="hexuint"/>
      </element>
      <optional>
        <element name="guestVisibleWorkarounds">
          <data type="string"/>
        </element>
      </optional>
      <optional>
        <element name="idBlock">
          <data type="string"/>
        </element>
      </optional>
      <optional>
        <element name="idAuth">
          <data type="string"/>
        </element>
      </optional>
      <optional>
        <element name="hostData">
          <data type="string"/>
        </element>
      </optional>
    </interleave>
  </define>

  <define name="launchSecurityTDX">
    <attribute name="type">
      <value>tdx</value>
    </attribute>
    <interleave>
      <optional>
        <element name="policy">
          <ref name="hexuint"/>
        </element>
      </optional>
      <optional>
        <element name="mrConfigId">
          <data type="string"/>
        </element>
      </optional>
      <optional>
        <element name="mrOwner">
          <data type="string"/>
        </element>
      </optional>
      <optional>
        <element name="mrOwnerConfig">
          <data type="string"/>
        </element>
      </optional>
      <optional>
        <element name="quoteGenerationService">
          <optional>
            <attribute name="path">
              <ref name="absFilePath"/>
            </attribute>
          </optional>
        </element>
      </optional>
    </interleave>
  </define>

  <!--
      Enable or disable perf events for the domain. For each
      of the events the following rules apply:
      on: the event will be forcefully enabled
      off: the event will be forcefully disabled
      not specified: the event will be disabled by default
  -->
  <define name="perf">
    <element name="perf">
      <oneOrMore>
        <element name="event">
          <attribute name="name">
            <choice>
              <value>cmt</value>
              <value>mbmt</value>
              <value>mbml</value>
              <value>cpu_cycles</value>
              <value>instructions</value>
              <value>cache_references</value>
              <value>cache_misses</value>
              <value>branch_instructions</value>
              <value>branch_misses</value>
              <value>bus_cycles</value>
              <value>stalled_cycles_frontend</value>
              <value>stalled_cycles_backend</value>
              <value>ref_cpu_cycles</value>
              <value>cpu_clock</value>
              <value>task_clock</value>
              <value>page_faults</value>
              <value>context_switches</value>
              <value>cpu_migrations</value>
              <value>page_faults_min</value>
              <value>page_faults_maj</value>
              <value>alignment_faults</value>
              <value>emulation_faults</value>
            </choice>
          </attribute>
          <attribute name="enabled">
            <ref name="virYesNo"/>
          </attribute>
        </element>
      </oneOrMore>
    </element>
  </define>

  <define name="fibrechannel">
    <element name="fibrechannel">
      <attribute name="appid">
        <data type="string">
          <!-- All printable characters -->
          <param name="pattern">[&#x20;-&#x7E;]{1,128}</param>
        </data>
      </attribute>
    </element>
  </define>

  <define name="idmap">
    <element name="idmap">
      <interleave>
        <zeroOrMore>
          <element name="uid">
            <attribute name="start">
              <ref name="unsignedInt"/>
            </attribute>
            <attribute name="target">
              <ref name="unsignedInt"/>
            </attribute>
            <attribute name="count">
              <ref name="unsignedInt"/>
            </attribute>
            <empty/>
          </element>
        </zeroOrMore>
        <zeroOrMore>
          <element name="gid">
            <attribute name="start">
              <ref name="unsignedInt"/>
            </attribute>
            <attribute name="target">
              <ref name="unsignedInt"/>
            </attribute>
            <attribute name="count">
              <ref name="unsignedInt"/>
            </attribute>
            <empty/>
          </element>
        </zeroOrMore>
      </interleave>
    </element>
  </define>
  <!--
      Resources usage defines the amount of memory (maximum and possibly
      current usage) and number of virtual CPUs used by that domain.
      We can't check here the rule that currentMemory <= memory
    -->
  <define name="resources">
    <interleave>
      <optional>
        <element name="memory">
          <ref name="scaledInteger"/>
          <optional>
            <attribute name="dumpCore">
              <ref name="virOnOff"/>
            </attribute>
          </optional>
        </element>
      </optional>
      <optional>
        <element name="maxMemory">
          <ref name="scaledInteger"/>
          <optional>
            <attribute name="slots">
              <ref name="unsignedInt"/>
            </attribute>
          </optional>
        </element>
      </optional>
      <optional>
        <element name="currentMemory">
          <ref name="scaledInteger"/>
        </element>
      </optional>
      <optional>
        <element name="memoryBacking">
          <interleave>
            <optional>
              <element name="hugepages">
                <zeroOrMore>
                  <element name="page">
                    <attribute name="size">
                      <ref name="unsignedLong"/>
                    </attribute>
                    <optional>
                      <attribute name="unit">
                        <ref name="unit"/>
                      </attribute>
                    </optional>
                    <optional>
                      <attribute name="nodeset">
                        <ref name="cpuset"/>
                      </attribute>
                    </optional>
                    <empty/>
                  </element>
                </zeroOrMore>
              </element>
            </optional>
            <optional>
              <element name="nosharepages">
                <empty/>
              </element>
            </optional>
            <optional>
              <element name="locked">
                <empty/>
              </element>
            </optional>
            <optional>
              <element name="source">
                <attribute name="type">
                  <choice>
                    <value>file</value>
                    <value>anonymous</value>
                    <value>memfd</value>
                  </choice>
                </attribute>
              </element>
            </optional>
            <optional>
              <element name="access">
                <attribute name="mode">
                  <choice>
                    <value>shared</value>
                    <value>private</value>
                  </choice>
                </attribute>
              </element>
            </optional>
            <optional>
              <element name="allocation">
                <optional>
                  <attribute name="mode">
                    <choice>
                      <value>immediate</value>
                      <value>ondemand</value>
                    </choice>
                  </attribute>
                </optional>
                <optional>
                  <attribute name="threads">
                    <ref name="unsignedInt"/>
                  </attribute>
                </optional>
              </element>
            </optional>
            <optional>
              <element name="discard">
                <empty/>
              </element>
            </optional>
          </interleave>
        </element>
      </optional>

      <optional>
        <element name="vcpu">
          <optional>
            <attribute name="placement">
              <choice>
                <value>static</value>
                <value>auto</value>
              </choice>
            </attribute>
          </optional>
          <optional>
            <attribute name="cpuset">
              <ref name="cpuset"/>
            </attribute>
          </optional>
          <optional>
            <attribute name="current">
              <ref name="countCPU"/>
            </attribute>
          </optional>
          <ref name="countCPU"/>
        </element>
      </optional>

      <optional>
        <element name="vcpus">
          <zeroOrMore>
            <element name="vcpu">
              <attribute name="id">
                <ref name="unsignedInt"/>
              </attribute>
              <attribute name="enabled">
                <ref name="virYesNo"/>
              </attribute>
              <optional>
                <attribute name="hotpluggable">
                  <ref name="virYesNo"/>
                </attribute>
              </optional>
              <optional>
                <attribute name="order">
                  <ref name="unsignedInt"/>
                </attribute>
              </optional>
            </element>
          </zeroOrMore>
        </element>
      </optional>

      <optional>
        <element name="iothreads">
          <ref name="unsignedInt"/>
        </element>
      </optional>

      <optional>
        <element name="iothreadids">
          <zeroOrMore>
            <element name="iothread">
              <attribute name="id">
                <ref name="unsignedInt"/>
              </attribute>
              <optional>
                <attribute name="thread_pool_min">
                  <ref name="unsignedInt"/>
                </attribute>
              </optional>
              <optional>
                <attribute name="thread_pool_max">
                  <ref name="unsignedInt"/>
                </attribute>
              </optional>
              <optional>
                <element name="poll">
                  <optional>
                    <attribute name="max">
                      <ref name="unsignedLong"/>
                    </attribute>
                  </optional>
                  <optional>
                    <attribute name="grow">
                      <ref name="unsignedLong"/>
                    </attribute>
                  </optional>
                  <optional>
                    <attribute name="shrink">
                      <ref name="unsignedLong"/>
                    </attribute>
                  </optional>
                </element>
              </optional>
            </element>
          </zeroOrMore>
        </element>
      </optional>

      <optional>
        <element name="defaultiothread">
          <optional>
            <attribute name="thread_pool_min">
              <ref name="unsignedInt"/>
            </attribute>
          </optional>
          <optional>
            <attribute name="thread_pool_max">
              <ref name="unsignedInt"/>
            </attribute>
          </optional>
        </element>
      </optional>

      <optional>
        <ref name="blkiotune"/>
      </optional>

      <optional>
        <ref name="memtune"/>
      </optional>

      <optional>
        <ref name="cputune"/>
      </optional>

      <optional>
        <ref name="numatune"/>
      </optional>

      <optional>
        <ref name="iommufd"/>
      </optional>

      <optional>
        <ref name="respartition"/>
      </optional>
    </interleave>
  </define>

  <!-- The Blkio cgroup related tunables would go in the blkiotune -->
  <define name="blkiotune">
    <element name="blkiotune">
      <interleave>
        <!-- I/O weight the VM can use -->
        <optional>
          <element name="weight">
            <ref name="weight"/>
          </element>
        </optional>
        <zeroOrMore>
          <element name="device">
            <interleave>
              <element name="path">
                <choice>
                  <ref name="absFilePath"/>
                  <value>*</value>
                </choice>
              </element>
              <optional>
                <element name="weight">
                  <ref name="weight"/>
                </element>
              </optional>
              <optional>
                <element name="read_iops_sec">
                  <data type="unsignedInt"/>
                </element>
              </optional>
              <optional>
                <element name="write_iops_sec">
                  <data type="unsignedInt"/>
                </element>
              </optional>
              <optional>
                <element name="read_bytes_sec">
                  <data type="unsignedLong"/>
                </element>
              </optional>
              <optional>
                <element name="write_bytes_sec">
                  <data type="unsignedLong"/>
                </element>
              </optional>
            </interleave>
          </element>
        </zeroOrMore>
      </interleave>
    </element>
  </define>

  <!-- All the memory/swap related tunables would go in the memtune -->
  <define name="memtune">
    <element name="memtune">
      <interleave>
        <!-- Maximum memory the VM can use -->
        <optional>
          <element name="hard_limit">
            <ref name="scaledInteger"/>
          </element>
        </optional>
        <!-- Minimum memory ascertained for the VM during contention -->
        <optional>
          <element name="soft_limit">
            <ref name="scaledInteger"/>
          </element>
        </optional>
        <!-- Minimum amount of memory required to start the VM -->
        <optional>
          <element name="min_guarantee">
            <ref name="scaledInteger"/>
          </element>
        </optional>
        <!-- Maximum swap area the VM can use -->
        <optional>
          <element name="swap_hard_limit">
            <ref name="scaledInteger"/>
          </element>
        </optional>
      </interleave>
    </element>
  </define>

  <!-- All the cpu related tunables would go in the cputune -->
  <define name="cputune">
    <element name="cputune">
      <interleave>
        <optional>
          <element name="shares">
            <ref name="cpushares"/>
          </element>
        </optional>
        <optional>
          <element name="global_period">
            <ref name="cpuperiod"/>
          </element>
        </optional>
        <optional>
          <element name="global_quota">
            <ref name="cpuquota"/>
          </element>
        </optional>
        <optional>
          <element name="period">
            <ref name="cpuperiod"/>
          </element>
        </optional>
        <optional>
          <element name="quota">
            <ref name="cpuquota"/>
          </element>
        </optional>
        <optional>
          <element name="emulator_period">
            <ref name="cpuperiod"/>
          </element>
        </optional>
        <optional>
          <element name="emulator_quota">
            <ref name="cpuquota"/>
          </element>
        </optional>
        <optional>
          <element name="iothread_period">
            <ref name="cpuperiod"/>
          </element>
        </optional>
        <optional>
          <element name="iothread_quota">
            <ref name="cpuquota"/>
          </element>
        </optional>
        <zeroOrMore>
          <element name="vcpupin">
            <attribute name="vcpu">
              <ref name="vcpuid"/>
            </attribute>
            <attribute name="cpuset">
              <ref name="cpuset"/>
            </attribute>
          </element>
        </zeroOrMore>
        <optional>
          <element name="emulatorpin">
            <attribute name="cpuset">
              <ref name="cpuset"/>
            </attribute>
          </element>
        </optional>
        <zeroOrMore>
          <element name="iothreadpin">
            <attribute name="iothread">
              <ref name="unsignedInt"/>
            </attribute>
            <attribute name="cpuset">
              <ref name="cpuset"/>
            </attribute>
          </element>
        </zeroOrMore>
        <zeroOrMore>
          <element name="vcpusched">
            <optional>
              <attribute name="vcpus">
                <ref name="cpuset"/>
              </attribute>
            </optional>
            <ref name="schedparam"/>
          </element>
        </zeroOrMore>
        <zeroOrMore>
          <element name="iothreadsched">
            <optional>
              <attribute name="iothreads">
                <ref name="cpuset"/>
              </attribute>
            </optional>
            <ref name="schedparam"/>
          </element>
        </zeroOrMore>
        <optional>
          <element name="emulatorsched">
            <ref name="schedparam"/>
          </element>
        </optional>
        <zeroOrMore>
          <element name="cachetune">
            <attribute name="vcpus">
              <ref name="cpuset"/>
            </attribute>
            <optional>
              <attribute name="id">
                <data type="string"/>
              </attribute>
            </optional>
            <oneOrMore>
              <choice>
                <element name="cache">
                  <attribute name="id">
                    <ref name="unsignedInt"/>
                  </attribute>
                  <attribute name="level">
                    <ref name="unsignedInt"/>
                  </attribute>
                  <attribute name="type">
                    <choice>
                      <value>both</value>
                      <value>code</value>
                      <value>data</value>
                    </choice>
                  </attribute>
                  <attribute name="size">
                    <ref name="unsignedLong"/>
                  </attribute>
                  <optional>
                    <attribute name="unit">
                      <ref name="unit"/>
                    </attribute>
                  </optional>
                </element>
                <element name="monitor">
                  <attribute name="level">
                    <ref name="unsignedInt"/>
                  </attribute>
                  <attribute name="vcpus">
                    <ref name="cpuset"/>
                  </attribute>
                </element>
              </choice>
            </oneOrMore>
          </element>
        </zeroOrMore>
        <zeroOrMore>
          <element name="memorytune">
            <attribute name="vcpus">
              <ref name="cpuset"/>
            </attribute>
            <oneOrMore>
              <choice>
                <element name="node">
                  <attribute name="id">
                    <ref name="unsignedInt"/>
                  </attribute>
                  <attribute name="bandwidth">
                    <ref name="unsignedInt"/>
                  </attribute>
                </element>
                <element name="monitor">
                  <attribute name="vcpus">
                    <ref name="cpuset"/>
                  </attribute>
                </element>
              </choice>
            </oneOrMore>
          </element>
        </zeroOrMore>
        <zeroOrMore>
          <element name="energytune">
            <attribute name="vcpus">
              <ref name="cpuset"/>
            </attribute>
            <optional>
              <attribute name="id">
                <data type="string"/>
              </attribute>
            </optional>
            <oneOrMore>
              <element name="monitor">
                <attribute name="vcpus">
                  <ref name="cpuset"/>
                </attribute>
              </element>
            </oneOrMore>
          </element>
        </zeroOrMore>
      </interleave>
    </element>
  </define>

  <define name="schedparam">
    <choice>
      <group>
        <attribute name="scheduler">
          <choice>
            <value>batch</value>
            <value>idle</value>
          </choice>
        </attribute>
      </group>
      <group>
        <attribute name="scheduler">
          <choice>
            <value>fifo</value>
            <value>rr</value>
          </choice>
        </attribute>
        <attribute name="priority">
          <ref name="unsignedShort"/>
        </attribute>
      </group>
    </choice>
  </define>

  <!-- All the NUMA related tunables would go in the numatune -->
  <define name="numatune">
    <element name="numatune">
      <interleave>
        <optional>
          <element name="memory">
            <optional>
              <attribute name="mode">
                <choice>
                  <value>strict</value>
                  <value>preferred</value>
                  <value>interleave</value>
                  <value>restrictive</value>
                </choice>
              </attribute>
            </optional>
            <choice>
              <group>
                <optional>
                  <attribute name="placement">
                    <value>static</value>
                  </attribute>
                </optional>
                <optional>
                  <attribute name="nodeset">
                    <ref name="cpuset"/>
                  </attribute>
                </optional>
              </group>
              <attribute name="placement">
                <value>auto</value>
              </attribute>
            </choice>
          </element>
        </optional>
        <zeroOrMore>
          <element name="memnode">
            <attribute name="cellid">
              <ref name="unsignedInt"/>
            </attribute>
            <attribute name="mode">
              <choice>
                <value>strict</value>
                <value>preferred</value>
                <value>interleave</value>
                <value>restrictive</value>
              </choice>
            </attribute>
            <attribute name="nodeset">
              <ref name="cpuset"/>
            </attribute>
          </element>
        </zeroOrMore>
      </interleave>
    </element>
  </define>

  <define name="iommufd">
    <element name="iommufd">
      <attribute name="enabled">
        <ref name="virYesNo"/>
      </attribute>
      <optional>
        <attribute name="fdgroup"/>
      </optional>
    </element>
  </define>

  <define name="respartition">
    <element name="resource">
      <optional>
        <element name="partition">
          <ref name="absFilePath"/>
        </element>
      </optional>
      <optional>
        <ref name="fibrechannel"/>
      </optional>
    </element>
  </define>

  <define name="clock">
    <optional>
      <element name="clock">
        <choice>
          <group>
            <attribute name="offset">
              <choice>
                <value>localtime</value>
                <value>utc</value>
              </choice>
            </attribute>
            <optional>
              <attribute name="adjustment">
                <choice>
                  <ref name="timeDelta"/>
                  <value>reset</value>
                </choice>
              </attribute>
            </optional>
          </group>
          <group>
            <attribute name="offset">
              <value>timezone</value>
            </attribute>
            <optional>
              <attribute name="timezone">
                <ref name="timeZone"/>
              </attribute>
            </optional>
          </group>
          <group>
            <attribute name="offset">
              <value>variable</value>
            </attribute>
            <optional>
              <attribute name="adjustment">
                <ref name="timeDelta"/>
              </attribute>
            </optional>
            <optional>
              <attribute name="basis">
                <choice>
                  <value>utc</value>
                  <value>localtime</value>
                </choice>
              </attribute>
            </optional>
          </group>
          <group>
            <attribute name="offset">
              <value>absolute</value>
            </attribute>
            <attribute name="start">
              <ref name="unsignedLong"/>
            </attribute>
          </group>
        </choice>
        <zeroOrMore>
          <ref name="timer"/>
        </zeroOrMore>
      </element>
    </optional>
  </define>
  <define name="timer">
    <element name="timer">
      <choice>
        <group>
          <attribute name="name">
            <choice>
              <value>platform</value>
              <value>rtc</value>
            </choice>
          </attribute>
          <optional>
            <attribute name="track">
              <choice>
                <value>boot</value>
                <value>guest</value>
                <value>wall</value>
                <value>realtime</value>
              </choice>
            </attribute>
          </optional>
          <optional>
            <ref name="tickpolicy"/>
          </optional>
        </group>
        <group>
          <attribute name="name">
            <value>tsc</value>
          </attribute>
          <optional>
            <ref name="tickpolicy"/>
          </optional>
          <optional>
            <attribute name="frequency">
              <ref name="unsignedLong"/>
            </attribute>
          </optional>
          <optional>
            <attribute name="mode">
              <choice>
                <value>auto</value>
                <value>native</value>
                <value>emulate</value>
                <value>paravirt</value>
                <value>smpsafe</value>
              </choice>
            </attribute>
          </optional>
        </group>
        <group>
          <attribute name="name">
            <choice>
              <value>hpet</value>
              <value>pit</value>
              <value>armvtimer</value>
            </choice>
          </attribute>
          <optional>
            <ref name="tickpolicy"/>
          </optional>
        </group>
        <group>
          <attribute name="name">
            <choice>
              <value>kvmclock</value>
              <value>hypervclock</value>
            </choice>
          </attribute>
        </group>
      </choice>
      <optional>
        <attribute name="present">
          <ref name="virYesNo"/>
        </attribute>
      </optional>
      <empty/>
    </element>
  </define>

  <define name="tickpolicy">
    <choice>
      <group>
        <attribute name="tickpolicy">
          <choice>
            <value>delay</value>
            <value>merge</value>
            <value>discard</value>
          </choice>
        </attribute>
      </group>
      <group>
        <attribute name="tickpolicy">
          <value>catchup</value>
        </attribute>
        <optional>
          <element name="catchup">
            <optional>
              <attribute name="threshold">
                <ref name="unsignedInt"/>
              </attribute>
            </optional>
            <optional>
              <attribute name="slew">
                <ref name="unsignedInt"/>
              </attribute>
            </optional>
            <optional>
              <attribute name="limit">
                <ref name="unsignedInt"/>
              </attribute>
            </optional>
          </element>
        </optional>
      </group>
    </choice>
  </define>
<!--
      A bootloader may be used to extract the OS information instead of
      defining the OS parameter in the instance. It points just to the
      binary or script used to extract the data from the first disk device.
    -->
  <define name="bootloader">
    <interleave>
      <optional>
        <element name="bootloader">
          <choice>
            <text/>
            <empty/>
          </choice>
        </element>
      </optional>
      <optional>
        <element name="bootloader_args">
          <text/>
        </element>
      </optional>
    </interleave>
  </define>
  <define name="osbootkernel">
    <interleave>
      <optional>
        <element name="kernel">
          <ref name="absFilePath"/>
        </element>
      </optional>
      <optional>
        <element name="initrd">
          <ref name="absFilePath"/>
        </element>
      </optional>
      <optional>
        <element name="root">
          <ref name="absFilePath"/>
        </element>
      </optional>
      <optional>
        <element name="cmdline">
          <text/>
        </element>
      </optional>
      <optional>
        <element name="shim">
          <text/>
        </element>
      </optional>
      <optional>
        <element name="dtb">
          <ref name="absFilePath"/>
        </element>
      </optional>
    </interleave>
  </define>
  <define name="osbootdev">
    <element name="boot">
      <attribute name="dev">
        <choice>
          <value>hd</value>
          <value>fd</value>
          <value>cdrom</value>
          <value>network</value>
        </choice>
      </attribute>
      <empty/>
    </element>
  </define>
  <define name="diskspec">
    <interleave>
      <optional>
        <ref name="diskDriver"/>
      </optional>
      <optional>
        <ref name="diskMirror"/>
      </optional>
      <optional>
        <ref name="diskAuth"/>
      </optional>
      <ref name="diskTarget"/>
      <optional>
        <ref name="deviceBoot"/>
      </optional>
      <optional>
        <element name="backenddomain">
          <attribute name="name">
            <ref name="objectNameWithSlash"/>
          </attribute>
          <empty/>
        </element>
      </optional>
      <optional>
        <element name="readonly">
          <empty/>
        </element>
      </optional>
      <optional>
        <element name="shareable">
          <empty/>
        </element>
      </optional>
      <optional>
        <element name="transient">
          <optional>
            <attribute name="shareBacking">
              <ref name='virYesNo'/>
            </attribute>
          </optional>
          <empty/>
        </element>
      </optional>
      <optional>
        <element name="serial">
          <ref name="diskSerial"/>
        </element>
      </optional>
      <optional>
        <ref name="encryption"/>
      </optional>
      <optional>
        <choice>
          <ref name="throttlefilters"/>
          <ref name="diskIoTune"/>
        </choice>
      </optional>
      <optional>
        <ref name="alias"/>
      </optional>
      <optional>
        <ref name="acpi"/>
      </optional>
      <optional>
        <ref name="address"/>
      </optional>
      <optional>
        <ref name="geometry"/>
      </optional>
      <optional>
        <ref name="diskBlockIo"/>
      </optional>
      <optional>
        <element name="wwn">
          <ref name="wwn"/>
        </element>
      </optional>
      <optional>
        <element name="vendor">
          <data type="string">
            <!-- All printable characters -->
            <param name="pattern">[&#x20;-&#x7E;]{0,8}</param>
          </data>
        </element>
      </optional>
      <optional>
        <element name="product">
          <data type="string">
            <!-- All printable characters -->
            <param name="pattern">[&#x20;-&#x7E;]{0,40}</param>
          </data>
        </element>
      </optional>
    </interleave>
  </define>
  <define name="snapshot">
    <attribute name="snapshot">
      <choice>
        <value>no</value>
        <value>internal</value>
        <value>external</value>
        <value>manual</value>
      </choice>
    </attribute>
  </define>

  <define name="lease">
    <element name="lease">
      <interleave>
        <element name="lockspace">
          <text/>
        </element>
        <element name="key">
          <text/>
        </element>
        <element name="target">
          <attribute name="path">
            <text/>
          </attribute>
          <optional>
            <attribute name="offset">
              <ref name="unsignedInt"/>
            </attribute>
          </optional>
        </element>
      </interleave>
    </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

    -->
  <define name="disk">
    <element name="disk">
      <choice>
        <group>
          <optional>
            <attribute name="device">
              <choice>
                <value>floppy</value>
                <value>disk</value>
                <value>cdrom</value>
              </choice>
            </attribute>
          </optional>
          <interleave>
            <ref name="diskSource"/>
            <ref name="diskSpecsExtra"/>
          </interleave>
        </group>
        <group>
          <attribute name="device">
            <value>lun</value>
          </attribute>
          <optional>
            <ref name="rawIO"/>
          </optional>
          <optional>
            <ref name="sgIO"/>
          </optional>
          <interleave>
            <choice>
              <ref name="diskSourceNetwork"/>
              <ref name="diskSourceBlock"/>
              <ref name="diskSourceVolume"/>
            </choice>
            <ref name="diskSpecsExtra"/>
          </interleave>
        </group>
      </choice>
      <optional>
        <attribute name="model">
          <choice>
            <value>virtio</value>
            <value>virtio-transitional</value>
            <value>virtio-non-transitional</value>
            <value>usb-storage</value>
            <value>usb-bot</value>
          </choice>
        </attribute>
      </optional>
      <optional>
        <ref name="snapshot"/>
      </optional>
    </element>
  </define>

  <define name="diskSpecsExtra">
    <interleave>
      <ref name="storageSourceExtra"/>
      <ref name="diskBackingChain"/>
      <ref name="privateDataDeviceDisk"/>
    </interleave>
  </define>

  <define name="diskBackingChain">
    <choice>
      <ref name="diskBackingStore"/>
      <ref name="diskBackingStoreLast"/>
    </choice>
  </define>

  <define name="diskBackingStore">
    <element name="backingStore">
      <optional>
        <attribute name="index">
          <ref name="positiveInteger"/>
        </attribute>
      </optional>
      <interleave>
        <ref name="diskSource"/>
        <ref name="diskBackingChain"/>
        <ref name="diskFormat"/>
      </interleave>
    </element>
  </define>

  <define name="diskFormat">
    <element name="format">
      <attribute name="type">
        <ref name="storageFormat"/>
      </attribute>
      <optional>
        <element name="metadata_cache">
          <optional>
            <element name="max_size">
              <ref name="scaledInteger"/>
            </element>
          </optional>
        </element>
      </optional>
    </element>
  </define>

  <define name="diskBackingStoreLast">
    <optional>
      <element name="backingStore">
        <empty/>
      </element>
    </optional>
  </define>

  <define name="diskSourceSlice">
    <attribute name="offset">
      <ref name="unsignedInt"/>
    </attribute>
    <attribute name="size">
      <ref name="positiveInteger"/>
    </attribute>
  </define>

  <define name="diskSourceCommon">
    <optional>
      <attribute name="index">
        <ref name="positiveInteger"/>
      </attribute>
    </optional>
    <optional>
      <element name="slices">
        <element name="slice">
          <attribute name="type">
            <value>storage</value>
          </attribute>
          <ref name="diskSourceSlice"/>
        </element>
      </element>
    </optional>
    <optional>
      <element name="dataStore">
        <interleave>
          <ref name="diskFormat"/>
          <ref name="diskSource"/>
        </interleave>
      </element>
    </optional>

    <ref name="privateDataStorageSource"/>
  </define>

  <define name="diskSource">
    <choice>
      <ref name="diskSourceFile"/>
      <ref name="diskSourceBlock"/>
      <ref name="diskSourceDir"/>
      <ref name="diskSourceNetwork"/>
      <ref name="diskSourceVolume"/>
      <ref name="diskSourceNvme"/>
      <ref name="diskSourceVhostUser"/>
      <ref name="diskSourceVhostVdpa"/>
      <ref name="diskSourceCtl"/>
    </choice>
  </define>

  <define name="diskSourceFile">
    <optional>
      <attribute name="type">
        <value>file</value>
      </attribute>
    </optional>
    <optional>
      <element name="source">
        <interleave>
          <optional>
            <attribute name="file">
              <choice>
                <ref name="absFilePath"/>
                <ref name="vmwarePath"/>
              </choice>
            </attribute>
            <optional>
              <attribute name="fdgroup"/>
            </optional>
          </optional>
          <ref name="diskSourceCommon"/>
          <optional>
            <ref name="storageStartupPolicy"/>
          </optional>
          <optional>
            <ref name="encryption"/>
          </optional>
          <zeroOrMore>
            <ref name="devSeclabel"/>
          </zeroOrMore>
        </interleave>
      </element>
    </optional>
  </define>

  <define name="diskSourceBlock">
    <attribute name="type">
      <value>block</value>
    </attribute>
    <optional>
      <element name="source">
        <interleave>
          <optional>
            <attribute name="dev">
              <choice>
                <ref name="absFilePath"/>
                <ref name="deviceName"/>
              </choice>
            </attribute>
          </optional>
          <ref name="diskSourceCommon"/>
          <optional>
            <ref name="storageStartupPolicy"/>
          </optional>
          <optional>
            <ref name="encryption"/>
          </optional>
          <optional>
            <ref name="reservations"/>
          </optional>
          <zeroOrMore>
            <ref name="devSeclabel"/>
          </zeroOrMore>
        </interleave>
      </element>
    </optional>
  </define>

  <define name="diskSourceDir">
    <attribute name="type">
      <value>dir</value>
    </attribute>
    <optional>
      <element name="source">
        <interleave>
          <attribute name="dir">
            <ref name="absFilePath"/>
          </attribute>
          <ref name="diskSourceCommon"/>
          <optional>
            <ref name="storageStartupPolicy"/>
          </optional>
          <optional>
            <ref name="encryption"/>
          </optional>
          <empty/>
        </interleave>
      </element>
    </optional>
  </define>

  <define name="diskSourceNetworkHost">
    <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>
  </define>

  <define name="diskSourceNetworkNFS">
    <optional>
      <element name="identity">
        <optional>
          <attribute name="user">
            <ref name="genericName"/>
          </attribute>
        </optional>
        <optional>
          <attribute name="group">
            <ref name="genericName"/>
          </attribute>
        </optional>
      </element>
    </optional>
  </define>

  <define name="diskSourceNetworkProtocolRBD">
    <element name="source">
      <interleave>
        <attribute name="protocol">
          <value>rbd</value>
        </attribute>
        <ref name="diskSourceCommon"/>
        <optional>
          <attribute name="name"/>
        </optional>
        <zeroOrMore>
          <ref name="diskSourceNetworkHost"/>
        </zeroOrMore>
        <optional>
          <element name="snapshot">
            <attribute name="name">
              <ref name="genericName"/>
            </attribute>
            <empty/>
          </element>
        </optional>
        <optional>
          <element name="config">
            <attribute name="file">
              <ref name="absFilePath"/>
            </attribute>
            <empty/>
          </element>
        </optional>
        <optional>
          <ref name="diskAuth"/>
        </optional>
        <optional>
          <ref name="encryption"/>
        </optional>
        <empty/>
      </interleave>
    </element>
  </define>

  <define name="diskSourceNetworkProtocolISCSI">
    <element name="source">
      <attribute name="protocol">
        <value>iscsi</value>
      </attribute>
      <attribute name="name"/>
      <interleave>
        <ref name="diskSourceCommon"/>
        <ref name="diskSourceNetworkHost"/>
        <optional>
          <ref name="diskAuth"/>
        </optional>
        <optional>
          <ref name="encryption"/>
        </optional>
        <optional>
          <ref name="initiatorinfo"/>
        </optional>
      </interleave>
    </element>
  </define>

  <define name="diskSourceNetworkProtocolPropsCommon">
    <interleave>
      <optional>
        <element name="readahead">
          <attribute name="size">
            <ref name="positiveInteger"/>
          </attribute>
          <empty/>
        </element>
      </optional>
      <optional>
        <element name="timeout">
          <attribute name="seconds">
            <ref name="positiveInteger"/>
          </attribute>
          <empty/>
        </element>
      </optional>
    </interleave>
  </define>

  <define name="diskSourceNetworkProtocolSSLVerify">
    <element name="ssl">
      <attribute name="verify">
        <ref name="virYesNo"/>
      </attribute>
      <empty/>
    </element>
  </define>

  <define name="diskSourceNetworkProtocolHTTPCookies">
    <element name="cookies">
      <oneOrMore>
        <element name="cookie">
          <attribute name="name">
            <data type="string">
              <param name="pattern">[!#$%&amp;'*+\-.0-9A-Z\^_`a-z|~]+</param>
            </data>
          </attribute>
          <data type="string">
            <param name="pattern">"?[!#$%&amp;'()*+\-./0-9:&gt;=&lt;?@A-Z\^_`\[\]a-z|~]+"?</param>
          </data>
        </element>
      </oneOrMore>
      <empty/>
    </element>
  </define>

  <define name="diskSourceNetworkProtocolHTTPS">
    <element name="source">
      <interleave>
        <attribute name="protocol">
          <choice>
            <value>https</value>
          </choice>
        </attribute>
        <attribute name="name"/>
        <optional>
          <attribute name="query"/>
        </optional>
        <ref name="diskSourceCommon"/>
        <ref name="diskSourceNetworkHost"/>
        <optional>
          <ref name="encryption"/>
        </optional>
        <optional>
          <ref name="diskSourceNetworkProtocolSSLVerify"/>
        </optional>
        <optional>
          <ref name="diskSourceNetworkProtocolHTTPCookies"/>
        </optional>
        <ref name="diskSourceNetworkProtocolPropsCommon"/>
        <optional>
          <ref name="diskAuth"/>
        </optional>
      </interleave>
    </element>
  </define>

  <define name="diskSourceNetworkProtocolHTTP">
    <element name="source">
      <interleave>
        <attribute name="protocol">
          <choice>
            <value>http</value>
          </choice>
        </attribute>
        <attribute name="name"/>
        <optional>
          <attribute name="query"/>
        </optional>
        <ref name="diskSourceCommon"/>
        <ref name="diskSourceNetworkHost"/>
        <optional>
          <ref name="encryption"/>
        </optional>
        <optional>
          <ref name="diskSourceNetworkProtocolHTTPCookies"/>
        </optional>
        <ref name="diskSourceNetworkProtocolPropsCommon"/>
        <optional>
          <ref name="diskAuth"/>
        </optional>
      </interleave>
    </element>
  </define>

  <define name="diskSourceNetworkProtocolFTPS">
    <element name="source">
      <interleave>
        <attribute name="protocol">
          <choice>
            <value>ftps</value>
          </choice>
        </attribute>
        <attribute name="name"/>
        <ref name="diskSourceCommon"/>
        <ref name="diskSourceNetworkHost"/>
        <optional>
          <ref name="encryption"/>
        </optional>
        <optional>
          <ref name="diskSourceNetworkProtocolSSLVerify"/>
        </optional>
        <ref name="diskSourceNetworkProtocolPropsCommon"/>
        <optional>
          <ref name="diskAuth"/>
        </optional>
      </interleave>
    </element>
  </define>

  <define name="diskSourceNetworkProtocolFTP">
    <element name="source">
      <interleave>
        <attribute name="protocol">
          <choice>
            <value>ftp</value>
          </choice>
        </attribute>
        <attribute name="name"/>
        <ref name="diskSourceCommon"/>
        <ref name="diskSourceNetworkHost"/>
        <optional>
          <ref name="encryption"/>
        </optional>
        <ref name="diskSourceNetworkProtocolPropsCommon"/>
        <optional>
          <ref name="diskAuth"/>
        </optional>
      </interleave>
    </element>
  </define>

  <define name="diskSourceNetworkProtocolSSHHostVerify">
    <element name="knownHosts">
      <attribute name="path">
        <ref name="absFilePath"/>
      </attribute>
    </element>
  </define>

  <define name="diskSourceNetworkProtocolSSHKeyDef">
    <element name="identity">
      <interleave>
        <attribute name="username">
          <ref name="genericName"/>
        </attribute>
        <choice>
          <attribute name="keyfile">
            <ref name="absFilePath"/>
          </attribute>
          <attribute name="agentsock">
            <ref name="absFilePath"/>
          </attribute>
        </choice>
      </interleave>
    </element>
  </define>

  <define name="diskSourceNetworkProtocolSSH">
    <element name="source">
      <interleave>
        <attribute name="protocol">
          <choice>
            <value>ssh</value>
          </choice>
        </attribute>
        <attribute name="name"/>
        <ref name="diskSourceCommon"/>
        <ref name="diskSourceNetworkHost"/>
        <optional>
          <ref name="encryption"/>
        </optional>
        <ref name="diskSourceNetworkProtocolPropsCommon"/>
        <optional>
          <ref name="diskSourceNetworkProtocolSSHHostVerify"/>
        </optional>
        <optional>
          <choice>
            <ref name="diskSourceNetworkProtocolSSHKeyDef"/>
            <ref name="diskAuth"/>
          </choice>
        </optional>
      </interleave>
    </element>
  </define>

  <define name="diskSourceNetworkProtocolSimple">
    <element name="source">
      <interleave>
        <attribute name="protocol">
          <choice>
            <value>sheepdog</value>
            <value>tftp</value>
          </choice>
        </attribute>
        <attribute name="name"/>
        <ref name="diskSourceCommon"/>
        <ref name="diskSourceNetworkHost"/>
        <optional>
          <ref name="encryption"/>
        </optional>
        <ref name="diskSourceNetworkProtocolPropsCommon"/>
      </interleave>
    </element>
  </define>

  <define name="diskSourceNetworkProtocolNBD">
    <element name="source">
      <interleave>
        <attribute name="protocol">
          <value>nbd</value>
        </attribute>
        <optional>
          <attribute name="name"/>
        </optional>
        <optional>
          <attribute name="tls">
            <ref name="virYesNo"/>
          </attribute>
        </optional>
        <optional>
          <attribute name="tlsHostname"/>
        </optional>
        <ref name="diskSourceCommon"/>
        <ref name="diskSourceNetworkHost"/>
        <optional>
          <ref name="reconnect"/>
        </optional>
        <optional>
          <ref name="encryption"/>
        </optional>
      </interleave>
    </element>
  </define>

  <define name="diskSourceNetworkProtocolGluster">
    <element name="source">
      <interleave>
        <attribute name="protocol">
          <value>gluster</value>
        </attribute>
        <attribute name="name"/>
        <ref name="diskSourceCommon"/>
        <oneOrMore>
          <ref name="diskSourceNetworkHost"/>
        </oneOrMore>
        <optional>
          <ref name="encryption"/>
        </optional>
      </interleave>
    </element>
  </define>

  <define name="diskSourceNetworkProtocolVxHS">
    <element name="source">
      <interleave>
        <attribute name="protocol">
          <choice>
            <value>vxhs</value>
          </choice>
        </attribute>
        <attribute name="name"/>
        <ref name="diskSourceCommon"/>
        <optional>
          <attribute name="tls">
            <ref name="virYesNo"/>
          </attribute>
        </optional>
        <ref name="diskSourceNetworkHost"/>
      </interleave>
    </element>
  </define>

  <define name="diskSourceNetworkProtocolNFS">
    <element name="source">
      <interleave>
        <attribute name="protocol">
          <choice>
            <value>nfs</value>
          </choice>
        </attribute>
        <attribute name="name"/>
        <ref name="diskSourceCommon"/>
        <ref name="diskSourceNetworkHost"/>
        <ref name="diskSourceNetworkNFS"/>
      </interleave>
    </element>
  </define>

  <define name="diskSourceNetwork">
    <attribute name="type">
      <value>network</value>
    </attribute>
    <choice>
      <ref name="diskSourceNetworkProtocolNBD"/>
      <ref name="diskSourceNetworkProtocolGluster"/>
      <ref name="diskSourceNetworkProtocolRBD"/>
      <ref name="diskSourceNetworkProtocolISCSI"/>
      <ref name="diskSourceNetworkProtocolHTTP"/>
      <ref name="diskSourceNetworkProtocolHTTPS"/>
      <ref name="diskSourceNetworkProtocolFTPS"/>
      <ref name="diskSourceNetworkProtocolFTP"/>
      <ref name="diskSourceNetworkProtocolSSH"/>
      <ref name="diskSourceNetworkProtocolSimple"/>
      <ref name="diskSourceNetworkProtocolVxHS"/>
      <ref name="diskSourceNetworkProtocolNFS"/>
    </choice>
  </define>

  <define name="diskSourceVolume">
    <attribute name="type">
      <value>volume</value>
    </attribute>
    <optional>
      <element name="source">
        <interleave>
          <attribute name="pool">
            <ref name="objectName"/>
          </attribute>
          <attribute name="volume">
            <ref name="volName"/>
          </attribute>
          <optional>
            <attribute name="mode">
              <choice>
                <value>host</value>
                <value>direct</value>
              </choice>
            </attribute>
          </optional>
          <ref name="diskSourceCommon"/>
          <optional>
            <ref name="storageStartupPolicy"/>
          </optional>
          <optional>
            <ref name="encryption"/>
          </optional>
          <zeroOrMore>
            <ref name="devSeclabel"/>
          </zeroOrMore>
        </interleave>
      </element>
    </optional>
  </define>

  <define name="diskSourceNvme">
    <attribute name="type">
      <value>nvme</value>
    </attribute>
    <optional>
      <element name="source">
        <interleave>
          <attribute name="type">
            <value>pci</value>
          </attribute>
          <attribute name="namespace">
            <ref name="uint32"/>
          </attribute>
          <optional>
            <attribute name="managed">
              <ref name="virYesNo"/>
            </attribute>
          </optional>
          <element name="address">
            <ref name="pciaddress"/>
          </element>
          <ref name="diskSourceCommon"/>
          <optional>
            <ref name="storageStartupPolicy"/>
          </optional>
          <optional>
            <ref name="encryption"/>
          </optional>
        </interleave>
      </element>
    </optional>
  </define>

  <define name="diskSourceVhostUser">
    <attribute name="type">
      <value>vhostuser</value>
    </attribute>
    <element name="source">
      <attribute name="type">
        <value>unix</value>
      </attribute>
      <attribute name="path">
        <ref name="absFilePath"/>
      </attribute>
      <optional>
         <ref name="reconnect"/>
      </optional>
      <empty/>
    </element>
  </define>

  <define name="diskSourceVhostVdpa">
    <attribute name="type">
      <value>vhostvdpa</value>
    </attribute>
    <element name="source">
      <attribute name="dev">
        <ref name="absFilePath"/>
      </attribute>
      <empty/>
    </element>
  </define>

  <define name="diskSourceCtl">
    <attribute name="type">
      <value>ctl</value>
    </attribute>
    <element name="source">
      <attribute name="dev">
        <ref name="absFilePath"/>
      </attribute>
      <empty/>
    </element>
  </define>

  <define name="diskTargetDev">
    <choice>
      <data type="string">
        <param name="pattern">(ioemu:)?(fd|hd|sd|vd|xvd|ubd)[a-zA-Z0-9_]+</param>
      </data>
      <data type="string">
        <param name="pattern">nvme[0-9]+n[0-9]+(p[0-9]+)?</param>
      </data>
    </choice>
  </define>

  <define name="diskTarget">
    <element name="target">
      <attribute name="dev">
        <ref name="diskTargetDev"/>
      </attribute>
      <optional>
        <attribute name="bus">
          <choice>
            <value>ide</value>
            <value>fdc</value>
            <value>scsi</value>
            <value>virtio</value>
            <value>xen</value>
            <value>usb</value>
            <value>uml</value> <!-- NOT USED ANYMORE -->
            <value>sata</value>
            <value>sd</value>
            <value>nvme</value>
          </choice>
        </attribute>
      </optional>
      <optional>
        <attribute name="tray">
          <choice>
            <value>open</value>
            <value>closed</value>
          </choice>
        </attribute>
      </optional>
      <optional>
        <attribute name="removable">
          <ref name="virOnOff"/>
        </attribute>
      </optional>
      <optional>
        <attribute name="rotation_rate">
          <ref name="positiveInteger"/>
        </attribute>
      </optional>
      <optional>
        <attribute name="dpofua">
          <ref name="virOnOff"/>
        </attribute>
      </optional>
    </element>
  </define>
  <define name="geometry">
    <element name="geometry">
      <attribute name="cyls">
        <data type="integer"/>
      </attribute>
      <attribute name="heads">
        <data type="integer"/>
      </attribute>
      <attribute name="secs">
        <data type="integer"/>
      </attribute>
      <optional>
        <attribute name="trans">
          <choice>
            <value>auto</value>
            <value>none</value>
            <value>lba</value>
          </choice>
        </attribute>
      </optional>
    </element>
  </define>
  <define name="diskBlockIo">
    <element name="blockio">
      <optional>
        <attribute name="logical_block_size">
          <data type="integer"/>
        </attribute>
      </optional>
      <optional>
        <attribute name="physical_block_size">
          <data type="integer"/>
        </attribute>
      </optional>
      <optional>
        <attribute name="discard_granularity">
          <data type="integer"/>
        </attribute>
      </optional>
    </element>
  </define>

  <define name="iothreadMapping">
    <element name="iothreads">
      <oneOrMore>
        <element name="iothread">
          <attribute name="id">
            <ref name="unsignedInt"/>
          </attribute>
          <zeroOrMore>
            <element name="queue">
              <attribute name="id">
                <ref name="unsignedInt"/>
              </attribute>
            </element>
          </zeroOrMore>
        </element>
      </oneOrMore>
    </element>
  </define>

  <define name="diskDriver">
    <element name="driver">
      <optional>
        <ref name="driverFormat"/>
      </optional>
      <optional>
        <ref name="driverCache"/>
      </optional>
      <optional>
        <ref name="driverErrorPolicy"/>
      </optional>
      <optional>
        <ref name="driverRerrorPolicy"/>
      </optional>
      <optional>
        <ref name="driverIO"/>
      </optional>
      <optional>
        <ref name="ioeventfd"/>
      </optional>
      <optional>
        <ref name="event_idx"/>
      </optional>
      <optional>
        <ref name="copy_on_read"/>
      </optional>
      <optional>
        <ref name="discard"/>
      </optional>
      <optional>
        <ref name="driverIOThread"/>
      </optional>
      <optional>
        <ref name="detect_zeroes"/>
      </optional>
      <optional>
        <attribute name="discard_no_unref">
          <ref name="virOnOff"/>
        </attribute>
      </optional>
      <optional>
        <attribute name="queues">
          <ref name="positiveInteger"/>
        </attribute>
      </optional>
      <optional>
        <attribute name="queue_size">
          <ref name="positiveInteger"/>
        </attribute>
      </optional>
      <ref name="virtioOptions"/>
      <interleave>
        <optional>
          <element name="metadata_cache">
            <optional>
              <element name="max_size">
                <ref name="scaledInteger"/>
              </element>
            </optional>
          </element>
        </optional>
        <optional>
          <ref name="iothreadMapping"/>
        </optional>
        <optional>
          <element name="statistics">
            <interleave>
              <zeroOrMore>
                <element name="statistic">
                  <attribute name="interval">
                    <ref name="unsignedInt"/>
                  </attribute>
                </element>
              </zeroOrMore>
              <zeroOrMore>
                <element name="latency-histogram">
                  <optional>
                    <attribute name='type'>
                      <choice>
                        <value>read</value>
                        <value>write</value>
                        <value>zone</value>
                        <value>flush</value>
                      </choice>
                    </attribute>
                  </optional>
                  <oneOrMore>
                    <element name='bin'>
                      <attribute name='start'>
                        <ref name="unsignedInt"/>
                      </attribute>
                    </element>
                  </oneOrMore>
                </element>
              </zeroOrMore>
            </interleave>
          </element>
        </optional>
      </interleave>
    </element>
  </define>

  <define name="driverFormat">
    <optional>
      <attribute name="name">
        <ref name="genericName"/>
      </attribute>
    </optional>
    <optional>
      <attribute name="type">
        <choice>
          <ref name="storageFormat"/>
          <value>aio</value> <!-- back-compat for "raw" -->
        </choice>
      </attribute>
    </optional>
  </define>

  <define name="driverCache">
    <attribute name="cache">
      <choice>
        <value>default</value>
        <value>none</value>
        <value>writeback</value>
        <value>writethrough</value>
        <value>directsync</value>
        <value>unsafe</value>
      </choice>
    </attribute>
  </define>
  <define name="driverErrorPolicy">
    <attribute name="error_policy">
      <choice>
        <value>stop</value>
        <value>report</value>
        <value>ignore</value>
        <value>enospace</value>
      </choice>
    </attribute>
  </define>
  <define name="driverRerrorPolicy">
    <attribute name="rerror_policy">
      <choice>
        <value>stop</value>
        <value>report</value>
        <value>ignore</value>
      </choice>
    </attribute>
  </define>
  <define name="driverIO">
    <attribute name="io">
      <choice>
        <value>threads</value>
        <value>native</value>
        <value>io_uring</value>
      </choice>
    </attribute>
  </define>
  <define name="ioeventfd">
    <attribute name="ioeventfd">
      <ref name="virOnOff"/>
    </attribute>
  </define>
  <define name="event_idx">
    <attribute name="event_idx">
      <ref name="virOnOff"/>
    </attribute>
  </define>
  <define name="copy_on_read">
    <attribute name="copy_on_read">
      <ref name="virOnOff"/>
    </attribute>
  </define>
  <define name="discard">
    <attribute name="discard">
      <choice>
        <value>unmap</value>
        <value>ignore</value>
      </choice>
    </attribute>
  </define>
  <define name="driverIOThread">
    <attribute name="iothread">
      <ref name="unsignedInt"/>
    </attribute>
  </define>
  <define name="detect_zeroes">
    <attribute name="detect_zeroes">
      <choice>
        <value>off</value>
        <value>on</value>
        <value>unmap</value>
      </choice>
    </attribute>
  </define>
  <define name="controller">
    <element name="controller">
      <optional>
        <attribute name="index">
          <ref name="unsignedInt"/>
        </attribute>
      </optional>
      <interleave>
        <optional>
          <ref name="alias"/>
        </optional>
        <optional>
          <ref name="acpi"/>
        </optional>
        <optional>
          <ref name="address"/>
        </optional>
        <choice>
          <!-- fdc/sata/ccid have only the common attributes -->
          <group>
            <attribute name="type">
              <choice>
                <value>fdc</value>
                <value>sata</value>
                <value>ccid</value>
              </choice>
            </attribute>
          </group>
          <!-- scsi has an optional attribute "model" -->
          <group>
            <attribute name="type">
              <value>scsi</value>
            </attribute>
            <optional>
              <attribute name="model">
                <choice>
                  <value>auto</value>
                  <value>buslogic</value>
                  <value>lsilogic</value>
                  <value>lsisas1068</value>
                  <value>vmpvscsi</value>
                  <value>ibmvscsi</value>
                  <value>virtio-scsi</value>
                  <value>lsisas1078</value>
                  <value>virtio-transitional</value>
                  <value>virtio-non-transitional</value>
                  <value>ncr53c90</value>
                  <value>dc390</value>
                  <value>am53c974</value>
                </choice>
              </attribute>
            </optional>
          </group>
          <!-- usb has an optional attribute "model",
               and optional subelements "master" and "ports" -->
          <group>
            <attribute name="type">
              <value>usb</value>
            </attribute>
            <optional>
              <attribute name="model">
                <choice>
                  <value>piix3-uhci</value>
                  <value>piix4-uhci</value>
                  <value>ehci</value>
                  <value>ich9-ehci1</value>
                  <value>ich9-uhci1</value>
                  <value>ich9-uhci2</value>
                  <value>ich9-uhci3</value>
                  <value>vt82c686b-uhci</value>
                  <value>pci-ohci</value>
                  <value>nec-xhci</value>
                  <value>none</value>
                  <value>qusb1</value>
                  <value>qusb2</value>
                  <value>qemu-xhci</value>
                </choice>
              </attribute>
            </optional>
            <optional>
              <ref name="usbmaster"/>
            </optional>
            <optional>
              <attribute name="ports">
                <ref name="unsignedInt"/>
              </attribute>
            </optional>
          </group>
          <!-- ide has an optional attribute "model" -->
          <group>
            <attribute name="type">
              <value>ide</value>
            </attribute>
            <optional>
              <attribute name="model">
                <choice>
                  <value>piix3</value>
                  <value>piix4</value>
                  <value>ich6</value>
                </choice>
              </attribute>
            </optional>
          </group>
          <!-- isa -->
          <group>
            <attribute name="type">
              <value>isa</value>
            </attribute>
          </group>
          <!-- pci has an optional attribute "model" -->
          <group>
            <attribute name="type">
              <value>pci</value>
            </attribute>
            <interleave>
              <optional>
                <element name="model">
                  <attribute name="name">
                    <choice>
                      <!-- implementations of "pci-root" -->
                      <value>spapr-pci-host-bridge</value>
                      <!-- implementations of "pci-bridge" -->
                      <value>pci-bridge</value>
                      <!-- implementations of "dmi-to-pci-bridge" -->
                      <value>i82801b11-bridge</value>
                      <!-- implementations of "pcie-to-pci-bridge" -->
                      <value>pcie-pci-bridge</value>
                      <!-- implementations of "pcie-root-port" -->
                      <value>ioh3420</value>
                      <value>pcie-root-port</value>
                      <!-- implementations of "pcie-switch-upstream-port" -->
                      <value>x3130-upstream</value>
                      <!-- implementations of "pcie-switch-downstream-port" -->
                      <value>xio3130-downstream</value>
                      <!-- implementations of "pci-expander-bus" -->
                      <value>pxb</value>
                      <!-- implementations of "pcie-expander-bus" -->
                      <value>pxb-pcie</value>
                    </choice>
                  </attribute>
                  <empty/>
                </element>
              </optional>
              <optional>
                <element name="target">
                  <optional>
                    <attribute name="chassisNr">
                      <ref name="uint8"/>
                    </attribute>
                  </optional>
                  <optional>
                    <attribute name="chassis">
                      <ref name="uint8"/>
                    </attribute>
                  </optional>
                  <optional>
                    <attribute name="port">
                      <ref name="uint8"/>
                    </attribute>
                  </optional>
                  <optional>
                    <attribute name="busNr">
                      <ref name="uint8"/>
                    </attribute>
                  </optional>
                  <optional>
                    <attribute name="index">
                      <ref name="uint8"/>
                    </attribute>
                  </optional>
                  <optional>
                    <attribute name="hotplug">
                      <ref name="virOnOff"/>
                    </attribute>
                  </optional>
                  <optional>
                    <element name="node">
                      <ref name="unsignedInt"/>
                    </element>
                  </optional>
                  <optional>
                    <attribute name="memReserve">
                      <ref name="unsignedLong"/>
                    </attribute>
                  </optional>
                </element>
              </optional>
              <!-- *-root controllers have an optional element "pcihole64"-->
              <choice>
                <group>
                  <attribute name="model">
                    <choice>
                      <value>pci-root</value>
                      <value>pcie-root</value>
                    </choice>
                  </attribute>
                  <optional>
                    <element name="pcihole64">
                      <ref name="scaledInteger"/>
                    </element>
                  </optional>
                </group>
                <group>
                  <attribute name="model">
                    <choice>
                      <value>pci-bridge</value>
                      <value>dmi-to-pci-bridge</value>
                      <value>pcie-to-pci-bridge</value>
                      <value>pcie-root-port</value>
                      <value>pcie-switch-upstream-port</value>
                      <value>pcie-switch-downstream-port</value>
                      <value>pci-expander-bus</value>
                      <value>pcie-expander-bus</value>
                    </choice>
                  </attribute>
                </group>
              </choice>
            </interleave>
          </group>
          <!-- virtio-serial has optional "ports" and "vectors" -->
          <group>
            <attribute name="type">
              <value>virtio-serial</value>
            </attribute>
            <optional>
              <attribute name="model">
                <choice>
                  <value>virtio</value>
                  <value>virtio-transitional</value>
                  <value>virtio-non-transitional</value>
                </choice>
              </attribute>
            </optional>
            <optional>
              <attribute name="ports">
                <ref name="unsignedInt"/>
              </attribute>
            </optional>
            <optional>
              <attribute name="vectors">
                <ref name="unsignedInt"/>
              </attribute>
            </optional>
          </group>
          <!-- xenbus has an optional attribute "maxGrantFrames" -->
          <group>
            <attribute name="type">
              <value>xenbus</value>
            </attribute>
            <optional>
              <attribute name="maxGrantFrames">
                <ref name="unsignedInt"/>
              </attribute>
            </optional>
            <optional>
              <attribute name="maxEventChannels">
                <ref name="unsignedInt"/>
              </attribute>
            </optional>
          </group>
          <group>
            <attribute name="type">
              <value>nvme</value>
            </attribute>
            <optional>
              <element name="serial">
                <ref name="diskSerial"/>
              </element>
            </optional>
          </group>
        </choice>
        <optional>
          <element name="driver">
            <optional>
              <attribute name="queues">
                <ref name="unsignedInt"/>
              </attribute>
            </optional>
            <optional>
              <attribute name="cmd_per_lun">
                <ref name="unsignedInt"/>
              </attribute>
            </optional>
            <optional>
              <attribute name="max_sectors">
                <ref name="unsignedInt"/>
              </attribute>
            </optional>
            <optional>
              <ref name="ioeventfd"/>
            </optional>
            <optional>
              <ref name="driverIOThread"/>
            </optional>
            <optional>
              <ref name="iothreadMapping"/>
            </optional>
            <ref name="virtioOptions"/>
          </element>
        </optional>
      </interleave>
    </element>
  </define>

  <define name="filesystemCommon">
    <interleave>
      <element name="target">
        <attribute name="dir"/>
        <empty/>
      </element>
      <optional>
        <attribute name="accessmode">
          <choice>
            <value>passthrough</value>
            <value>mapped</value>
            <value>squash</value>
          </choice>
        </attribute>
      </optional>
      <optional>
        <attribute name="multidevs">
          <choice>
            <value>default</value>
            <value>remap</value>
            <value>forbid</value>
            <value>warn</value>
          </choice>
        </attribute>
      </optional>
      <optional>
        <attribute name="fmode">
          <ref name="createMode"/>
        </attribute>
      </optional>
      <optional>
        <attribute name="dmode">
          <ref name="createMode"/>
        </attribute>
      </optional>
      <optional>
        <element name="readonly">
          <empty/>
        </element>
      </optional>
      <optional>
        <ref name="deviceBoot"/>
      </optional>
      <optional>
        <ref name="alias"/>
      </optional>
      <optional>
        <ref name="acpi"/>
      </optional>
      <optional>
        <ref name="address"/>
      </optional>
      <optional>
        <element name="space_hard_limit">
          <ref name="scaledInteger"/>
        </element>
      </optional>
      <optional>
        <element name="space_soft_limit">
          <ref name="scaledInteger"/>
        </element>
      </optional>
    </interleave>
  </define>

  <define name="filesystem">
    <element name="filesystem">
      <optional>
        <attribute name="model">
          <choice>
            <value>virtio</value>
            <value>virtio-transitional</value>
            <value>virtio-non-transitional</value>
          </choice>
        </attribute>
      </optional>
      <choice>
        <group>
          <attribute name="type">
            <value>file</value>
          </attribute>
          <interleave>
            <optional>
              <ref name="fsDriver"/>
            </optional>
            <element name="source">
              <attribute name="file">
                <ref name="absFilePath"/>
              </attribute>
              <empty/>
            </element>
            <ref name="filesystemCommon"/>
          </interleave>
        </group>
        <group>
          <attribute name="type">
            <value>block</value>
          </attribute>
          <interleave>
            <optional>
              <ref name="fsDriver"/>
            </optional>
            <element name="source">
              <attribute name="dev">
                <ref name="absFilePath"/>
              </attribute>
              <empty/>
            </element>
            <ref name="filesystemCommon"/>
          </interleave>
        </group>
        <group>
          <!-- type="mount" is default -->
          <optional>
            <attribute name="type">
              <value>mount</value>
            </attribute>
          </optional>
          <interleave>
            <optional>
              <ref name="fsDriver"/>
            </optional>
            <optional>
              <ref name="fsBinary"/>
            </optional>
            <element name="source">
              <choice>
                <group>
                  <attribute name="dir">
                    <ref name="absDirPath"/>
                  </attribute>
                </group>
                <group>
                  <attribute name="socket">
                    <ref name="absFilePath"/>
                  </attribute>
                </group>
              </choice>
              <empty/>
            </element>
            <optional>
              <ref name="idmap"/>
            </optional>
            <ref name="filesystemCommon"/>
          </interleave>
        </group>
        <group>
          <optional>
            <attribute name="type">
              <value>bind</value>
            </attribute>
          </optional>
          <interleave>
            <optional>
              <ref name="fsDriver"/>
            </optional>
            <element name="source">
              <attribute name="dir">
                <ref name="absDirPath"/>
              </attribute>
              <empty/>
            </element>
            <ref name="filesystemCommon"/>
          </interleave>
        </group>
        <group>
          <attribute name="type">
            <value>template</value>
          </attribute>
          <interleave>
            <optional>
              <ref name="fsDriver"/>
            </optional>
            <element name="source">
              <attribute name="name">
                <ref name="genericName"/>
              </attribute>
              <empty/>
            </element>
            <ref name="filesystemCommon"/>
          </interleave>
        </group>
        <group>
          <attribute name="type">
            <value>ram</value>
          </attribute>
          <interleave>
            <optional>
              <ref name="fsDriver"/>
            </optional>
            <element name="source">
              <attribute name="usage">
                <ref name="unsignedLong"/>
              </attribute>
              <optional>
                <attribute name="units">
                  <ref name="unit"/>
                </attribute>
              </optional>
              <empty/>
            </element>
            <ref name="filesystemCommon"/>
          </interleave>
        </group>
      </choice>
    </element>
  </define>

  <define name="fsDriver">
    <element name="driver">
      <!-- Annoying inconsistency. "disk" uses "name"
           for this kind of info, and "type" for the
           storage format. We need the latter too, so
           had to invent a new attribute name -->
      <choice>
        <group>
          <optional>
            <attribute name="type">
              <choice>
                <value>path</value>
                <value>handle</value>
                <value>loop</value>
                <value>nbd</value>
                <value>ploop</value>
              </choice>
            </attribute>
          </optional>
          <optional>
            <attribute name="format">
              <ref name="storageFormat"/>
            </attribute>
          </optional>
          <optional>
            <attribute name="wrpolicy">
              <value>immediate</value>
            </attribute>
          </optional>
          <ref name="virtioOptions"/>
        </group>
        <group>
          <attribute name="type">
            <value>virtiofs</value>
          </attribute>
          <optional>
            <attribute name="queue">
              <ref name="unsignedInt"/>
            </attribute>
          </optional>
          <ref name="virtioOptions"/>
        </group>
        <group>
          <attribute name="type">
            <value>mtp</value>
          </attribute>
        </group>
        <empty/>
      </choice>
    </element>
  </define>
  <define name="fsBinary">
    <element name="binary">
      <optional>
        <attribute name="path">
          <ref name="absFilePath"/>
        </attribute>
      </optional>
      <optional>
        <attribute name="xattr">
          <ref name="virOnOff"/>
        </attribute>
      </optional>
      <interleave>
        <optional>
          <element name="cache">
            <optional>
              <attribute name="mode">
                <choice>
                  <value>none</value>
                  <value>always</value>
                </choice>
              </attribute>
            </optional>
          </element>
        </optional>
        <optional>
          <element name="sandbox">
            <optional>
              <attribute name="mode">
                <choice>
                  <value>namespace</value>
                  <value>chroot</value>
                </choice>
              </attribute>
            </optional>
          </element>
        </optional>
        <optional>
          <element name="lock">
            <optional>
              <attribute name="posix">
                <ref name="virOnOff"/>
              </attribute>
            </optional>
            <optional>
              <attribute name="flock">
                <ref name="virOnOff"/>
              </attribute>
            </optional>
          </element>
        </optional>
        <optional>
          <element name="thread_pool">
            <optional>
              <attribute name="size">
                <data type="integer"/>
              </attribute>
            </optional>
          </element>
        </optional>
        <optional>
          <element name="openfiles">
            <optional>
              <attribute name="max">
                <data type="positiveInteger"/>
              </attribute>
            </optional>
          </element>
        </optional>
      </interleave>
    </element>
  </define>

  <define name="interface-network-attributes">
    <attribute name="network">
      <text/>
    </attribute>
    <optional>
      <attribute name="portgroup">
        <ref name="deviceName"/>
      </attribute>
    </optional>
    <optional>
      <attribute name="portid">
        <ref name="UUID"/>
      </attribute>
    </optional>
  </define>

  <define name="interface-bridge-attributes">
    <attribute name="bridge">
      <data type="string">
        <param name="pattern">[a-zA-Z0-9_\.\-\\:/ ]*</param>
      </data>
    </attribute>
    <optional>
      <attribute name="macTableManager">
        <ref name="macTableManager"/>
      </attribute>
    </optional>
  </define>

  <!--
      An interface description can either be of type bridge in which case
      it will use a bridging source, or of type ethernet which uses a device
      source and a device target instead. They both share a set of interface
      options. FIXME
    -->
  <define name="interface">
    <element name="interface">
      <choice>
        <group>
          <attribute name="type">
            <value>bridge</value>
          </attribute>
          <interleave>
            <optional>
              <element name="source">
                <ref name="interface-bridge-attributes"/>
                <optional>
                  <ref name="interface-network-attributes"/>
                </optional>
                <empty/>
              </element>
            </optional>
            <optional>
              <ref name="virtualPortProfile"/>
            </optional>
            <ref name="interface-options"/>
          </interleave>
        </group>
        <group>
          <attribute name="type">
            <value>ethernet</value>
          </attribute>
          <interleave>
            <optional>
              <element name="source">
                <ref name="interface-ip-info"/>
              </element>
            </optional>
            <ref name="interface-options"/>
          </interleave>
        </group>
        <group>
          <attribute name="type">
            <value>vhostuser</value>
          </attribute>
          <interleave>
            <optional>
              <element name="source">
                <optional>
                  <attribute name="type">
                    <value>unix</value>
                  </attribute>
                </optional>
                <optional>
                  <attribute name="path">
                    <ref name="absFilePath"/>
                  </attribute>
                </optional>
                <optional>
                  <attribute name="mode">
                    <choice>
                      <value>server</value>
                      <value>client</value>
                    </choice>
                  </attribute>
                </optional>
                <optional>
                  <attribute name="dev">
                    <ref name="deviceName"/>
                  </attribute>
                </optional>
                <optional>
                  <ref name="reconnect"/>
                </optional>
                <empty/>
              </element>
             </optional>
            <ref name="interface-options"/>
          </interleave>
        </group>
        <group>
          <attribute name="type">
            <value>network</value>
          </attribute>
          <interleave>
            <element name="source">
              <ref name="interface-network-attributes"/>
              <optional>
                <ref name="interface-bridge-attributes"/>
              </optional>
              <empty/>
            </element>
            <optional>
              <ref name="virtualPortProfile"/>
            </optional>
            <ref name="interface-options"/>
          </interleave>
        </group>
        <group>
          <attribute name="type">
            <value>direct</value>
          </attribute>
          <interleave>
            <element name="source">
              <attribute name="dev">
                <ref name="deviceName"/>
              </attribute>
              <optional>
                <attribute name="mode">
                  <ref name="bridgeMode"/>
                </attribute>
              </optional>
              <optional>
                <ref name="interface-network-attributes"/>
              </optional>
              <empty/>
            </element>
            <optional>
              <ref name="virtualPortProfile"/>
            </optional>
            <ref name="interface-options"/>
          </interleave>
        </group>
        <group>
          <attribute name="type">
            <value>user</value>
          </attribute>
          <interleave>
            <optional>
              <element name="source">
                <attribute name="dev">
                  <ref name="deviceName"/>
                </attribute>
                <empty/>
              </element>
            </optional>
            <ref name="interface-options"/>
          </interleave>
        </group>
        <group>
          <attribute name="type">
            <value>internal</value>
          </attribute>
          <interleave>
            <element name="source">
              <attribute name="name">
                <ref name="deviceName"/>
              </attribute>
              <empty/>
            </element>
            <ref name="interface-options"/>
          </interleave>
        </group>
        <group>
          <attribute name="type">
            <choice>
              <value>mcast</value>
              <value>client</value>
            </choice>
          </attribute>
          <interleave>
            <element name="source">
              <attribute name="address">
                <ref name="ipv4Addr"/>
              </attribute>
              <attribute name="port">
                <ref name="PortNumber"/>
              </attribute>
              <empty/>
            </element>
            <ref name="interface-options"/>
          </interleave>
        </group>
        <group>
          <attribute name="type">
            <value>udp</value>
          </attribute>
          <interleave>
            <element name="source">
              <attribute name="address">
                <ref name="ipv4Addr"/>
              </attribute>
              <attribute name="port">
                <ref name="PortNumber"/>
              </attribute>
              <element name="local">
                <attribute name="address">
                  <ref name="ipv4Addr"/>
                </attribute>
                <attribute name="port">
                  <ref name="PortNumber"/>
                </attribute>
                <empty/>
              </element>
            </element>
            <ref name="interface-options"/>
          </interleave>
        </group>
        <group>
          <attribute name="type">
            <value>server</value>
          </attribute>
          <interleave>
            <element name="source">
              <optional>
                <attribute name="address">
                  <ref name="ipv4Addr"/>
                </attribute>
              </optional>
              <attribute name="port">
                <ref name="PortNumber"/>
              </attribute>
              <empty/>
            </element>
            <ref name="interface-options"/>
          </interleave>
        </group>
        <group>
          <attribute name="type">
            <value>hostdev</value>
          </attribute>
          <optional>
            <attribute name="managed">
              <ref name="virYesNo"/>
            </attribute>
          </optional>
          <interleave>
            <element name="source">
              <optional>
                <attribute name="missing">
                  <ref name="virYesNo"/>
                </attribute>
              </optional>
              <choice>
                <group>
                  <ref name="usbproduct"/>
                  <optional>
                    <ref name="usbaddress"/>
                  </optional>
                </group>
                <element name="address">
                  <choice>
                    <group>
                      <attribute name="type">
                        <value>pci</value>
                      </attribute>
                      <ref name="pciaddress"/>
                    </group>
                    <group>
                      <attribute name="type">
                        <value>usb</value>
                      </attribute>
                      <attribute name="bus">
                        <ref name="usbAddr"/>
                      </attribute>
                      <attribute name="device">
                        <ref name="usbAddr"/>
                      </attribute>
                    </group>
                  </choice>
                </element>
              </choice>
            </element>
            <optional>
              <ref name="virtualPortProfile"/>
            </optional>
            <ref name="interface-options"/>
          </interleave>
        </group>

        <group>
          <attribute name="type">
            <value>vdpa</value>
          </attribute>
          <interleave>
            <element name="source">
              <attribute name="dev">
                <ref name="deviceName"/>
              </attribute>
            </element>
            <ref name="interface-options"/>
          </interleave>
        </group>

        <group>
          <attribute name="type">
            <value>null</value>
          </attribute>
          <ref name="interface-options"/>
        </group>

        <group>
          <attribute name="type">
            <value>vds</value>
          </attribute>
          <interleave>
            <element name="source">
              <attribute name="switchid">
                <ref name="UUID"/>
              </attribute>
              <optional>
                <attribute name="portid">
                  <data type="long"/>
                </attribute>
              </optional>
              <optional>
                <attribute name="portgroupid">
                  <data type="string"/>
                </attribute>
              </optional>
              <optional>
                <attribute name="connectionid">
                  <data type="long"/>
                </attribute>
              </optional>
            </element>
            <ref name="interface-options"/>
          </interleave>
        </group>

      </choice>
      <optional>
        <attribute name="trustGuestRxFilters">
          <ref name="virYesNo"/>
        </attribute>
      </optional>
    </element>
  </define>
  <!--
      The interface options possible are:
        - the MAC address
        - the IP address bound to the interface
        - the name of the script used to set up the binding
        - the target device used
        - boot order
        - link state
    -->
  <define name="interface-options">
    <interleave>
      <optional>
        <element name="link">
          <attribute name="state">
            <choice>
              <value>up</value>
              <value>down</value>
            </choice>
          </attribute>
          <empty/>
        </element>
      </optional>
      <optional>
        <ref name="mtu"/>
      </optional>
      <optional>
        <ref name="coalesce"/>
      </optional>
      <optional>
        <element name="target">
          <attribute name="dev">
            <ref name="deviceName"/>
          </attribute>
          <optional>
            <attribute name="managed">
              <ref name="virYesNo"/>
            </attribute>
          </optional>
          <empty/>
        </element>
      </optional>
      <optional>
        <element name="guest">
          <interleave>
            <optional>
              <attribute name="dev">
                <ref name="deviceName"/>
              </attribute>
            </optional>
            <optional>
              <attribute name="actual">
                <ref name="deviceName"/>
              </attribute>
            </optional>
          </interleave>
          <empty/>
        </element>
      </optional>
      <optional>
        <element name="mac">
          <attribute name="address">
            <ref name="uniMacAddr"/>
          </attribute>
          <optional>
            <attribute name="type">
              <choice>
                <value>generated</value>
                <value>static</value>
              </choice>
            </attribute>
          </optional>
          <optional>
            <attribute name="check">
              <ref name="virYesNo"/>
            </attribute>
          </optional>
          <optional>
            <attribute name="currentAddress">
              <ref name="uniMacAddr"/>
            </attribute>
          </optional>
          <empty/>
        </element>
      </optional>
      <ref name="interface-ip-info"/>
      <ref name="interface-port-forwards"/>
      <optional>
        <element name="script">
          <attribute name="path">
            <ref name="filePath"/>
          </attribute>
          <empty/>
        </element>
      </optional>
      <optional>
        <element name="downscript">
          <attribute name="path">
            <ref name="filePath"/>
          </attribute>
          <empty/>
        </element>
      </optional>
      <optional>
        <element name="backenddomain">
          <attribute name="name">
            <ref name="objectNameWithSlash"/>
          </attribute>
          <empty/>
        </element>
      </optional>
      <optional>
        <element name="model">
          <attribute name="type">
            <data type="string">
              <param name="pattern">[a-zA-Z0-9\-_]+</param>
            </data>
          </attribute>
          <empty/>
        </element>
      </optional>
      <optional>
        <element name="backend">
          <optional>
            <attribute name="type">
              <choice>
                <value>default</value>
                <value>passt</value>
              </choice>
            </attribute>
          </optional>
          <optional>
            <attribute name="tap">
              <ref name="absFilePath"/>
            </attribute>
          </optional>
          <optional>
            <attribute name="vhost">
              <ref name="absFilePath"/>
            </attribute>
          </optional>
          <optional>
            <attribute name="logFile">
              <ref name="absFilePath"/>
            </attribute>
          </optional>
          <optional>
            <attribute name="hostname">
              <ref name="dnsName"/>
            </attribute>
          </optional>
          <optional>
            <attribute name="fqdn">
              <ref name="dnsName"/>
            </attribute>
          </optional>
        </element>
      </optional>
      <optional>
        <choice>
          <group>
            <ref name="hostdevDriver"/>
          </group>
          <group>
            <element name="driver">
              <optional>
                <attribute name="name">
                  <choice>
                    <value>qemu</value>
                    <value>vhost</value>
                  </choice>
                </attribute>
              </optional>
              <optional>
                <attribute name="queues">
                  <ref name="positiveInteger"/>
                </attribute>
              </optional>
              <optional>
                <attribute name="rx_queue_size">
                  <ref name="positiveInteger"/>
                </attribute>
              </optional>
              <optional>
                <attribute name="tx_queue_size">
                  <ref name="positiveInteger"/>
                </attribute>
              </optional>
              <optional>
                <attribute name="txmode">
                  <choice>
                    <value>iothread</value>
                    <value>timer</value>
                  </choice>
                </attribute>
              </optional>
              <optional>
                <ref name="ioeventfd"/>
              </optional>
              <optional>
                <ref name="event_idx"/>
              </optional>
              <ref name="virtioOptions"/>
              <interleave>
                <optional>
                  <element name="host">
                    <optional>
                      <attribute name="csum">
                        <ref name="virOnOff"/>
                      </attribute>
                    </optional>
                    <optional>
                      <attribute name="gso">
                        <ref name="virOnOff"/>
                      </attribute>
                    </optional>
                    <optional>
                      <attribute name="tso4">
                        <ref name="virOnOff"/>
                      </attribute>
                    </optional>
                    <optional>
                      <attribute name="tso6">
                        <ref name="virOnOff"/>
                      </attribute>
                    </optional>
                    <optional>
                      <attribute name="ecn">
                        <ref name="virOnOff"/>
                      </attribute>
                    </optional>
                    <optional>
                      <attribute name="ufo">
                        <ref name="virOnOff"/>
                      </attribute>
                    </optional>
                    <optional>
                      <attribute name="mrg_rxbuf">
                        <ref name="virOnOff"/>
                      </attribute>
                    </optional>
                  </element>
                </optional>
                <optional>
                  <element name="guest">
                    <optional>
                      <attribute name="csum">
                        <ref name="virOnOff"/>
                      </attribute>
                    </optional>
                    <optional>
                      <attribute name="tso4">
                        <ref name="virOnOff"/>
                      </attribute>
                    </optional>
                    <optional>
                      <attribute name="tso6">
                        <ref name="virOnOff"/>
                      </attribute>
                    </optional>
                    <optional>
                      <attribute name="ecn">
                        <ref name="virOnOff"/>
                      </attribute>
                    </optional>
                    <optional>
                      <attribute name="ufo">
                        <ref name="virOnOff"/>
                      </attribute>
                    </optional>
                  </element>
                </optional>
                <optional>
                  <attribute name="rss">
                    <ref name="virOnOff"/>
                  </attribute>
                </optional>
                <optional>
                  <attribute name="rss_hash_report">
                    <ref name="virOnOff"/>
                  </attribute>
                </optional>
              </interleave>
            </element>
          </group>
        </choice>
      </optional>
      <optional>
        <ref name="alias"/>
      </optional>
      <optional>
        <ref name="acpi"/>
      </optional>
      <optional>
        <ref name="address"/>
      </optional>
      <optional>
        <element name="filterref">
          <ref name="filterref-node-attributes"/>
        </element>
      </optional>
      <optional>
        <element name="tune">
          <optional>
            <!-- size of send buffer for network tap devices -->
            <element name="sndbuf">
              <ref name="unsignedInt"/>
            </element>
          </optional>
        </element>
      </optional>
      <optional>
        <ref name="deviceBoot"/>
      </optional>
      <optional>
        <ref name="rom"/>
      </optional>
      <optional>
        <ref name="bandwidth"/>
      </optional>
      <optional>
        <ref name="vlan"/>
      </optional>
      <optional>
        <ref name="portOptions"/>
      </optional>
      <optional>
        <ref name="teaming"/>
      </optional>
    </interleave>
  </define>

  <!--
      All ip-related info for either the host or guest side of an interface
  -->
  <define name="interface-ip-info">
    <interleave>
      <zeroOrMore>
        <element name="ip">
          <attribute name="address">
            <ref name="ipAddr"/>
          </attribute>
          <optional>
            <attribute name="family">
              <ref name="addr-family"/>
            </attribute>
          </optional>
          <optional>
            <attribute name="prefix">
              <ref name="ipPrefix"/>
            </attribute>
          </optional>
          <optional>
            <attribute name="peer">
              <ref name="ipAddr"/>
            </attribute>
          </optional>
          <empty/>
        </element>
      </zeroOrMore>
      <zeroOrMore>
        <ref name="route"/>
      </zeroOrMore>
    </interleave>
  </define>

  <define name="interface-port-forwards">
    <zeroOrMore>
      <element name="portForward">
        <attribute name="proto">
          <choice>
            <value>tcp</value>
            <value>udp</value>
          </choice>
        </attribute>
        <optional>
          <attribute name="address">
            <ref name="ipAddr"/>
          </attribute>
        </optional>
        <optional>
          <attribute name="dev">
            <ref name="deviceName"/>
          </attribute>
        </optional>
        <interleave>
          <zeroOrMore>
            <element name="range">
              <attribute name="start">
                <ref name="PortNumber"/>
              </attribute>
              <optional>
                <attribute name="end">
                  <ref name="PortNumber"/>
                </attribute>
              </optional>
              <optional>
                <attribute name="to">
                  <ref name="PortNumber"/>
                </attribute>
              </optional>
              <optional>
                <attribute name="exclude">
                  <ref name="virYesNo"/>
                </attribute>
              </optional>
            </element>
          </zeroOrMore>
        </interleave>
      </element>
    </zeroOrMore>
  </define>

  <define name="teaming">
    <element name="teaming">
      <choice>
        <group>
          <attribute name="type">
            <value>persistent</value>
          </attribute>
        </group>
        <group>
          <attribute name="type">
            <value>transient</value>
          </attribute>
          <attribute name="persistent">
            <ref name="aliasName"/>
          </attribute>
        </group>
      </choice>
    </element>
  </define>

  <!--
      An emulator description is just a path to the binary used for the task
    -->
  <define name="emulator">
    <element name="emulator">
      <ref name="absFilePath"/>
    </element>
  </define>
  <!--
      A graphic description (SPICE, VNC, SDL, ...)
    -->
  <define name="graphic">
    <element name="graphics">
      <choice>
        <group>
          <attribute name="type">
            <value>sdl</value>
          </attribute>
          <optional>
            <attribute name="display">
              <text/>
            </attribute>
          </optional>
          <optional>
            <attribute name="xauth">
              <text/>
            </attribute>
          </optional>
          <optional>
            <attribute name="fullscreen">
              <ref name="virYesNo"/>
            </attribute>
          </optional>
          <optional>
            <element name="gl">
              <attribute name="enable">
                <ref name="virYesNo"/>
              </attribute>
              <empty/>
            </element>
          </optional>
        </group>
        <group>
          <attribute name="type">
            <value>vnc</value>
          </attribute>
          <choice>
            <group>
              <optional>
                <attribute name="port">
                  <ref name="PortNumber"/>
                </attribute>
              </optional>
              <optional>
                <attribute name="autoport">
                  <ref name="virYesNo"/>
                </attribute>
              </optional>
              <optional>
                <attribute name="websocket">
                  <ref name="PortNumber"/>
                </attribute>
              </optional>
              <optional>
                <attribute name="listen">
                  <ref name="addrIPorName"/>
                </attribute>
              </optional>
              <optional>
                <attribute name="sharePolicy">
                  <choice>
                    <value>allow-exclusive</value>
                    <value>force-shared</value>
                    <value>ignore</value>
                  </choice>
                </attribute>
              </optional>
              <optional>
                <attribute name="powerControl">
                  <ref name="virYesNo"/>
                </attribute>
              </optional>
              <optional>
                <attribute name="wait">
                  <ref name="virYesNo"/>
                </attribute>
              </optional>
            </group>
            <group>
              <optional>
                <attribute name="socket">
                  <ref name="absFilePath"/>
                </attribute>
              </optional>
            </group>
          </choice>
          <optional>
            <attribute name="passwd">
              <text/>
            </attribute>
          </optional>
          <optional>
            <attribute name="keymap">
              <text/>
            </attribute>
          </optional>
          <optional>
            <attribute name="passwdValidTo">
              <data type="dateTime"/>
            </attribute>
          </optional>
          <optional>
            <attribute name="connected">
              <value>keep</value>
            </attribute>
          </optional>
          <interleave>
            <optional>
              <element name="audio">
                <attribute name="id">
                  <ref name="uint8"/>
                </attribute>
              </element>
            </optional>
            <ref name="listenElements"/>
          </interleave>
        </group>
        <group>
          <attribute name="type">
            <value>spice</value>
          </attribute>
          <optional>
            <attribute name="port">
              <ref name="PortNumber"/>
            </attribute>
          </optional>
          <optional>
            <attribute name="tlsPort">
              <ref name="PortNumber"/>
            </attribute>
          </optional>
          <optional>
            <attribute name="autoport">
              <ref name="virYesNo"/>
            </attribute>
          </optional>
          <optional>
            <attribute name="listen">
              <ref name="addrIPorName"/>
            </attribute>
          </optional>
          <optional>
            <attribute name="passwd">
              <text/>
            </attribute>
          </optional>
          <optional>
            <attribute name="keymap">
              <text/>
            </attribute>
          </optional>
          <optional>
            <attribute name="passwdValidTo">
              <data type="dateTime"/>
            </attribute>
          </optional>
          <optional>
            <attribute name="connected">
              <choice>
                <value>fail</value>
                <value>disconnect</value>
                <value>keep</value>
              </choice>
            </attribute>
          </optional>
          <optional>
            <attribute name="defaultMode">
              <choice>
                <value>any</value>
                <value>secure</value>
                <value>insecure</value>
              </choice>
            </attribute>
          </optional>
          <interleave>
            <ref name="listenElements"/>
            <zeroOrMore>
              <element name="channel">
                <attribute name="name">
                  <choice>
                    <value>main</value>
                    <value>display</value>
                    <value>inputs</value>
                    <value>cursor</value>
                    <value>playback</value>
                    <value>record</value>
                    <value>smartcard</value>
                    <value>usbredir</value>
                  </choice>
                </attribute>
                <attribute name="mode">
                  <choice>
                    <value>any</value>
                    <value>secure</value>
                    <value>insecure</value>
                  </choice>
                </attribute>
                <empty/>
              </element>
            </zeroOrMore>
            <optional>
              <element name="image">
                <attribute name="compression">
                  <choice>
                    <value>auto_glz</value>
                    <value>auto_lz</value>
                    <value>quic</value>
                    <value>glz</value>
                    <value>lz</value>
                    <value>off</value>
                  </choice>
                </attribute>
                <empty/>
              </element>
            </optional>
            <optional>
              <element name="jpeg">
                <attribute name="compression">
                  <choice>
                    <value>auto</value>
                    <value>never</value>
                    <value>always</value>
                  </choice>
                </attribute>
                <empty/>
              </element>
            </optional>
            <optional>
              <element name="zlib">
                <attribute name="compression">
                  <choice>
                    <value>auto</value>
                    <value>never</value>
                    <value>always</value>
                  </choice>
                </attribute>
                <empty/>
              </element>
            </optional>
            <optional>
              <element name="playback">
                <attribute name="compression">
                  <ref name="virOnOff"/>
                </attribute>
                <empty/>
              </element>
            </optional>
            <optional>
              <element name="streaming">
                <attribute name="mode">
                  <choice>
                    <value>filter</value>
                    <value>all</value>
                    <value>off</value>
                  </choice>
                </attribute>
                <empty/>
              </element>
            </optional>
            <optional>
              <ref name="clipboard"/>
            </optional>
            <optional>
              <ref name="mousemode"/>
            </optional>
            <optional>
              <element name="filetransfer">
                <attribute name="enable">
                  <ref name="virYesNo"/>
                </attribute>
                <empty/>
              </element>
            </optional>
            <optional>
              <element name="gl">
                <attribute name="enable">
                  <ref name="virYesNo"/>
                </attribute>
                <optional>
                  <attribute name="rendernode">
                    <ref name="absFilePath"/>
                  </attribute>
                </optional>
                <empty/>
              </element>
            </optional>
          </interleave>
        </group>
        <group>
          <attribute name="type">
            <value>dbus</value>
          </attribute>
          <optional>
            <choice>
              <group>
                <attribute name="address">
                  <ref name="dbusAddr"/>
                </attribute>
              </group>
              <group>
                <attribute name="p2p">
                  <ref name="virYesNo"/>
                </attribute>
              </group>
            </choice>
          </optional>
          <interleave>
            <optional>
              <element name="gl">
                <attribute name="enable">
                  <ref name="virYesNo"/>
                </attribute>
                <optional>
                  <attribute name="rendernode">
                    <ref name="absFilePath"/>
                  </attribute>
                </optional>
              </element>
            </optional>
            <optional>
              <element name="audio">
                <attribute name="id">
                  <ref name="uint8"/>
                </attribute>
              </element>
            </optional>
          </interleave>
        </group>
        <group>
          <attribute name="type">
            <value>rdp</value>
          </attribute>
          <optional>
            <attribute name="port">
              <ref name="PortNumber"/>
            </attribute>
          </optional>
          <optional>
            <attribute name="autoport">
              <ref name="virYesNo"/>
            </attribute>
          </optional>
          <optional>
            <attribute name="replaceUser">
              <ref name="virYesNo"/>
            </attribute>
          </optional>
          <optional>
            <attribute name="multiUser">
              <ref name="virYesNo"/>
            </attribute>
          </optional>
          <optional>
            <attribute name="listen">
              <ref name="addrIPorName"/>
            </attribute>
          </optional>
          <optional>
            <attribute name="username">
              <text/>
            </attribute>
          </optional>
          <optional>
            <attribute name="passwd">
              <text/>
            </attribute>
          </optional>
          <ref name="listenElements"/>
        </group>
        <group>
          <attribute name="type">
            <value>desktop</value>
          </attribute>
          <optional>
            <attribute name="display">
              <text/>
            </attribute>
          </optional>
        </group>
        <group>
          <attribute name="type">
            <value>egl-headless</value>
          </attribute>
          <optional>
            <element name="gl">
              <optional>
                <attribute name="rendernode">
                  <ref name="absFilePath"/>
                </attribute>
              </optional>
            </element>
          </optional>
        </group>
      </choice>
    </element>
  </define>

  <define name="clipboard">
    <element name="clipboard">
      <attribute name="copypaste">
        <ref name="virYesNo"/>
      </attribute>
      <empty/>
    </element>
  </define>
  <define name="mousemode">
    <element name="mouse">
      <attribute name="mode">
        <choice>
          <value>server</value>
          <value>client</value>
        </choice>
      </attribute>
      <empty/>
    </element>
  </define>
  <define name="listenElements">
    <zeroOrMore>
      <element name="listen">
        <choice>
          <group>
            <attribute name="type">
              <value>address</value>
            </attribute>
            <optional>
              <attribute name="address">
                <ref name="addrIPorName"/>
              </attribute>
            </optional>
          </group>
          <group>
            <attribute name="type">
              <value>network</value>
            </attribute>
            <attribute name="network">
              <text/>
            </attribute>
            <optional>
              <attribute name="address">
                <ref name="addrIPorName"/>
              </attribute>
            </optional>
          </group>
          <group>
            <attribute name="type">
              <value>socket</value>
            </attribute>
            <optional>
              <attribute name="socket">
                <ref name="absFilePath"/>
              </attribute>
            </optional>
          </group>
          <group>
            <attribute name="type">
              <value>none</value>
            </attribute>
          </group>
        </choice>
      </element>
    </zeroOrMore>
  </define>
  <!--
     A video adapter description, allowing configuration of device
     model, number of virtual heads, video ram size, and for qxl
     both ram bar sizes.
   -->
  <define name="video">
    <element name="video">
      <interleave>
        <optional>
          <element name="driver">
            <optional>
              <ref name="virtioOptions"/>
            </optional>
            <optional>
              <attribute name="name">
                <choice>
                  <value>qemu</value>
                  <value>vhostuser</value>
                </choice>
              </attribute>
            </optional>
            <optional>
              <attribute name="vgaconf">
                <choice>
                  <value>io</value>
                  <value>on</value>
                  <value>off</value>
                </choice>
              </attribute>
            </optional>
          </element>
        </optional>
        <optional>
          <element name="model">
            <choice>
              <attribute name="type">
                <choice>
                  <value>vga</value>
                  <value>cirrus</value>
                  <value>vmvga</value>
                  <value>xen</value>
                  <value>vbox</value>
                  <value>gop</value>
                  <value>none</value>
                  <value>bochs</value>
                  <value>ramfb</value>
                </choice>
              </attribute>
              <group>
                <attribute name="type">
                  <value>qxl</value>
                </attribute>
                <optional>
                  <attribute name="ram">
                    <ref name="unsignedInt"/>
                  </attribute>
                </optional>
                <optional>
                  <attribute name="vgamem">
                    <ref name="unsignedInt"/>
                  </attribute>
                </optional>
                <optional>
                  <attribute name="vram64">
                    <ref name="unsignedInt"/>
                  </attribute>
                </optional>
              </group>
              <group>
                <attribute name="type">
                  <value>virtio</value>
                </attribute>
                <optional>
                  <attribute name="device">
                    <choice>
                      <value>virtio-vga</value>
                      <value>virtio-vga-gl</value>
                      <value>virtio-gpu</value>
                      <value>virtio-gpu-gl</value>
                      <value>vhost-user-vga</value>
                      <value>vhost-user-gpu</value>
                    </choice>
                  </attribute>
                </optional>
              </group>
            </choice>
            <optional>
              <attribute name="vram">
                <ref name="unsignedInt"/>
              </attribute>
            </optional>
            <optional>
              <attribute name="heads">
                <ref name="unsignedInt"/>
              </attribute>
            </optional>
            <optional>
              <attribute name="primary">
                <ref name="virYesNo"/>
              </attribute>
            </optional>
            <optional>
              <attribute name="blob">
                <ref name="virOnOff"/>
              </attribute>
            </optional>
            <optional>
              <attribute name="edid">
                <ref name="virOnOff"/>
              </attribute>
            </optional>
            <optional>
              <element name="acceleration">
                <optional>
                  <attribute name="accel3d">
                    <ref name="virYesNo"/>
                  </attribute>
                </optional>
                <optional>
                  <attribute name="accel2d">
                    <ref name="virYesNo"/>
                  </attribute>
                </optional>
                <optional>
                  <attribute name="rendernode">
                    <ref name="absFilePath"/>
                  </attribute>
                </optional>
              </element>
            </optional>
            <optional>
              <element name="resolution">
                <attribute name="x">
                  <ref name="unsignedInt"/>
                </attribute>
                <attribute name="y">
                  <ref name="unsignedInt"/>
                </attribute>
              </element>
            </optional>
          </element>
        </optional>
        <optional>
          <ref name="alias"/>
        </optional>
        <optional>
          <ref name="acpi"/>
        </optional>
        <optional>
          <ref name="address"/>
        </optional>
      </interleave>
    </element>
  </define>
  <!--
      When a certain event happens, multiple policies can be applied
      depends on what happened:
    -->
  <define name="events">
    <interleave>
      <optional>
        <element name="on_reboot">
          <ref name="offOptions"/>
        </element>
      </optional>
      <optional>
        <element name="on_poweroff">
          <ref name="offOptions"/>
        </element>
      </optional>
      <optional>
        <element name="on_crash">
          <ref name="crashOptions"/>
        </element>
      </optional>
      <optional>
        <element name="on_lockfailure">
          <ref name="lockfailureOptions"/>
        </element>
      </optional>
    </interleave>
  </define>
  <!--
      Options when a domain terminates:
      destroy: The domain is cleaned up
      restart: A new domain is started in place of the old one
      preserve: The domain will remain in memory until it is destroyed manually
      rename-restart: a variant of the previous one but where the old domain is
                      renamed before being saved to allow a restart
    -->
  <define name="offOptions">
    <choice>
      <value>destroy</value>
      <value>restart</value>
      <value>preserve</value>
      <value>rename-restart</value>
    </choice>
  </define>
  <!--
      Options when a domain crashes:
      destroy: The domain is cleaned up
      restart: A new domain is started in place of the old one
      preserve: The domain will remain in memory until it is destroyed manually
      rename-restart: a variant of the previous one but where the old domain is
                      renamed before being saved to allow a restart
      coredump-destroy: The crashed domain's core will be dumped, and then the
                        domain will be terminated completely and all resources
                        released
      coredump-restart: The crashed domain's core will be dumped, and then the
                        domain will be restarted with the same configuration
    -->
  <define name="crashOptions">
    <choice>
      <value>destroy</value>
      <value>restart</value>
      <value>preserve</value>
      <value>rename-restart</value>
      <value>coredump-destroy</value>
      <value>coredump-restart</value>
    </choice>
  </define>
  <!--
      Options when resource locks are lost:
      poweroff: power off the domain
      restart: power off the domain and start it up again to reacquire the
               locks
      pause: pause the execution of the domain so that it can be manually
             resumed when lock issues are solved
      ignore: keep the domain running
  -->
  <define name="lockfailureOptions">
    <choice>
      <value>poweroff</value>
      <value>restart</value>
      <value>pause</value>
      <value>ignore</value>
    </choice>
  </define>
  <!--
      Control ACPI sleep states (dis)allowed for the domain
      For each of the states the following rules apply:
      on: the state will be forcefully enabled
      off: the state will be forcefully disabled
      not specified: hypervisor will be left to decide its defaults
  -->
  <define name="pm">
    <element name="pm">
      <interleave>
        <optional>
          <element name="suspend-to-mem">
            <ref name="suspendChoices"/>
          </element>
        </optional>
        <optional>
          <element name="suspend-to-disk">
            <ref name="suspendChoices"/>
          </element>
        </optional>
      </interleave>
      <empty/>
    </element>
  </define>
  <define name="suspendChoices">
    <optional>
      <attribute name="enabled">
        <ref name="virYesNo"/>
      </attribute>
    </optional>
  </define>
  <!--
      Specific setup for a qemu emulated character device.  Note: this
      definition doesn't fully specify the constraints on this node.
    -->
  <define name="qemucdev">
    <ref name="qemucdevSrcType"/>
    <optional>
      <attribute name="tty">
        <ref name="absFilePath"/>
      </attribute>
    </optional>
    <interleave>
      <ref name="qemucdevSrcDef"/>
      <optional>
        <ref name="qemucdevTgtDef"/>
      </optional>
      <optional>
        <ref name="alias"/>
      </optional>
      <optional>
        <ref name="acpi"/>
      </optional>
      <optional>
        <ref name="address"/>
      </optional>
    </interleave>
  </define>

  <define name="qemucdevConsoleTgtType">
    <attribute name="type">
      <choice>
        <value>xen</value>
        <value>serial</value>
        <value>uml</value> <!-- NOT USED ANYMORE -->
        <value>virtio</value>
        <value>lxc</value>
        <value>openvz</value>
        <value>sclp</value>
        <value>sclplm</value>
      </choice>
    </attribute>
  </define>

  <define name="qemucdevSerialTgtType">
    <attribute name="type">
      <choice>
        <value>isa-serial</value>
        <value>usb-serial</value>
        <value>pci-serial</value>
        <value>spapr-vio-serial</value>
        <value>system-serial</value>
        <value>sclp-serial</value>
        <value>isa-debug</value>
      </choice>
    </attribute>
  </define>

  <define name="qemucdevSerialTgtModel">
    <element name="model">
      <attribute name="name">
        <choice>
          <value>isa-serial</value>
          <value>usb-serial</value>
          <value>pci-serial</value>
          <value>spapr-vty</value>
          <value>pl011</value>
          <value>16550a</value>
          <value>sclpconsole</value>
          <value>sclplmconsole</value>
          <value>isa-debugcon</value>
        </choice>
      </attribute>
    </element>
  </define>

  <define  name="qemucdevTgtDef">
    <element name="target">
      <interleave>
        <choice>
          <optional>
            <ref name="qemucdevConsoleTgtType"/>
          </optional>
          <optional>
            <ref name="qemucdevSerialTgtType"/>
          </optional>
        </choice>
        <optional>
          <attribute name="port"/>
        </optional>
        <optional>
          <ref name="qemucdevSerialTgtModel"/>
        </optional>
      </interleave>
    </element>
  </define>

  <define name="qemucdevSrcTypeChoice">
    <choice>
      <value>dev</value>
      <value>file</value>
      <value>pipe</value>
      <value>unix</value>
      <value>tcp</value>
      <value>udp</value>
      <value>null</value>
      <value>stdio</value>
      <value>vc</value>
      <value>pty</value>
      <value>spicevmc</value>
      <value>spiceport</value>
      <value>nmdm</value>
      <value>qemu-vdagent</value>
      <value>dbus</value>
    </choice>
  </define>

  <define name="usbdevfilter">
    <element name="usbdev">
      <attribute name="allow">
        <ref name="virYesNo"/>
      </attribute>
      <optional>
        <attribute name="class">
          <choice>
            <ref name="usbClass"/>
            <ref name="usbIdDefault"/>
          </choice>
        </attribute>
      </optional>
      <optional>
        <attribute name="vendor">
          <choice>
            <ref name="usbId"/>
            <ref name="usbIdDefault"/>
          </choice>
        </attribute>
      </optional>
      <optional>
        <attribute name="product">
          <choice>
            <ref name="usbId"/>
            <ref name="usbIdDefault"/>
          </choice>
        </attribute>
      </optional>
      <optional>
        <attribute name="version">
          <choice>
            <ref name="usbVersion"/>
            <ref name="usbIdDefault"/>
          </choice>
        </attribute>
      </optional>
    </element>
  </define>

  <define name="qemucdevSrcType">
    <attribute name="type">
      <ref name="qemucdevSrcTypeChoice"/>
    </attribute>
  </define>

  <define name="qemucdevSrcDef">
    <interleave>
      <zeroOrMore>
        <element name="source">
          <optional>
            <attribute name="mode"/>
          </optional>
          <optional>
            <attribute name="path"/>
          </optional>
          <optional>
            <attribute name="host"/>
          </optional>
          <optional>
            <attribute name="service"/>
          </optional>
          <optional>
            <attribute name="channel"/>
          </optional>
          <optional>
            <attribute name="master"/>
          </optional>
          <optional>
            <attribute name="slave"/>
          </optional>
          <optional>
            <attribute name="append">
              <ref name="virOnOff"/>
            </attribute>
          </optional>
          <optional>
            <attribute name="tls">
              <ref name="virYesNo"/>
            </attribute>
          </optional>
          <optional>
            <ref name="reconnect"/>
          </optional>
          <interleave>
            <zeroOrMore>
              <ref name="devSeclabel"/>
            </zeroOrMore>
            <optional>
              <ref name="clipboard"/>
            </optional>
            <optional>
              <ref name="mousemode"/>
            </optional>
          </interleave>
        </element>
      </zeroOrMore>
      <optional>
        <element name="protocol">
          <optional>
            <attribute name="type">
              <choice>
                <value>raw</value>
                <value>telnet</value>
                <value>telnets</value>
                <value>tls</value>
              </choice>
            </attribute>
          </optional>
        </element>
      </optional>
      <optional>
        <element name="log">
          <attribute name="file">
            <ref name="absFilePath"/>
          </attribute>
          <optional>
            <attribute name="append">
              <ref name="virOnOff"/>
            </attribute>
          </optional>
        </element>
      </optional>
    </interleave>
  </define>
  <!--
      The description for a console
      just a tty device
    -->
  <define name="console">
    <element name="console">
      <choice>
        <group>
          <optional>
            <attribute name="tty">
              <ref name="absFilePath"/>
            </attribute>
          </optional>
          <empty/>
        </group>
        <ref name="qemucdev"/>
      </choice>
    </element>
  </define>
  <define name="codec">
    <element name="codec">
      <attribute name="type">
        <choice>
          <value>duplex</value>
          <value>micro</value>
          <value>output</value>
        </choice>
      </attribute>
    </element>
  </define>
  <define name="sound">
    <element name="sound">
      <attribute name="model">
        <choice>
          <value>sb16</value>
          <value>es1370</value>
          <value>pcspk</value>
          <value>ac97</value>
          <value>ich6</value>
          <value>ich7</value>
          <value>ich9</value>
          <value>usb</value>
          <value>virtio</value>
        </choice>
      </attribute>
      <optional>
        <attribute name="multichannel">
          <ref name="virYesNo"/>
        </attribute>
      </optional>
      <optional>
        <attribute name="streams">
          <ref name="uint32"/>
        </attribute>
      </optional>
      <interleave>
        <optional>
          <ref name="alias"/>
        </optional>
        <optional>
          <ref name="acpi"/>
        </optional>
        <optional>
          <ref name="address"/>
        </optional>
        <optional>
          <element name="audio">
            <attribute name="id">
              <ref name="uint8"/>
            </attribute>
          </element>
        </optional>
        <zeroOrMore>
          <ref name="codec"/>
        </zeroOrMore>
        <optional>
          <element name="driver">
            <ref name="virtioOptions"/>
          </element>
        </optional>
      </interleave>
    </element>
  </define>

  <define name="audiocommonattr">
    <optional>
      <attribute name="mixingEngine">
        <ref name="virYesNo"/>
      </attribute>
    </optional>
    <optional>
      <attribute name="fixedSettings">
        <ref name="virYesNo"/>
      </attribute>
    </optional>
    <optional>
      <attribute name="voices">
        <ref name="uint32"/>
      </attribute>
    </optional>
    <optional>
      <attribute name="bufferLength">
        <ref name="uint32"/>
      </attribute>
    </optional>
  </define>

  <define name="audiocommonchild">
    <optional>
      <element name="settings">
        <optional>
          <attribute name="frequency">
            <ref name="uint32"/>
          </attribute>
        </optional>
        <optional>
          <attribute name="channels">
            <ref name="uint32"/>
          </attribute>
        </optional>
        <optional>
          <attribute name="format">
            <choice>
              <value>s8</value>
              <value>u8</value>
              <value>s16</value>
              <value>u16</value>
              <value>s32</value>
              <value>u32</value>
              <value>f32</value>
            </choice>
          </attribute>
        </optional>
      </element>
    </optional>
  </define>

  <define name="audionone">
    <ref name="audiocommonattr"/>
    <ref name="audiocommonchild"/>
  </define>

  <define name="audioalsa">
    <ref name="audiocommonattr"/>
    <optional>
      <attribute name="dev">
        <ref name="filePath"/>
      </attribute>
    </optional>
    <ref name="audiocommonchild"/>
  </define>

  <define name="audiocoreaudio">
    <ref name="audiocommonattr"/>
    <optional>
      <attribute name="bufferCount">
        <ref name="uint32"/>
      </attribute>
    </optional>
    <ref name="audiocommonchild"/>
  </define>

  <define name="audiojack">
    <ref name="audiocommonattr"/>
    <optional>
      <attribute name="serverName">
        <data type="string"/>
      </attribute>
    </optional>
    <optional>
      <attribute name="clientName">
        <data type="string"/>
      </attribute>
    </optional>
    <optional>
      <attribute name="connectPorts">
        <data type="string"/>
      </attribute>
    </optional>
    <optional>
      <attribute name="exactName">
        <ref name="virYesNo"/>
      </attribute>
    </optional>
    <ref name="audiocommonchild"/>
  </define>

  <define name="audiooss">
    <ref name="audiocommonattr"/>
    <optional>
      <attribute name="dev">
        <ref name="deviceName"/>
      </attribute>
    </optional>
    <optional>
      <attribute name="bufferCount">
        <ref name="uint32"/>
      </attribute>
    </optional>
    <optional>
      <attribute name="tryPoll">
        <ref name="virYesNo"/>
      </attribute>
    </optional>
    <ref name="audiocommonchild"/>
  </define>

  <define name="audiopipewire">
    <ref name="audiocommonattr"/>
    <optional>
      <attribute name="name">
        <data type="string"/>
      </attribute>
    </optional>
    <optional>
      <attribute name="streamName">
        <data type="string"/>
      </attribute>
    </optional>
    <optional>
      <attribute name="latency">
        <ref name="uint32"/>
      </attribute>
    </optional>
    <ref name="audiocommonchild"/>
  </define>

  <define name="audiopulseaudio">
    <ref name="audiocommonattr"/>
    <optional>
      <attribute name="name">
        <data type="string"/>
      </attribute>
    </optional>
    <optional>
      <attribute name="streamName">
        <data type="string"/>
      </attribute>
    </optional>
    <optional>
      <attribute name="latency">
        <ref name="uint32"/>
      </attribute>
    </optional>
    <ref name="audiocommonchild"/>
  </define>

  <define name="audiosdl">
    <ref name="audiocommonattr"/>
    <optional>
      <attribute name="bufferCount">
        <ref name="uint32"/>
      </attribute>
    </optional>
    <ref name="audiocommonchild"/>
  </define>

  <define name="audiospice">
    <ref name="audiocommonattr"/>
    <ref name="audiocommonchild"/>
  </define>

  <define name="audiofile">
    <ref name="audiocommonattr"/>
    <ref name="audiocommonchild"/>
  </define>

  <define name="audiodbus">
    <ref name="audiocommonattr"/>
    <ref name="audiocommonchild"/>
  </define>

  <define name="audio">
    <element name="audio">
      <attribute name="id">
        <ref name="uint8"/>
      </attribute>
      <optional>
        <attribute name="timerPeriod">
          <ref name="uint32"/>
        </attribute>
      </optional>
      <choice>
        <group>
          <attribute name="type">
            <value>none</value>
          </attribute>
          <interleave>
            <optional>
              <element name="input">
                <ref name="audionone"/>
              </element>
            </optional>
            <optional>
              <element name="output">
                <ref name="audionone"/>
              </element>
            </optional>
          </interleave>
        </group>
        <group>
          <attribute name="type">
            <value>dbus</value>
          </attribute>
          <interleave>
            <optional>
              <element name="input">
                <ref name="audiodbus"/>
              </element>
            </optional>
            <optional>
              <element name="output">
                <ref name="audiodbus"/>
              </element>
            </optional>
          </interleave>
        </group>
        <group>
          <attribute name="type">
            <value>alsa</value>
          </attribute>
          <interleave>
            <optional>
              <element name="input">
                <ref name="audioalsa"/>
              </element>
            </optional>
            <optional>
              <element name="output">
                <ref name="audioalsa"/>
              </element>
            </optional>
          </interleave>
        </group>
        <group>
          <attribute name="type">
            <value>coreaudio</value>
          </attribute>
          <interleave>
            <optional>
              <element name="input">
                <ref name="audiocoreaudio"/>
              </element>
            </optional>
            <optional>
              <element name="output">
                <ref name="audiocoreaudio"/>
              </element>
            </optional>
          </interleave>
        </group>
        <group>
          <attribute name="type">
            <value>jack</value>
          </attribute>
          <interleave>
            <optional>
              <element name="input">
                <ref name="audiojack"/>
              </element>
            </optional>
            <optional>
              <element name="output">
                <ref name="audiojack"/>
              </element>
            </optional>
          </interleave>
        </group>
        <group>
          <attribute name="type">
            <choice>
              <value>oss</value>
            </choice>
          </attribute>
          <optional>
            <attribute name="tryMMap">
              <ref name="virYesNo"/>
            </attribute>
          </optional>
          <optional>
            <attribute name="exclusive">
              <ref name="virYesNo"/>
            </attribute>
          </optional>
          <optional>
            <attribute name="dspPolicy">
              <data type="int"/>
            </attribute>
          </optional>
          <interleave>
            <optional>
              <element name="input">
                <ref name="audiooss"/>
              </element>
            </optional>
            <optional>
              <element name="output">
                <ref name="audiooss"/>
              </element>
            </optional>
          </interleave>
        </group>
        <group>
          <attribute name="type">
            <value>pipewire</value>
          </attribute>
          <interleave>
            <optional>
              <element name="input">
                <ref name="audiopipewire"/>
              </element>
            </optional>
            <optional>
              <element name="output">
                <ref name="audiopipewire"/>
              </element>
            </optional>
            <optional>
              <attribute name="runtimeDir">
                <ref name="filePath"/>
              </attribute>
            </optional>
          </interleave>
        </group>
        <group>
          <attribute name="type">
            <value>pulseaudio</value>
          </attribute>
          <optional>
            <attribute name="serverName">
              <data type="string"/>
            </attribute>
          </optional>
          <interleave>
            <optional>
              <element name="input">
                <ref name="audiopulseaudio"/>
              </element>
            </optional>
            <optional>
              <element name="output">
                <ref name="audiopulseaudio"/>
              </element>
            </optional>
          </interleave>
        </group>
        <group>
          <attribute name="type">
            <value>sdl</value>
          </attribute>
          <optional>
            <attribute name="driver">
              <choice>
                <value>esd</value>
                <value>alsa</value>
                <value>arts</value>
                <value>pulseaudio</value>
              </choice>
            </attribute>
          </optional>
          <interleave>
            <optional>
              <element name="input">
                <ref name="audiosdl"/>
              </element>
            </optional>
            <optional>
              <element name="output">
                <ref name="audiosdl"/>
              </element>
            </optional>
          </interleave>
        </group>
        <group>
          <attribute name="type">
            <value>spice</value>
          </attribute>
          <interleave>
            <optional>
              <element name="input">
                <ref name="audiospice"/>
              </element>
            </optional>
            <optional>
              <element name="output">
                <ref name="audiospice"/>
              </element>
            </optional>
          </interleave>
        </group>
        <group>
          <attribute name="type">
            <value>file</value>
          </attribute>
          <optional>
            <attribute name="path">
              <ref name="filePath"/>
            </attribute>
          </optional>
          <interleave>
            <optional>
              <element name="input">
                <ref name="audiofile"/>
              </element>
            </optional>
            <optional>
              <element name="output">
                <ref name="audiofile"/>
              </element>
            </optional>
          </interleave>
        </group>
      </choice>
    </element>
  </define>
  <define name="watchdog">
    <element name="watchdog">
      <interleave>
        <attribute name="model">
          <choice>
            <value>i6300esb</value>
            <value>ib700</value>
            <value>diag288</value>
            <value>itco</value>
          </choice>
        </attribute>
        <optional>
          <attribute name="action">
            <choice>
              <value>reset</value>
              <value>shutdown</value>
              <value>poweroff</value>
              <value>pause</value>
              <value>none</value>
              <value>dump</value>
              <value>inject-nmi</value>
            </choice>
          </attribute>
        </optional>
        <optional>
          <ref name="alias"/>
        </optional>
        <optional>
          <ref name="acpi"/>
        </optional>
        <optional>
          <ref name="address"/>
        </optional>
      </interleave>
    </element>
  </define>
  <define name="nvram">
    <element name="nvram">
      <optional>
        <ref name="address"/>
      </optional>
    </element>
  </define>

  <define name="shmem">
    <element name="shmem">
      <attribute name="name">
        <data type="string">
          <param name="pattern">[^/]*</param>
        </data>
      </attribute>
      <optional>
        <attribute name="role">
          <choice>
            <value>master</value>
            <value>peer</value>
          </choice>
        </attribute>
      </optional>
      <interleave>
        <optional>
          <element name="model">
            <attribute name="type">
              <choice>
                <value>ivshmem</value>
                <value>ivshmem-plain</value>
                <value>ivshmem-doorbell</value>
              </choice>
            </attribute>
          </element>
        </optional>
        <optional>
          <element name="size">
            <ref name="scaledInteger"/>
          </element>
        </optional>
        <optional>
          <element name="server">
            <optional>
              <attribute name="path">
                <ref name="absFilePath"/>
              </attribute>
            </optional>
          </element>
        </optional>
        <optional>
          <element name="msi">
            <optional>
              <ref name="ioeventfd"/>
            </optional>
            <optional>
              <attribute name="vectors">
                <ref name="unsignedInt"/>
              </attribute>
            </optional>
          </element>
        </optional>
        <optional>
          <ref name="alias"/>
        </optional>
        <optional>
          <ref name="acpi"/>
        </optional>
        <optional>
          <ref name="address"/>
        </optional>
      </interleave>
    </element>
  </define>

  <define name="memballoon">
    <element name="memballoon">
      <attribute name="model">
        <choice>
          <value>virtio</value>
          <value>virtio-transitional</value>
          <value>virtio-non-transitional</value>
          <value>xen</value>
          <value>none</value>
        </choice>
      </attribute>
      <optional>
        <attribute name="autodeflate">
          <ref name="virOnOff"/>
        </attribute>
      </optional>
      <optional>
         <attribute name="freePageReporting">
           <ref name="virOnOff"/>
         </attribute>
       </optional>
      <interleave>
        <optional>
          <ref name="alias"/>
        </optional>
        <optional>
          <ref name="acpi"/>
        </optional>
        <optional>
          <ref name="address"/>
        </optional>
        <optional>
          <element name="stats">
            <attribute name="period">
              <ref name="positiveInteger"/>
            </attribute>
          </element>
        </optional>
        <optional>
          <element name="driver">
            <ref name="virtioOptions"/>
          </element>
        </optional>
      </interleave>
    </element>
  </define>
  <define name="parallel">
    <element name="parallel">
      <ref name="qemucdev"/>
    </element>
  </define>
  <define name="serial">
    <element name="serial">
      <ref name="qemucdev"/>
    </element>
  </define>
  <define name="guestfwdTarget">
    <element name="target">
      <attribute name="type">
        <value>guestfwd</value>
      </attribute>
      <attribute name="address"/>
      <attribute name="port"/>
    </element>
  </define>
  <define name="virtioTarget">
    <element name="target">
      <attribute name="type">
        <value>virtio</value>
      </attribute>
      <optional>
        <attribute name="name"/>
      </optional>
      <optional>
        <attribute name="state">
          <choice>
            <value>connected</value>
            <value>disconnected</value>
          </choice>
        </attribute>
      </optional>
    </element>
  </define>
  <define name="xenTarget">
    <element name="target">
      <attribute name="type">
        <value>xen</value>
      </attribute>
      <optional>
        <attribute name="name"/>
      </optional>
    </element>
  </define>
  <define name="channel">
    <element name="channel">
      <ref name="qemucdevSrcType"/>
      <interleave>
        <ref name="qemucdevSrcDef"/>
        <choice>
          <ref name="guestfwdTarget"/>
          <ref name="virtioTarget"/>
          <ref name="xenTarget"/>
        </choice>
        <optional>
          <ref name="alias"/>
        </optional>
        <optional>
          <ref name="address"/>
        </optional>
      </interleave>
    </element>
  </define>

  <define name="smartcard">
    <element name="smartcard">
      <interleave>
        <choice>
          <group>
            <attribute name="mode">
              <value>host</value>
            </attribute>
            <!-- might need to add optional database element here later -->
          </group>
          <group>
            <interleave>
              <attribute name="mode">
                <value>host-certificates</value>
              </attribute>
              <group>
                <ref name="certificate"/>
                <ref name="certificate"/>
                <ref name="certificate"/>
              </group>
              <optional>
                <element name="database">
                  <ref name="absDirPath"/>
                </element>
              </optional>
            </interleave>
          </group>
          <group>
            <attribute name="mode">
              <value>passthrough</value>
            </attribute>
            <ref name="qemucdevSrcType"/>
            <interleave>
              <ref name="qemucdevSrcDef"/>
              <optional>
                <ref name="qemucdevTgtDef"/>
              </optional>
            </interleave>
          </group>
        </choice>
        <optional>
          <ref name="acpi"/>
        </optional>
        <optional>
          <ref name="address"/>
        </optional>
      </interleave>
    </element>
  </define>

  <define name="certificate">
    <element name="certificate">
      <text/>
    </element>
  </define>

  <define name="tpm">
    <element name="tpm">
      <optional>
        <attribute name="model">
          <choice>
            <value>tpm-tis</value>
            <value>tpm-crb</value>
            <value>tpm-spapr</value>
            <value>spapr-tpm-proxy</value>
          </choice>
        </attribute>
      </optional>
      <interleave>
        <ref name="tpm-backend"/>
        <optional>
          <ref name="alias"/>
        </optional>
        <optional>
          <ref name="address"/>
        </optional>
      </interleave>
    </element>
  </define>

  <define name="tpm-backend">
    <element name="backend">
      <choice>
        <group>
          <attribute name="type">
            <value>passthrough</value>
          </attribute>
          <ref name="tpm-passthrough-device"/>
        </group>
        <group>
          <attribute name="type">
            <value>emulator</value>
          </attribute>
          <interleave>
            <ref name="tpm-backend-emulator-encryption"/>
            <ref name="tpm-backend-emulator-active-pcr-banks"/>
            <ref name="tpm-backend-emulator-source"/>
            <ref name="tpm-backend-emulator-profile"/>
          </interleave>
          <optional>
            <attribute name="persistent_state">
              <ref name="virYesNo"/>
            </attribute>
          </optional>
          <optional>
            <attribute name="debug">
              <ref name="uint8"/>
            </attribute>
          </optional>
        </group>
        <group>
          <attribute name="type">
            <value>external</value>
          </attribute>
          <ref name="tpm-external-source"/>
        </group>
      </choice>
      <optional>
        <attribute name="version">
          <choice>
            <value>1.2</value>
            <value>2.0</value>
          </choice>
       </attribute>
      </optional>
    </element>
  </define>

  <define name="tpm-passthrough-device">
    <optional>
      <element name="device">
        <optional>
          <attribute name="path">
            <ref name="filePath"/>
          </attribute>
        </optional>
      </element>
    </optional>
  </define>

  <define name="tpm-external-source">
    <optional>
      <element name="source">
        <attribute name="type">
          <value>unix</value>
        </attribute>
        <attribute name="path">
          <ref name="filePath"/>
        </attribute>
        <attribute name="mode">
          <value>connect</value>
        </attribute>
      </element>
    </optional>
  </define>

  <define name="tpm-backend-emulator-source">
    <optional>
      <element name="source">
        <choice>
          <group>
            <attribute name="type">
              <value>file</value>
            </attribute>
            <attribute name="path">
              <ref name="absFilePath"/>
            </attribute>
          </group>
          <group>
            <attribute name="type">
              <value>dir</value>
            </attribute>
            <attribute name="path">
              <ref name="absDirPath"/>
            </attribute>
          </group>
        </choice>
      </element>
    </optional>
  </define>

  <define name="tpm-backend-emulator-encryption">
    <optional>
      <element name="encryption">
        <attribute name="secret">
          <ref name="UUID"/>
        </attribute>
      </element>
    </optional>
  </define>

  <define name="tpm-backend-emulator-active-pcr-banks">
    <optional>
      <element name="active_pcr_banks">
        <interleave>
          <optional>
            <element name="sha1">
              <empty/>
            </element>
          </optional>
          <optional>
            <element name="sha256">
              <empty/>
            </element>
          </optional>
          <optional>
            <element name="sha384">
              <empty/>
            </element>
          </optional>
          <optional>
            <element name="sha512">
              <empty/>
            </element>
          </optional>
        </interleave>
      </element>
    </optional>
  </define>

  <define name="profileName">
    <data type="string">
      <param name="pattern">[A-Za-z0-9.\-:]+</param>
    </data>
  </define>

  <define name="tpm-backend-emulator-profile">
    <optional>
      <element name="profile">
        <optional>
          <attribute name="source">
            <ref name="profileName"/>
          </attribute>
        </optional>
        <optional>
          <attribute name="removeDisabled">
            <choice>
              <value>check</value>
              <value>fips-host</value>
            </choice>
          </attribute>
        </optional>
        <optional>
          <attribute name="name">
            <ref name="profileName"/>
          </attribute>
        </optional>
      </element>
    </optional>
  </define>

  <define name="vsock">
    <element name="vsock">
      <optional>
        <attribute name="model">
          <choice>
            <value>virtio</value>
            <value>virtio-transitional</value>
            <value>virtio-non-transitional</value>
          </choice>
        </attribute>
      </optional>
      <interleave>
        <optional>
          <element name="cid">
            <optional>
              <attribute name="auto">
                <ref name="virYesNo"/>
              </attribute>
            </optional>
            <optional>
              <attribute name="address">
                <ref name="unsignedInt"/>
              </attribute>
            </optional>
          </element>
        </optional>
        <optional>
          <ref name="address"/>
        </optional>
        <optional>
          <ref name="alias"/>
        </optional>
        <optional>
          <ref name="acpi"/>
        </optional>
        <optional>
          <element name="driver">
            <ref name="virtioOptions"/>
          </element>
        </optional>
      </interleave>
    </element>
  </define>
  <define name="iommu">
    <element name="iommu">
      <attribute name="model">
        <choice>
          <value>intel</value>
          <value>smmuv3</value>
          <value>virtio</value>
          <value>amd</value>
        </choice>
      </attribute>
      <interleave>
        <optional>
          <element name="driver">
            <optional>
              <attribute name="intremap">
                <ref name="virOnOff"/>
              </attribute>
            </optional>
            <optional>
              <attribute name="caching_mode">
                <ref name="virOnOff"/>
              </attribute>
            </optional>
            <optional>
              <attribute name="eim">
                <ref name="virOnOff"/>
              </attribute>
            </optional>
            <optional>
              <attribute name="iotlb">
                <ref name="virOnOff"/>
              </attribute>
            </optional>
            <optional>
              <attribute name="aw_bits">
                <ref name="uint8"/>
              </attribute>
            </optional>
            <optional>
              <attribute name="dma_translation">
                <ref name="virOnOff"/>
              </attribute>
            </optional>
            <optional>
              <attribute name="xtsup">
                <ref name="virOnOff"/>
              </attribute>
            </optional>
            <optional>
              <attribute name="passthrough">
                <ref name="virOnOff"/>
              </attribute>
            </optional>
            <optional>
              <attribute name="pciBus">
                <data type="unsignedInt"/>
              </attribute>
            </optional>
            <optional>
              <element name="granule">
                <choice>
                  <group>
                    <attribute name="mode">
                      <value>host</value>
                    </attribute>
                  </group>
                  <group>
                    <attribute name="size">
                      <ref name="unsignedInt"/>
                    </attribute>
                    <optional>
                      <attribute name="unit">
                        <ref name="unit"/>
                      </attribute>
                    </optional>
                  </group>
                </choice>
                <empty/>
              </element>
            </optional>
          </element>
        </optional>
        <optional>
          <ref name="acpi"/>
        </optional>
        <optional>
          <ref name="address"/>
        </optional>
        <optional>
          <ref name="alias"/>
        </optional>
      </interleave>
    </element>
  </define>

  <define name="input">
    <element name="input">
      <interleave>
        <optional>
          <element name="driver">
            <ref name="virtioOptions"/>
          </element>
        </optional>
        <choice>
          <group>
            <attribute name="type">
              <choice>
                <value>tablet</value>
                <value>mouse</value>
                <value>keyboard</value>
              </choice>
            </attribute>
            <optional>
              <attribute name="bus">
                <choice>
                  <value>ps2</value>
                  <value>usb</value>
                  <value>xen</value>
                  <value>virtio</value>
                </choice>
              </attribute>
            </optional>
          </group>
          <group>
            <attribute name="type">
              <value>passthrough</value>
            </attribute>
            <attribute name="bus">
              <value>virtio</value>
            </attribute>
            <element name="source">
              <attribute name="evdev">
                <ref name="absFilePath"/>
              </attribute>
            </element>
          </group>
          <group>
            <attribute name="type">
              <value>evdev</value>
            </attribute>
            <element name="source">
              <attribute name="dev">
                <ref name="absFilePath"/>
              </attribute>
              <optional>
                <attribute name="grab">
                  <value>all</value>
                </attribute>
              </optional>
              <optional>
                <attribute name="grabToggle">
                  <choice>
                    <value>ctrl-ctrl</value>
                    <value>alt-alt</value>
                    <value>shift-shift</value>
                    <value>meta-meta</value>
                    <value>scrolllock</value>
                    <value>ctrl-scrolllock</value>
                  </choice>
                </attribute>
              </optional>
              <optional>
                <attribute name="repeat">
                  <ref name="virOnOff"/>
                </attribute>
              </optional>
            </element>
          </group>
        </choice>
        <optional>
          <attribute name="model">
            <choice>
              <value>virtio</value>
              <value>virtio-transitional</value>
              <value>virtio-non-transitional</value>
            </choice>
          </attribute>
        </optional>
        <optional>
          <ref name="alias"/>
        </optional>
        <optional>
          <ref name="acpi"/>
        </optional>
        <optional>
          <ref name="address"/>
        </optional>
      </interleave>
    </element>
  </define>
  <define name="hub">
    <element name="hub">
      <attribute name="type">
        <value>usb</value>
      </attribute>
      <interleave>
        <optional>
          <ref name="alias"/>
        </optional>
        <optional>
          <ref name="address"/>
        </optional>
      </interleave>
    </element>
  </define>
  <define name="redirdev">
    <element name="redirdev">
      <attribute name="bus">
        <value>usb</value>
      </attribute>
      <attribute name="type">
        <ref name="qemucdevSrcTypeChoice"/>
      </attribute>
      <interleave>
        <ref name="qemucdevSrcDef"/>
        <optional>
          <ref name="alias"/>
        </optional>
        <optional>
          <ref name="address"/>
        </optional>
        <optional>
          <ref name="deviceBoot"/>
        </optional>
      </interleave>
    </element>
  </define>
  <define name="redirfilter">
    <element name="redirfilter">
      <zeroOrMore>
        <ref name="usbdevfilter"/>
      </zeroOrMore>
    </element>
  </define>

  <define name="pstore">
    <element name="pstore">
      <attribute name="backend">
        <value>acpi-erst</value>
      </attribute>
      <interleave>
        <optional>
          <element name="path">
            <ref name="absFilePath"/>
          </element>
        </optional>
        <element name="size">
          <ref name="scaledInteger"/>
        </element>
        <optional>
          <ref name="address"/>
        </optional>
        <optional>
          <ref name="alias"/>
        </optional>
      </interleave>
    </element>
  </define>

  <define name="hostdev">
    <element name="hostdev">
      <interleave>
        <choice>
          <group>
            <ref name="hostdevsubsys"/>
          </group>
          <group>
            <ref name="hostdevcaps"/>
          </group>
        </choice>
        <optional>
          <ref name="alias"/>
        </optional>
        <optional>
          <ref name="acpi"/>
        </optional>
        <optional>
          <ref name="deviceBoot"/>
        </optional>
        <optional>
          <ref name="rom"/>
        </optional>
        <optional>
          <ref name="address"/>
        </optional>
        <optional>
          <element name="readonly">
            <empty/>
          </element>
        </optional>
        <optional>
          <element name="shareable">
            <empty/>
          </element>
        </optional>
      </interleave>
    </element>
  </define>

  <define name="hostdevsubsys">
    <optional>
      <attribute name="mode">
        <value>subsystem</value>
      </attribute>
    </optional>
    <optional>
      <attribute name="managed">
        <ref name="virYesNo"/>
      </attribute>
    </optional>
    <choice>
      <ref name="hostdevsubsyspci"/>
      <ref name="hostdevsubsysusb"/>
      <ref name="hostdevsubsysscsi"/>
      <ref name="hostdevsubsyshost"/>
      <ref name="hostdevsubsysmdev"/>
    </choice>
  </define>

  <define name="hostdevcaps">
    <attribute name="mode">
      <value>capabilities</value>
    </attribute>
    <choice>
      <group>
        <ref name="hostdevcapsstorage"/>
      </group>
      <group>
        <ref name="hostdevcapsmisc"/>
      </group>
      <group>
        <ref name="hostdevcapsnet"/>
      </group>
    </choice>
  </define>


  <define name="hostdevsubsyspci">
    <attribute name="type">
      <value>pci</value>
    </attribute>
    <interleave>
      <optional>
        <ref name="hostdevDriver"/>
      </optional>
      <optional>
        <ref name="teaming"/>
      </optional>
      <element name="source">
        <optional>
          <ref name="startupPolicy"/>
        </optional>
        <optional>
          <attribute name="writeFiltering">
            <ref name="virYesNo"/>
          </attribute>
        </optional>
        <element name="address">
          <ref name="pciaddress"/>
        </element>
      </element>
      <ref name="hostdevsubsysvfiodisplay"/>
    </interleave>
  </define>

  <define name="hostdevsubsysusb">
    <attribute name="type">
      <value>usb</value>
    </attribute>
    <element name="source">
      <optional>
        <ref name="startupPolicy"/>
      </optional>
      <optional>
        <attribute name="guestReset">
          <choice>
            <value>off</value>
            <value>uninitialized</value>
            <value>on</value>
          </choice>
        </attribute>
      </optional>
      <choice>
        <group>
          <ref name="usbproduct"/>
          <optional>
            <ref name="usbaddress"/>
          </optional>
        </group>
        <ref name="usbaddress"/>
      </choice>
    </element>
  </define>

  <define name="hostdevsubsysscsi">
    <attribute name="type">
      <value>scsi</value>
    </attribute>
    <optional>
      <ref name="sgIO"/>
    </optional>
    <optional>
      <ref name="rawIO"/>
    </optional>
    <element name="source">
      <choice>
        <group>  <!-- scsi_host adapter -->
          <optional>
            <attribute name="protocol">
              <value>adapter</value>   <!-- scsi_host, default, optional -->
            </attribute>
          </optional>
          <interleave>
            <ref name="sourceinfoadapter"/>
            <element name="address">
              <ref name="scsiaddress"/>
            </element>
          </interleave>
        </group>
        <group>  <!-- iscsi adapter -->
          <attribute name="protocol">
            <value>iscsi</value>     <!-- iscsi, required -->
          </attribute>
          <attribute name="name">
            <text/>
          </attribute>
          <interleave>
            <oneOrMore>
              <element name="host">
                <attribute name="name">
                  <text/>
                </attribute>
                <optional>
                  <attribute name="port">
                    <ref name="PortNumber"/>
                  </attribute>
                </optional>
                <empty/>
              </element>
            </oneOrMore>
            <optional>
              <ref name="diskAuth"/>
            </optional>
            <optional>
              <ref name="initiatorinfo"/>
            </optional>
          </interleave>
        </group>
      </choice>
    </element>
  </define>

  <define name="hostdevsubsyshost">
    <attribute name="type">
      <value>scsi_host</value>
    </attribute>
    <optional>
      <attribute name="model">
        <choice>
          <value>virtio</value>
          <value>virtio-transitional</value>
          <value>virtio-non-transitional</value>
        </choice>
      </attribute>
    </optional>
    <element name="source">
      <choice>
        <group>
          <attribute name="protocol">
            <value>vhost</value>     <!-- vhost, required -->
          </attribute>
          <attribute name="wwpn">
            <data type="string">
              <param name="pattern">(naa\.)[0-9a-fA-F]{16}</param>
            </data>
          </attribute>
        </group>
      </choice>
    </element>
  </define>

  <define name="hostdevsubsysvfiodisplay">
    <optional>
      <attribute name="ramfb">
        <ref name="virOnOff"/>
      </attribute>
    </optional>
    <optional>
      <attribute name="display">
        <ref name="virOnOff"/>
      </attribute>
    </optional>
  </define>

  <define name="hostdevsubsysmdev">
    <attribute name="type">
      <value>mdev</value>
    </attribute>
    <attribute name="model">
      <choice>
        <value>vfio-pci</value>
        <value>vfio-ccw</value>
        <value>vfio-ap</value>
      </choice>
    </attribute>
    <ref name="hostdevsubsysvfiodisplay"/>
    <element name="source">
      <ref name="mdevaddress"/>
    </element>
  </define>

  <define name="hostdevcapsstorage">
    <attribute name="type">
      <value>storage</value>
    </attribute>
    <element name="source">
      <element name="block">
        <ref name="absFilePath"/>
      </element>
    </element>
  </define>

  <define name="hostdevcapsmisc">
    <attribute name="type">
      <value>misc</value>
    </attribute>
    <element name="source">
      <element name="char">
        <ref name="absFilePath"/>
      </element>
    </element>
  </define>

  <define name="hostdevcapsnet">
    <attribute name="type">
      <value>net</value>
    </attribute>
    <interleave>
      <element name="source">
        <element name="interface">
          <ref name="deviceName"/>
        </element>
      </element>
      <ref name="interface-ip-info"/>
    </interleave>
  </define>

  <define name="usbproduct">
    <element name="vendor">
      <attribute name="id">
        <ref name="usbId"/>
      </attribute>
    </element>
    <element name="product">
      <attribute name="id">
        <ref name="usbId"/>
      </attribute>
    </element>
  </define>
  <define name="usbaddress">
    <element name="address">
      <attribute name="bus">
        <ref name="usbAddr"/>
      </attribute>
      <choice>
        <attribute name="device">
          <ref name="usbAddr"/>
        </attribute>
        <attribute name="port">
          <ref name="usbPort"/>
        </attribute>
      </choice>
    </element>
  </define>
  <define name="scsiaddress">
    <attribute name="bus">
      <ref name="driveBus"/>
    </attribute>
    <attribute name="target">
      <ref name="driveSCSITarget"/>
    </attribute>
    <attribute name="unit">
      <ref name="driveSCSIUnit"/>
    </attribute>
  </define>
  <define name="usbportaddress">
    <attribute name="bus">
      <ref name="usbAddr"/>
    </attribute>
    <optional>
      <attribute name="port">
        <ref name="usbPort"/>
      </attribute>
    </optional>
  </define>
  <define name="spaprvioaddress">
    <optional>
      <attribute name="reg">
        <ref name="spaprvioReg"/>
      </attribute>
    </optional>
  </define>
  <define name="ccwaddress">
    <optional>
      <attribute name="cssid">
        <ref name="ccwCssidRange"/>
      </attribute>
      <attribute name="ssid">
        <ref name="ccwSsidRange"/>
      </attribute>
      <attribute name="devno">
        <ref name="ccwDevnoRange"/>
      </attribute>
    </optional>
  </define>
  <define name="driveaddress">
    <optional>
      <attribute name="controller">
        <ref name="driveController"/>
      </attribute>
    </optional>
    <optional>
      <attribute name="bus">
        <ref name="driveBus"/>
      </attribute>
    </optional>
    <optional>
      <attribute name="target">
        <ref name="driveTarget"/>
      </attribute>
    </optional>
    <optional>
      <attribute name="unit">
        <ref name="driveUnit"/>
      </attribute>
    </optional>
  </define>
  <define name="virtioserialaddress">
    <attribute name="controller">
      <ref name="driveController"/>
    </attribute>
    <optional>
      <attribute name="bus">
        <ref name="driveBus"/>
      </attribute>
    </optional>
    <optional>
      <attribute name="port">
        <ref name="virtioserialPort"/>
      </attribute>
    </optional>
  </define>
  <define name="ccidaddress">
    <attribute name="controller">
      <ref name="driveController"/>
    </attribute>
    <optional>
      <attribute name="slot">
        <ref name="ccidSlot"/>
      </attribute>
    </optional>
  </define>
  <define name="dimmaddress">
    <optional>
      <attribute name="slot">
        <ref name="unsignedInt"/>
      </attribute>
    </optional>
    <optional>
      <attribute name="base">
        <ref name="hexuint"/>
      </attribute>
    </optional>
  </define>
  <define name="mdevaddress">
    <element name="address">
      <attribute name="uuid">
        <ref name="UUID"/>
      </attribute>
    </element>
  </define>
  <define name="devices">
    <element name="devices">
      <interleave>
        <optional>
          <ref name="emulator"/>
        </optional>
        <zeroOrMore>
          <choice>
            <ref name="disk"/>
            <ref name="controller"/>
            <ref name="lease"/>
            <ref name="filesystem"/>
            <ref name="interface"/>
            <ref name="input"/>
            <ref name="sound"/>
            <ref name="audio"/>
            <ref name="hostdev"/>
            <ref name="graphic"/>
            <ref name="video"/>
            <ref name="console"/>
            <ref name="parallel"/>
            <ref name="serial"/>
            <ref name="channel"/>
            <ref name="smartcard"/>
            <ref name="hub"/>
            <ref name="redirdev"/>
            <ref name="redirfilter"/>
            <ref name="rng"/>
            <ref name="tpm"/>
            <ref name="shmem"/>
            <ref name="memorydev"/>
            <ref name="crypto"/>
          </choice>
        </zeroOrMore>
        <zeroOrMore>
          <ref name="watchdog"/>
        </zeroOrMore>
        <optional>
          <ref name="memballoon"/>
        </optional>
        <optional>
          <ref name="nvram"/>
        </optional>
        <zeroOrMore>
          <ref name="panic"/>
        </zeroOrMore>
        <zeroOrMore>
          <ref name="iommu"/>
        </zeroOrMore>
        <optional>
          <ref name="vsock"/>
        </optional>
        <optional>
          <ref name="pstore"/>
        </optional>
      </interleave>
    </element>
  </define>
  <define name="throttlegroup">
    <element name="throttlegroup">
      <ref name="iotune"/>
    </element>
  </define>
  <!--
      A set of optional throttlegroups
    -->
  <define name="throttlegroups">
    <optional>
      <element name="throttlegroups">
        <zeroOrMore>
          <ref name="throttlegroup"/>
        </zeroOrMore>
      </element>
    </optional>
  </define>
  <!--
      A set of throttlefilters to reference throttlegroups
    -->
  <define name="throttlefilters">
    <element name="throttlefilters">
      <zeroOrMore>
        <element name="throttlefilter">
          <attribute name="group">
            <data type="string"/>
          </attribute>
        </element>
      </zeroOrMore>
    </element>
  </define>
  <!--
      A set of optional features: PAE, APIC, ACPI, GIC, TCG,
      HyperV Enlightenment, KVM features, paravirtual spinlocks and HAP support
    -->
  <define name="features">
    <optional>
      <element name="features">
        <interleave>
          <optional>
            <element name="pae">
              <empty/>
            </element>
          </optional>
          <optional>
            <element name="apic">
              <optional>
                <attribute name="eoi">
                  <ref name="virOnOff"/>
                </attribute>
              </optional>
            </element>
          </optional>
          <optional>
            <element name="acpi">
              <empty/>
            </element>
          </optional>
          <optional>
            <element name="hap">
              <optional>
                <attribute name="state">
                  <ref name="virOnOff"/>
                </attribute>
              </optional>
            </element>
          </optional>
          <optional>
            <ref name="hyperv"/>
          </optional>
          <optional>
            <element name="viridian">
              <empty/>
            </element>
          </optional>
          <optional>
            <ref name="kvm"/>
          </optional>
          <optional>
            <ref name="xen"/>
          </optional>
          <optional>
            <element name="privnet">
              <empty/>
            </element>
          </optional>
          <optional>
            <element name="pvspinlock">
              <optional>
                <ref name="featurestate"/>
              </optional>
              <empty/>
            </element>
          </optional>
          <optional>
            <ref name="capabilities"/>
          </optional>
          <optional>
            <ref name="pmu"/>
          </optional>
          <optional>
            <element name="vmport">
              <optional>
                <attribute name="state">
                  <ref name="virOnOff"/>
                </attribute>
              </optional>
            </element>
          </optional>
          <optional>
            <element name="gic">
              <optional>
                <attribute name="version">
                  <choice>
                    <value>host</value>
                    <value>2</value>
                    <value>3</value>
                  </choice>
                </attribute>
              </optional>
            </element>
          </optional>
          <optional>
            <element name="smm">
              <optional>
                <attribute name="state">
                  <ref name="virOnOff"/>
                </attribute>
                <optional>
                  <element name="tseg">
                    <ref name="scaledInteger"/>
                  </element>
                </optional>
              </optional>
            </element>
          </optional>
          <optional>
            <ref name="ioapic"/>
          </optional>
          <optional>
            <ref name="hpt"/>
          </optional>
          <optional>
            <ref name="vmcoreinfo"/>
          </optional>
          <optional>
            <element name="htm">
              <ref name="featurestate"/>
            </element>
          </optional>
          <optional>
            <element name="nested-hv">
              <ref name="featurestate"/>
            </element>
          </optional>
          <optional>
            <ref name="msrs"/>
          </optional>
          <optional>
            <element name="ccf-assist">
              <ref name="featurestate"/>
            </element>
          </optional>
          <optional>
            <ref name="cfpc"/>
          </optional>
          <optional>
            <ref name="sbbc"/>
          </optional>
          <optional>
            <ref name="ibs"/>
          </optional>
          <optional>
            <ref name="tcgfeatures"/>
          </optional>
          <optional>
            <element name="async-teardown">
              <optional>
                <attribute name="enabled">
                  <ref name="virYesNo"/>
                </attribute>
              </optional>
            </element>
          </optional>
          <optional>
            <element name="ras">
              <ref name="featurestate"/>
            </element>
          </optional>
          <optional>
            <element name="ps2">
              <ref name="featurestate"/>
            </element>
          </optional>
          <optional>
            <ref name="aia"/>
          </optional>
          <optional>
            <element name="virtualization">
              <empty/>
            </element>
          </optional>
        </interleave>
      </element>
    </optional>
  </define>

  <!--
      System information specification:
       Placeholder for system specific information likes the ones
       contained in the SMBIOS area.
       Only a limited subset of entries can be modified there, so we
       fully enumerate each case here.
       The DMTF spec doesn't specify any string subset, just 0 terminated
       byte strings, but better be safe and restrict at least the names
       to avoid problems with space normalization in attribute values,
       the value is kept as the element body for maximum flexibility.
       A priori we allow only type 0 and type 1 string updates
      -->
  <define name="sysinfo">
    <element name="sysinfo">
      <choice>
        <group>
          <attribute name="type">
            <value>smbios</value>
          </attribute>
          <interleave>
            <ref name="sysinfo-smbios-group-bios"/>
            <ref name="sysinfo-smbios-group-system"/>
            <ref name="sysinfo-smbios-group-baseboard"/>
            <ref name="sysinfo-smbios-group-chassis"/>
            <ref name="sysinfo-smbios-group-oemstrings"/>
          </interleave>
        </group>
        <group>
          <attribute name="type">
            <value>fwcfg</value>
          </attribute>
          <zeroOrMore>
            <ref name="sysinfo-fwcfg-entry"/>
          </zeroOrMore>
        </group>
      </choice>
    </element>
  </define>

  <define name="acpiTable">
    <element name="acpi">
      <zeroOrMore>
        <element name="table">
          <attribute name="type">
            <choice>
              <value>raw</value>
              <value>rawset</value>
              <value>slic</value>
              <value>msdm</value>
            </choice>
          </attribute>
          <ref name="absFilePath"/>
        </element>
      </zeroOrMore>
    </element>
  </define>

  <define name="smbios">
    <element name="smbios">
      <attribute name="mode">
        <choice>
          <value>emulate</value>
          <value>host</value>
          <value>sysinfo</value>
        </choice>
      </attribute>
      <empty/>
    </element>
  </define>

  <define name="bios">
    <element name="bios">
      <optional>
        <attribute name="useserial">
          <ref name="virYesNo"/>
        </attribute>
      </optional>
      <optional>
        <attribute name="rebootTimeout">
          <ref name="rebootTimeoutDelay"/>
        </attribute>
      </optional>
    </element>
  </define>

  <define name="ioapic">
    <element name="ioapic">
      <attribute name="driver">
        <choice>
          <value>qemu</value>
          <value>kvm</value>
        </choice>
      </attribute>
      <empty/>
    </element>
  </define>

  <define name="hpt">
    <element name="hpt">
      <optional>
        <attribute name="resizing">
          <choice>
            <value>enabled</value>
            <value>disabled</value>
            <value>required</value>
          </choice>
        </attribute>
      </optional>
      <optional>
        <element name="maxpagesize">
          <ref name="scaledInteger"/>
        </element>
      </optional>
    </element>
  </define>

  <define name="vmcoreinfo">
    <element name="vmcoreinfo">
      <optional>
        <attribute name="state">
          <ref name="virOnOff"/>
        </attribute>
      </optional>
    </element>
  </define>

  <define name="msrs">
    <element name="msrs">
      <attribute name="unknown">
        <choice>
          <value>ignore</value>
          <value>fault</value>
        </choice>
      </attribute>
    </element>
  </define>

  <define name="cfpc">
    <element name="cfpc">
      <attribute name="value">
        <choice>
          <value>broken</value>
          <value>workaround</value>
          <value>fixed</value>
        </choice>
      </attribute>
    </element>
  </define>

  <define name="sbbc">
    <element name="sbbc">
      <attribute name="value">
        <choice>
          <value>broken</value>
          <value>workaround</value>
          <value>fixed</value>
        </choice>
      </attribute>
    </element>
  </define>

  <define name="ibs">
    <element name="ibs">
      <attribute name="value">
        <choice>
          <value>broken</value>
          <value>workaround</value>
          <value>fixed-ibs</value>
          <value>fixed-ccd</value>
          <value>fixed-na</value>
        </choice>
      </attribute>
    </element>
  </define>

  <define name="tcgfeatures">
    <element name="tcg">
      <optional>
        <element name="tb-cache">
          <ref name="scaledInteger"/>
        </element>
      </optional>
    </element>
  </define>

  <define name="aia">
    <element name="aia">
      <attribute name="value">
        <choice>
          <value>none</value>
          <value>aplic</value>
          <value>aplic-imsic</value>
        </choice>
      </attribute>
    </element>
  </define>

  <define name="address">
    <element name="address">
      <choice>
        <group>
          <attribute name="type">
            <value>pci</value>
          </attribute>
          <ref name="pciaddress"/>
          <ref name="zpciaddress"/>
        </group>
        <group>
          <attribute name="type">
            <value>drive</value>
          </attribute>
          <ref name="driveaddress"/>
        </group>
        <group>
          <attribute name="type">
            <value>virtio-serial</value>
          </attribute>
          <ref name="virtioserialaddress"/>
        </group>
        <group>
          <attribute name="type">
            <value>ccid</value>
          </attribute>
          <ref name="ccidaddress"/>
        </group>
        <group>
          <attribute name="type">
            <value>usb</value>
          </attribute>
          <ref name="usbportaddress"/>
        </group>
        <group>
          <attribute name="type">
            <value>spapr-vio</value>
          </attribute>
          <ref name="spaprvioaddress"/>
        </group>
        <group>
          <attribute name="type">
            <value>ccw</value>
          </attribute>
          <ref name="ccwaddress"/>
        </group>
        <group>
          <attribute name="type">
            <value>isa</value>
          </attribute>
          <ref name="isaaddress"/>
        </group>
        <group>
          <attribute name="type">
            <value>virtio-mmio</value>
          </attribute>
        </group>
        <group>
          <attribute name="type">
            <value>dimm</value>
          </attribute>
          <ref name="dimmaddress"/>
        </group>
        <group>
          <attribute name="type">
            <value>unassigned</value>
          </attribute>
        </group>
      </choice>
    </element>
  </define>

  <define name="rom">
    <element name="rom">
      <optional>
        <attribute name="enabled">
          <ref name="virYesNo"/>
        </attribute>
      </optional>
      <optional>
        <attribute name="bar">
          <ref name="virOnOff"/>
        </attribute>
      </optional>
      <optional>
        <attribute name="file">
          <ref name="absFilePath"/>
        </attribute>
      </optional>
      <empty/>
    </element>
  </define>

  <define name="acpi">
    <element name="acpi">
      <optional>
        <attribute name="index">
          <ref name="unsignedInt"/>
        </attribute>
      </optional>
      <optional>
        <attribute name="nodeset">
          <ref name="cpuset"/>
        </attribute>
      </optional>
    </element>
  </define>

  <define name="memorydev">
    <element name="memory">
      <attribute name="model">
        <choice>
          <value>dimm</value>
          <value>nvdimm</value>
          <value>virtio-pmem</value>
          <value>virtio-mem</value>
          <value>sgx-epc</value>
        </choice>
      </attribute>
      <optional>
        <attribute name="access">
          <choice>
            <value>shared</value>
            <value>private</value>
          </choice>
        </attribute>
      </optional>
      <optional>
        <attribute name="discard">
          <ref name="virYesNo"/>
        </attribute>
      </optional>
      <interleave>
        <optional>
          <element name="uuid">
            <ref name="UUID"/>
          </element>
        </optional>
        <optional>
          <element name="driver">
            <ref name="virtioOptions"/>
          </element>
        </optional>
        <optional>
          <ref name="memorydev-source"/>
        </optional>
        <ref name="memorydev-target"/>
        <optional>
          <ref name="address"/>
        </optional>
        <optional>
          <ref name="alias"/>
        </optional>
        <optional>
          <ref name="acpi"/>
        </optional>
      </interleave>
    </element>
  </define>

  <define name="memorydev-source">
    <element name="source">
      <choice>
        <group>
          <interleave>
            <optional>
              <element name="pagesize">
                <ref name="scaledInteger"/>
              </element>
            </optional>
            <optional>
              <element name="nodemask">
                <ref name="cpuset"/>
              </element>
            </optional>
          </interleave>
        </group>
        <group>
          <interleave>
            <element name="path">
              <ref name="absFilePath"/>
            </element>
            <optional>
              <element name="alignsize">
                <ref name="scaledInteger"/>
              </element>
            </optional>
            <optional>
              <element name="pmem">
                <empty/>
              </element>
            </optional>
          </interleave>
        </group>
      </choice>
    </element>
  </define>

  <define name="memorydev-target">
    <element name="target">
      <optional>
        <attribute name="dynamicMemslots">
          <ref name="virYesNo"/>
        </attribute>
      </optional>
      <interleave>
        <element name="size">
          <ref name="scaledInteger"/>
        </element>
        <optional>
          <element name="node">
            <ref name="unsignedInt"/>
          </element>
        </optional>
        <optional>
          <element name="block">
            <ref name="scaledInteger"/>
          </element>
        </optional>
        <optional>
          <element name="requested">
            <ref name="scaledInteger"/>
          </element>
        </optional>
        <optional>
          <element name="current">
            <ref name="scaledInteger"/>
          </element>
        </optional>
        <optional>
          <element name="label">
            <element name="size">
              <ref name="scaledInteger"/>
            </element>
          </element>
        </optional>
        <optional>
          <element name="readonly">
            <empty/>
          </element>
        </optional>
        <optional>
          <element name="address">
            <attribute name="base">
              <ref name="hexuint"/>
            </attribute>
          </element>
        </optional>
      </interleave>
    </element>
  </define>

  <define name="rng">
    <element name="rng">
      <attribute name="model">
        <choice>
          <value>virtio</value>
          <value>virtio-transitional</value>
          <value>virtio-non-transitional</value>
        </choice>
      </attribute>
      <interleave>
        <ref name="rng-backend"/>
        <optional>
          <element name="driver">
            <ref name="virtioOptions"/>
          </element>
        </optional>
        <optional>
          <ref name="rng-rate"/>
        </optional>
        <optional>
          <ref name="alias"/>
        </optional>
        <optional>
          <ref name="acpi"/>
        </optional>
        <optional>
          <ref name="address"/>
        </optional>
      </interleave>
    </element>
  </define>

  <define name="rng-backend">
    <element name="backend">
      <choice>
        <group>
          <attribute name="model">
            <value>random</value>
          </attribute>
          <choice>
            <ref name="absFilePath"/>
            <empty/>
          </choice>
        </group>
        <group>
          <attribute name="model">
            <value>egd</value>
          </attribute>
          <ref name="qemucdevSrcType"/>
          <ref name="qemucdevSrcDef"/>
        </group>
        <group>
          <attribute name="model">
            <value>builtin</value>
          </attribute>
          <empty/>
        </group>
      </choice>
    </element>
  </define>

  <define name="rng-rate">
    <element name="rate">
      <attribute name="bytes">
        <ref name="positiveInteger"/>
      </attribute>
      <optional>
        <attribute name="period">
          <ref name="positiveInteger"/>
        </attribute>
      </optional>
      <empty/>
    </element>
  </define>

  <define name="crypto">
    <element name="crypto">
      <attribute name="model">
        <choice>
          <value>virtio</value>
        </choice>
      </attribute>
      <attribute name="type">
        <choice>
          <value>qemu</value>
        </choice>
      </attribute>
      <interleave>
        <ref name="crypto-backend"/>
        <optional>
          <element name="driver">
            <ref name="virtioOptions"/>
          </element>
        </optional>
        <optional>
          <ref name="alias"/>
        </optional>
        <optional>
          <ref name="address"/>
        </optional>
      </interleave>
    </element>
  </define>

  <define name="crypto-backend">
    <element name="backend">
      <choice>
        <group>
          <attribute name="model">
            <value>builtin</value>
          </attribute>
          <optional>
            <attribute name="queues">
              <ref name="positiveInteger"/>
            </attribute>
          </optional>
        </group>
        <group>
          <attribute name="model">
            <value>lkcf</value>
          </attribute>
          <optional>
            <attribute name="queues">
              <ref name="positiveInteger"/>
            </attribute>
          </optional>
        </group>
      </choice>
    </element>
  </define>


  <define name="virtioOptions">
    <optional>
      <attribute name="iommu">
        <ref name="virOnOff"/>
      </attribute>
    </optional>
    <optional>
      <attribute name="ats">
        <ref name="virOnOff"/>
      </attribute>
    </optional>
    <optional>
      <attribute name="packed">
        <ref name="virOnOff"/>
      </attribute>
    </optional>
    <optional>
      <attribute name="page_per_vq">
        <ref name="virOnOff"/>
      </attribute>
    </optional>
  </define>

  <define name="usbmaster">
    <element name="master">
      <attribute name="startport">
        <ref name="usbPort"/>
      </attribute>
      <empty/>
    </element>
  </define>

  <define name="deviceBoot">
    <element name="boot">
      <attribute name="order">
        <ref name="positiveInteger"/>
      </attribute>
      <optional>
        <attribute name="loadparm">
          <data type="string">
            <param name="pattern">[a-zA-Z0-9.\s]{1,8}</param>
          </data>
        </attribute>
      </optional>
      <empty/>
    </element>
  </define>

  <define name="diskMirror">
    <element name="mirror">
      <interleave>
        <choice>
          <group> <!-- old format, for block copy back-compat -->
            <attribute name="file">
              <ref name="absFilePath"/>
            </attribute>
            <optional>
              <attribute name="format">
                <ref name="storageFormat"/>
              </attribute>
            </optional>
            <optional>
              <attribute name="job">
                <value>copy</value>
              </attribute>
            </optional>
            <optional>
              <interleave>
                <ref name="diskSourceFile"/>
                <optional>
                  <ref name="diskFormat"/>
                </optional>
              </interleave>
            </optional>
          </group>
          <group> <!-- preferred format -->
            <attribute name="job">
              <choice>
                <value>copy</value>
                <value>active-commit</value>
              </choice>
            </attribute>
            <interleave>
              <ref name="diskSource"/>
              <optional>
                <ref name="diskFormat"/>
              </optional>
            </interleave>
          </group>
        </choice>
        <optional>
          <attribute name="ready">
            <choice>
              <value>yes</value>
              <value>abort</value>
              <value>pivot</value>
            </choice>
          </attribute>
        </optional>
        <ref name="diskBackingChain"/>
      </interleave>
    </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="objectName"/>
        </attribute>
      </choice>
    </element>
  </define>

  <define name="iotune">
    <interleave>
      <choice>
        <element name="total_bytes_sec">
          <data type="unsignedLong"/>
        </element>
        <group>
          <interleave>
            <optional>
              <element name="read_bytes_sec">
                <data type="unsignedLong"/>
              </element>
            </optional>
            <optional>
              <element name="write_bytes_sec">
                <data type="unsignedLong"/>
              </element>
            </optional>
          </interleave>
        </group>
      </choice>
      <choice>
        <element name="total_iops_sec">
          <data type="unsignedLong"/>
        </element>
        <group>
          <interleave>
            <optional>
              <element name="read_iops_sec">
                <data type="unsignedLong"/>
              </element>
            </optional>
            <optional>
              <element name="write_iops_sec">
                <data type="unsignedLong"/>
              </element>
            </optional>
          </interleave>
        </group>
      </choice>
      <choice>
        <element name="total_bytes_sec_max">
          <data type="unsignedLong"/>
        </element>
        <group>
          <interleave>
            <optional>
              <element name="read_bytes_sec_max">
                <data type="unsignedLong"/>
              </element>
            </optional>
            <optional>
              <element name="write_bytes_sec_max">
                <data type="unsignedLong"/>
              </element>
            </optional>
          </interleave>
        </group>
      </choice>
      <choice>
        <element name="total_iops_sec_max">
          <data type="unsignedLong"/>
        </element>
        <group>
          <interleave>
            <optional>
              <element name="read_iops_sec_max">
                <data type="unsignedLong"/>
              </element>
            </optional>
            <optional>
              <element name="write_iops_sec_max">
                <data type="unsignedLong"/>
              </element>
            </optional>
          </interleave>
        </group>
      </choice>
      <optional>
        <element name="size_iops_sec">
          <data type="unsignedLong"/>
        </element>
      </optional>
      <optional>
        <element name="group_name">
          <text/>
        </element>
      </optional>
      <choice>
        <element name="total_bytes_sec_max_length">
          <data type="unsignedLong"/>
        </element>
        <group>
          <interleave>
            <optional>
              <element name="read_bytes_sec_max_length">
                <data type="unsignedLong"/>
              </element>
            </optional>
            <optional>
              <element name="write_bytes_sec_max_length">
                <data type="unsignedLong"/>
              </element>
            </optional>
          </interleave>
        </group>
      </choice>
      <choice>
        <element name="total_iops_sec_max_length">
          <data type="unsignedLong"/>
        </element>
        <group>
          <interleave>
            <optional>
              <element name="read_iops_sec_max_length">
                <data type="unsignedLong"/>
              </element>
            </optional>
            <optional>
              <element name="write_iops_sec_max_length">
                <data type="unsignedLong"/>
              </element>
            </optional>
          </interleave>
        </group>
      </choice>
    </interleave>
  </define>

  <define name="diskIoTune">
    <element name="iotune">
      <ref name="iotune"/>
    </element>
  </define>

  <define name="pflashFormatTypes">
    <choice>
      <value>raw</value>
      <value>qcow2</value>
    </choice>
  </define>

  <define name="pflashFormat">
    <attribute name="format">
      <ref name="pflashFormatTypes"/>
    </attribute>
  </define>

  <!-- Optional HyperV Enlightenment features -->
  <define name="hyperv">
    <element name="hyperv">
      <choice>
        <attribute name="mode">
          <value>passthrough</value>
        </attribute>
        <group>
          <optional>
            <attribute name="mode">
              <choice>
                <value>custom</value>
                <value>host-model</value>
              </choice>
            </attribute>
          </optional>
          <interleave>
            <optional>
              <element name="relaxed">
                <ref name="featurestate"/>
              </element>
            </optional>
            <optional>
              <element name="vapic">
                <ref name="featurestate"/>
              </element>
            </optional>
            <optional>
              <element name="spinlocks">
                <ref name="featurestate"/>
                <optional>
                  <attribute name="retries">
                    <data type="unsignedInt"/>
                  </attribute>
                </optional>
              </element>
            </optional>
            <optional>
              <element name="vpindex">
                <ref name="featurestate"/>
              </element>
            </optional>
            <optional>
              <element name="runtime">
                <ref name="featurestate"/>
              </element>
            </optional>
            <optional>
              <element name="synic">
                <ref name="featurestate"/>
              </element>
            </optional>
            <optional>
              <element name="stimer">
                <ref name="stimer"/>
              </element>
            </optional>
            <optional>
              <element name="reset">
                <ref name="featurestate"/>
              </element>
            </optional>
            <optional>
              <element name="vendor_id">
                <ref name="featurestate"/>
                <optional>
                  <attribute name="value">
                    <data type="string">
                      <param name="pattern">[^,]{0,12}</param>
                    </data>
                  </attribute>
                </optional>
              </element>
            </optional>
            <optional>
              <element name="frequencies">
                <ref name="featurestate"/>
              </element>
            </optional>
            <optional>
              <element name="reenlightenment">
                <ref name="featurestate"/>
              </element>
            </optional>
            <optional>
              <element name="tlbflush">
                <ref name="tlbflush"/>
              </element>
            </optional>
            <optional>
              <element name="ipi">
                <ref name="featurestate"/>
              </element>
            </optional>
            <optional>
              <element name="evmcs">
                <ref name="featurestate"/>
              </element>
            </optional>
            <optional>
              <element name="avic">
                <ref name="featurestate"/>
              </element>
            </optional>
            <optional>
              <element name="emsr_bitmap">
                <ref name="featurestate"/>
              </element>
            </optional>
            <optional>
              <element name="xmm_input">
                <ref name="featurestate"/>
              </element>
            </optional>
          </interleave>
        </group>
      </choice>
    </element>
  </define>

  <!-- Hyper-V stimer features -->
  <define name="stimer">
    <interleave>
      <optional>
        <ref name="featurestate"/>
      </optional>
      <optional>
        <element name="direct">
          <ref name="featurestate"/>
        </element>
      </optional>
    </interleave>
  </define>

  <!-- Hyper-V tlbflush features -->
  <define name="tlbflush">
    <interleave>
      <optional>
        <ref name="featurestate"/>
      </optional>
      <optional>
        <element name="direct">
          <ref name="featurestate"/>
        </element>
      </optional>
      <optional>
        <element name="extended">
          <ref name="featurestate"/>
        </element>
      </optional>
    </interleave>
  </define>

  <!-- Optional KVM features -->
  <define name="kvm">
    <element name="kvm">
      <interleave>
        <optional>
          <element name="hidden">
            <ref name="featurestate"/>
          </element>
        </optional>
        <optional>
          <element name="hint-dedicated">
            <ref name="featurestate"/>
          </element>
        </optional>
        <optional>
          <element name="poll-control">
            <ref name="featurestate"/>
          </element>
        </optional>
        <optional>
          <element name="pv-ipi">
            <ref name="featurestate"/>
          </element>
        </optional>
        <optional>
          <element name="dirty-ring">
            <ref name="featurestate"/>
            <optional>
              <attribute name="size">
                <data type="unsignedInt"/>
              </attribute>
            </optional>
          </element>
        </optional>
      </interleave>
    </element>
  </define>

  <!-- Optional Xen features -->
  <define name="xen">
    <element name="xen">
      <interleave>
        <optional>
          <element name="e820_host">
            <ref name="featurestate"/>
          </element>
        </optional>
        <optional>
          <element name="passthrough">
            <ref name="featurestate"/>
            <optional>
              <attribute name="mode">
                <data type="string">
                  <param name="pattern">(sync_pt|share_pt)</param>
                </data>
              </attribute>
            </optional>
          </element>
        </optional>
      </interleave>
    </element>
  </define>

  <!-- Optional capabilities features -->
  <define name="capabilities">
    <element name="capabilities">
      <ref name="capabilitiespolicy"/>
      <interleave>
        <optional>
          <element name="audit_control">
            <ref name="featurestate"/>
          </element>
        </optional>
        <optional>
          <element name="audit_write">
            <ref name="featurestate"/>
          </element>
        </optional>
        <optional>
          <element name="block_suspend">
            <ref name="featurestate"/>
          </element>
        </optional>
        <optional>
          <element name="chown">
            <ref name="featurestate"/>
          </element>
        </optional>
        <optional>
          <element name="dac_override">
            <ref name="featurestate"/>
          </element>
        </optional>
        <optional>
          <element name="dac_read_search">
            <ref name="featurestate"/>
          </element>
        </optional>
        <optional>
          <element name="fowner">
            <ref name="featurestate"/>
          </element>
        </optional>
        <optional>
          <element name="fsetid">
            <ref name="featurestate"/>
          </element>
        </optional>
        <optional>
          <element name="ipc_lock">
            <ref name="featurestate"/>
          </element>
        </optional>
        <optional>
          <element name="ipc_owner">
            <ref name="featurestate"/>
          </element>
        </optional>
        <optional>
          <element name="kill">
            <ref name="featurestate"/>
          </element>
        </optional>
        <optional>
          <element name="lease">
            <ref name="featurestate"/>
          </element>
        </optional>
        <optional>
          <element name="linux_immutable">
            <ref name="featurestate"/>
          </element>
        </optional>
        <optional>
          <element name="mac_admin">
            <ref name="featurestate"/>
          </element>
        </optional>
        <optional>
          <element name="mac_override">
            <ref name="featurestate"/>
          </element>
        </optional>
        <optional>
          <element name="mknod">
            <ref name="featurestate"/>
          </element>
        </optional>
        <optional>
          <element name="net_admin">
            <ref name="featurestate"/>
          </element>
        </optional>
        <optional>
          <element name="net_bind_service">
            <ref name="featurestate"/>
          </element>
        </optional>
        <optional>
          <element name="net_broadcast">
            <ref name="featurestate"/>
          </element>
        </optional>
        <optional>
          <element name="net_raw">
            <ref name="featurestate"/>
          </element>
        </optional>
        <optional>
          <element name="setgid">
            <ref name="featurestate"/>
          </element>
        </optional>
        <optional>
          <element name="setfcap">
            <ref name="featurestate"/>
          </element>
        </optional>
        <optional>
          <element name="setpcap">
            <ref name="featurestate"/>
          </element>
        </optional>
        <optional>
          <element name="setuid">
            <ref name="featurestate"/>
          </element>
        </optional>
        <optional>
          <element name="sys_admin">
            <ref name="featurestate"/>
          </element>
        </optional>
        <optional>
          <element name="sys_boot">
            <ref name="featurestate"/>
          </element>
        </optional>
        <optional>
          <element name="sys_chroot">
            <ref name="featurestate"/>
          </element>
        </optional>
        <optional>
          <element name="sys_module">
            <ref name="featurestate"/>
          </element>
        </optional>
        <optional>
          <element name="sys_nice">
            <ref name="featurestate"/>
          </element>
        </optional>
        <optional>
          <element name="sys_pacct">
            <ref name="featurestate"/>
          </element>
        </optional>
        <optional>
          <element name="sys_ptrace">
            <ref name="featurestate"/>
          </element>
        </optional>
        <optional>
          <element name="sys_rawio">
            <ref name="featurestate"/>
          </element>
        </optional>
        <optional>
          <element name="sys_resource">
            <ref name="featurestate"/>
          </element>
        </optional>
        <optional>
          <element name="sys_time">
            <ref name="featurestate"/>
          </element>
        </optional>
        <optional>
          <element name="sys_tty_config">
            <ref name="featurestate"/>
          </element>
        </optional>
        <optional>
          <element name="syslog">
            <ref name="featurestate"/>
          </element>
        </optional>
        <optional>
          <element name="wake_alarm">
            <ref name="featurestate"/>
          </element>
        </optional>
      </interleave>
    </element>
  </define>

  <define name="pmu">
    <element name="pmu">
      <optional>
        <ref name="featurestate"/>
      </optional>
    </element>
  </define>

  <define name="featurestate">
    <attribute name="state">
      <ref name="virOnOff"/>
    </attribute>
  </define>

  <define name="capabilitiespolicy">
    <attribute name="policy">
      <choice>
        <value>default</value>
        <value>allow</value>
        <value>deny</value>
      </choice>
    </attribute>
  </define>

  <!--
       Optional hypervisor extensions in their own namespace:
         QEMU
    -->
  <define name="qemucmdline">
    <element name="commandline" ns="http://libvirt.org/schemas/domain/qemu/1.0">
      <interleave>
        <zeroOrMore>
          <element name="arg">
            <attribute name="value"/>
          </element>
        </zeroOrMore>
        <zeroOrMore>
          <element name="env">
            <attribute name="name">
              <ref name="filter-param-name"/>
            </attribute>
            <optional>
              <attribute name="value"/>
            </optional>
            <empty/>
          </element>
        </zeroOrMore>
      </interleave>
    </element>
  </define>

  <define name="qemucapabilities">
    <element name="capabilities" ns="http://libvirt.org/schemas/domain/qemu/1.0">
      <interleave>
        <zeroOrMore>
          <element name="add">
            <attribute name="capability"/>
          </element>
        </zeroOrMore>
        <zeroOrMore>
          <element name="del">
            <attribute name="capability"/>
          </element>
        </zeroOrMore>
      </interleave>
    </element>
  </define>

  <define name="qemudeprecation">
    <element name="deprecation" ns="http://libvirt.org/schemas/domain/qemu/1.0">
      <attribute name="behavior">
        <choice>
          <value>none</value>
          <value>omit</value>
          <value>reject</value>
          <value>crash</value>
        </choice>
      </attribute>
    </element>
  </define>

  <define name="qemuoverrideproperty">
    <element name="property" ns="http://libvirt.org/schemas/domain/qemu/1.0">
      <attribute name="name"/>
      <attribute name="type">
        <choice>
          <value>string</value>
          <value>signed</value>
          <value>unsigned</value>
          <value>bool</value>
          <value>remove</value>
        </choice>
      </attribute>
      <optional>
        <attribute name="value"/>
      </optional>
    </element>
  </define>

  <define name="qemuoverride">
    <element name="override" ns="http://libvirt.org/schemas/domain/qemu/1.0">
      <interleave>
        <zeroOrMore>
          <element name="device">
            <attribute name="alias"/>
            <interleave>
              <optional>
                <element name="frontend">
                  <zeroOrMore>
                    <ref name="qemuoverrideproperty"/>
                  </zeroOrMore>
                </element>
              </optional>
            </interleave>
          </element>
        </zeroOrMore>
      </interleave>
    </element>
  </define>


  <!--
       Optional hypervisor extensions in their own namespace:
       LXC
    -->
  <define name="lxcsharens">
    <element name="namespace" ns="http://libvirt.org/schemas/domain/lxc/1.0">
      <interleave>
        <optional>
          <element name="sharenet">
            <attribute name="type">
              <choice>
                <value>netns</value>
                <value>name</value>
                <value>pid</value>
              </choice>
            </attribute>
            <attribute name="value"/>
          </element>
        </optional>
        <optional>
          <element name="shareipc">
            <attribute name="type">
              <choice>
                <value>name</value>
                <value>pid</value>
              </choice>
            </attribute>
            <attribute name="value"/>
          </element>
        </optional>
        <optional>
          <element name="shareuts">
            <attribute name="type">
              <choice>
                <value>name</value>
                <value>pid</value>
              </choice>
            </attribute>
            <attribute name="value"/>
          </element>
        </optional>
      </interleave>
    </element>
  </define>

  <!--
       Optional hypervisor extensions in their own namespace:
         Bhyve
    -->
  <define name="bhyvecmdline">
    <element name="commandline" ns="http://libvirt.org/schemas/domain/bhyve/1.0">
      <zeroOrMore>
        <element name="arg">
          <attribute name="value"/>
        </element>
      </zeroOrMore>
    </element>
  </define>

  <!--
       Optional hypervisor extensions in their own namespace:
         Xen
    -->
  <define name="xencmdline">
    <element name="commandline" ns="http://libvirt.org/schemas/domain/xen/1.0">
      <zeroOrMore>
        <element name="arg">
          <attribute name="value"/>
        </element>
      </zeroOrMore>
    </element>
  </define>

  <!--
       Optional hypervisor extensions in their own namespace:
         vmware
    -->
  <define name="vmwaredatacenterpath">
    <element name="datacenterpath" ns="http://libvirt.org/schemas/domain/vmware/1.0">
      <text/>
    </element>
  </define>

  <!--
       Type library
    -->
  <define name="countCPU">
    <data type="unsignedShort">
      <param name="pattern">[0-9]+</param>
      <param name="minInclusive">1</param>
    </data>
  </define>
  <define name="vcpuid">
    <data type="unsignedShort">
      <param name="pattern">[0-9]+</param>
    </data>
  </define>
  <define name="cpushares">
    <data type="unsignedInt">
      <param name="pattern">[0-9]+</param>
    </data>
  </define>
  <define name="cpuperiod">
    <data type="unsignedLong">
      <param name="pattern">[0-9]+</param>
      <param name="minInclusive">1000</param>
      <param name="maxInclusive">1000000</param>
    </data>
  </define>
  <define name="cpuquota">
    <data type="long">
      <param name="pattern">-?[0-9]+</param>
      <param name="maxInclusive">17592186044415</param>
      <param name="minInclusive">-1</param>
    </data>
  </define>
  <define name="rebootTimeoutDelay">
    <data type="short">
      <param name="minInclusive">-1</param>
    </data>
  </define>
  <!-- weight currently is in range [100, 1000] -->
  <define name="weight">
    <data type="unsignedInt">
      <param name="pattern">[0-9]+</param>
      <param name="minInclusive">100</param>
      <param name="maxInclusive">1000</param>
    </data>
  </define>
  <define name="diskSerial">
    <data type="string">
      <param name="pattern">[A-Za-z0-9_\.\+\- ]+</param>
    </data>
  </define>
  <define name="bridgeMode">
    <data type="string">
      <param name="pattern">(vepa|bridge|private|passthrough)</param>
    </data>
  </define>
  <define name="addrIPorName">
    <choice>
      <ref name="ipAddr"/>
      <ref name="dnsName"/>
    </choice>
  </define>
  <define name="driveController">
    <data type="string">
      <param name="pattern">[0-9]{1,2}</param>
    </data>
  </define>
  <define name="driveBus">
    <data type="string">
      <param name="pattern">[0-9]{1,2}</param>
    </data>
  </define>
  <define name="driveTarget">
    <data type="string">
      <param name="pattern">[0-9]{1,2}</param>
    </data>
  </define>
  <define name="driveSCSITarget">
    <data type="string">
      <param name="pattern">[0-9]{1,10}</param>
    </data>
  </define>
  <define name="driveUnit">
    <data type="string">
      <param name="pattern">[0-9]{1,5}</param>
    </data>
  </define>
  <define name="driveSCSIUnit">
    <data type="string">
      <param name="pattern">[0-9]{1,20}</param>
    </data>
  </define>
  <define name="timeDelta">
    <data type="string">
      <param name="pattern">(-|\+)?[0-9]+</param>
    </data>
  </define>
  <define name="timeZone">
    <data type="string">
      <param name="pattern">[a-zA-Z0-9_\.\+\-/]+</param>
    </data>
  </define>
  <define name="spaprvioReg">
    <data type="string">
      <param name="pattern">(0x)?[0-9a-fA-F]{1,8}</param>
    </data>
  </define>
  <define name="aliasName">
    <data type="string">
      <param name="pattern">[a-zA-Z0-9_\-.]+</param>
    </data>
  </define>
  <define name="virtioserialPort">
    <data type="string">
      <param name="pattern">[0-9]{1,2}</param>
    </data>
  </define>
  <define name="ccidSlot">
    <data type="string">
      <param name="pattern">[0-9]{1,2}</param>
    </data>
  </define>
  <define name="alias">
    <element name="alias">
      <attribute name="name">
        <ref name="aliasName"/>
      </attribute>
    </element>
    <empty/>
  </define>
  <define name="panic">
    <element name="panic">
      <optional>
        <attribute name="model">
          <choice>
            <value>isa</value>
            <value>pseries</value>
            <value>hyperv</value>
            <value>s390</value>
            <value>pvpanic</value>
          </choice>
        </attribute>
      </optional>
      <interleave>
        <optional>
          <ref name="alias"/>
        </optional>
        <optional>
          <ref name="address"/>
        </optional>
      </interleave>
    </element>
  </define>
  <define name="rawIO">
    <attribute name="rawio">
      <ref name="virYesNo"/>
    </attribute>
  </define>
  <define name="sgIO">
    <attribute name="sgio">
      <choice>
        <value>filtered</value>
        <value>unfiltered</value>
      </choice>
    </attribute>
  </define>

  <define name="coalesce">
    <element name="coalesce">
      <interleave>
        <optional>
          <element name="rx">
            <optional>
              <element name="frames">
                <optional>
                  <attribute name="max">
                    <ref name="unsignedInt"/>
                  </attribute>
                </optional>
                <!--
                    This is how we'd add more Rx-related settings for
                    frames, like irq, high, and low

                <optional>
                  <attribute name="irq">
                    <ref name="unsignedInt"/>
                  </attribute>
                </optional>
                <optional>
                  <attribute name="high">
                    <ref name="unsignedInt"/>
                  </attribute>
                </optional>
                <optional>
                  <attribute name="low">
                    <ref name="unsignedInt"/>
                  </attribute>
                </optional>

              -->
              </element>
            </optional>
            <!--
                This is how we'd add more Rx-related settings, like
                usecs

            <optional>
              <element name="usecs">
                <optional>
                  <attribute name="max">
                    <ref name="unsignedInt"/>
                  </attribute>
                </optional>
                <optional>
                  <attribute name="irq">
                    <ref name="unsignedInt"/>
                  </attribute>
                </optional>
                <optional>
                  <attribute name="high">
                    <ref name="unsignedInt"/>
                  </attribute>
                </optional>
                <optional>
                  <attribute name="low">
                    <ref name="unsignedInt"/>
                  </attribute>
                </optional>
              </element>
            </optional>
              -->
          </element>
        </optional>
        <!--
            This is how you would add more coalesce settings, like
            Tx-related ones

        <optional>
          <element name="tx">
            <optional>
              <element name="frames">
                <optional>
                  <attribute name="max">
                    <ref name="unsignedInt"/>
                  </attribute>
                </optional>
                <optional>
                  <attribute name="irq">
                    <ref name="unsignedInt"/>
                  </attribute>
                </optional>
                <optional>
                  <attribute name="high">
                    <ref name="unsignedInt"/>
                  </attribute>
                </optional>
                <optional>
                  <attribute name="low">
                    <ref name="unsignedInt"/>
                  </attribute>
                </optional>
              </element>
            </optional>
            <optional>
              <element name="usecs">
                <optional>
                  <attribute name="max">
                    <ref name="unsignedInt"/>
                  </attribute>
                </optional>
                <optional>
                  <attribute name="irq">
                    <ref name="unsignedInt"/>
                  </attribute>
                </optional>
                <optional>
                  <attribute name="high">
                    <ref name="unsignedInt"/>
                  </attribute>
                </optional>
                <optional>
                  <attribute name="low">
                    <ref name="unsignedInt"/>
                  </attribute>
                </optional>
              </element>
            </optional>
          </element>
        </optional>
        -->
      </interleave>
    </element>
  </define>

</grammar>
