<?xml version="1.0"?>
<!-- A Relax NG schema for the libvirt domain capabilities XML format -->
<grammar xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
  <include href="basictypes.rng"/>
  <include href="cputypes.rng"/>
  <start>
    <ref name="domainCapabilities"/>
  </start>


  <define name="domainCapabilities">
    <element name="domainCapabilities">
      <interleave>
        <optional>
          <element name="path">
            <ref name="absFilePath"/>
          </element>
        </optional>
        <element name="domain">
          <text/>
        </element>
        <optional>
          <element name="machine">
            <text/>
          </element>
        </optional>
        <element name="arch">
          <text/>
        </element>
        <optional>
          <ref name="vcpu"/>
        </optional>
        <optional>
          <ref name="iothreads"/>
        </optional>
        <optional>
          <ref name="os"/>
        </optional>
        <optional>
          <ref name="cpu"/>
        </optional>
        <optional>
          <ref name="memoryBacking"/>
        </optional>
        <optional>
          <ref name="devices"/>
        </optional>
        <optional>
          <ref name="features"/>
        </optional>
      </interleave>
    </element>
  </define>

  <define name="vcpu">
    <element name="vcpu">
      <attribute name="max">
        <ref name="unsignedInt"/>
      </attribute>
      <empty/>
    </element>
  </define>

  <define name="iothreads">
    <element name="iothreads">
      <ref name="supported"/>
      <empty/>
    </element>
  </define>

  <define name="firmwareFeatures">
    <element name="firmwareFeatures">
      <ref name="supported"/>
      <optional>
        <ref name="enum"/>
      </optional>
    </element>
  </define>

  <define name="loader">
    <element name="loader">
      <ref name="supported"/>
      <optional>
        <ref name="value"/>
      </optional>
      <ref name="enum"/>
    </element>
  </define>

  <define name="varstore">
    <element name="varstore">
      <ref name="supported"/>
    </element>
  </define>

  <define name="os">
    <element name="os">
      <interleave>
        <ref name="supported"/>
        <ref name="enum"/>
        <optional>
          <ref name="firmwareFeatures"/>
        </optional>
        <optional>
          <ref name="loader"/>
        </optional>
        <optional>
          <ref name="varstore"/>
        </optional>
      </interleave>
    </element>
  </define>

  <define name="cpu">
    <element name="cpu">
      <ref name="cpuHost"/>
      <ref name="cpuMax"/>
      <ref name="cpuHostModel"/>
      <ref name="cpuCustom"/>
    </element>
  </define>

  <define name="cpuHost">
    <element name="mode">
      <attribute name="name">
        <value>host-passthrough</value>
      </attribute>
      <ref name="supported"/>
      <optional>
        <ref name="enum"/>
      </optional>
    </element>
  </define>

  <define name="cpuMax">
    <element name="mode">
      <attribute name="name">
        <value>maximum</value>
      </attribute>
      <ref name="supported"/>
      <optional>
        <ref name="enum"/>
      </optional>
    </element>
  </define>

  <define name="cpuHostModel">
    <element name="mode">
      <attribute name="name">
        <value>host-model</value>
      </attribute>
      <ref name="supported"/>
      <optional>
        <ref name="cpuModel"/>
        <optional>
          <ref name="cpuVendor"/>
        </optional>
        <optional>
          <ref name="cpuMaxPhysAddr"/>
        </optional>
        <zeroOrMore>
          <ref name="cpuFeature"/>
        </zeroOrMore>
      </optional>
    </element>
  </define>

  <define name="cpuCustom">
    <element name="mode">
      <attribute name="name">
        <value>custom</value>
      </attribute>
      <ref name="supported"/>
      <zeroOrMore>
        <element name="model">
          <attribute name="usable">
            <choice>
              <value>yes</value>
              <value>no</value>
              <value>unknown</value>
            </choice>
          </attribute>
          <optional>
            <attribute name="deprecated">
              <ref name="virYesNo"/>
            </attribute>
          </optional>
          <optional>
            <attribute name="canonical">
              <text/>
            </attribute>
          </optional>
          <attribute name='vendor'>
            <text/>
          </attribute>
          <text/>
        </element>
        <optional>
          <element name="blockers">
            <attribute name="model">
              <text/>
            </attribute>
            <oneOrMore>
              <element name="feature">
                <attribute name="name">
                  <text/>
                </attribute>
              </element>
            </oneOrMore>
          </element>
        </optional>
      </zeroOrMore>
    </element>
  </define>

  <define name="memoryBacking">
    <element name="memoryBacking">
      <ref name="supported"/>
      <ref name="enum"/>
    </element>
  </define>

  <define name="devices">
    <element name="devices">
      <optional>
        <ref name="disk"/>
      </optional>
      <optional>
        <ref name="graphics"/>
      </optional>
      <optional>
        <ref name="video"/>
      </optional>
      <optional>
        <ref name="hostdev"/>
      </optional>
      <optional>
        <ref name="rng"/>
      </optional>
      <optional>
        <ref name="filesystem"/>
      </optional>
      <optional>
        <ref name="tpm"/>
      </optional>
      <optional>
        <ref name="redirdev"/>
      </optional>
      <optional>
        <ref name="channel"/>
      </optional>
      <optional>
        <ref name="crypto"/>
      </optional>
      <optional>
        <ref name="interface"/>
      </optional>
      <optional>
        <ref name="panic"/>
      </optional>
      <optional>
        <ref name="console"/>
      </optional>
    </element>
  </define>

  <define name="disk">
    <element name="disk">
      <ref name="supported"/>
      <ref name="enum"/>
    </element>
  </define>

  <define name="graphics">
    <element name="graphics">
      <ref name="supported"/>
      <ref name="enum"/>
    </element>
  </define>

  <define name="video">
    <element name="video">
      <ref name="supported"/>
      <ref name="enum"/>
    </element>
  </define>

  <define name="hostdev">
    <element name="hostdev">
      <ref name="supported"/>
      <ref name="enum"/>
    </element>
  </define>

  <define name="rng">
    <element name="rng">
      <ref name="supported"/>
      <ref name="enum"/>
    </element>
  </define>

  <define name="filesystem">
    <element name="filesystem">
      <ref name="supported"/>
      <ref name="enum"/>
    </element>
  </define>

  <define name="tpm">
    <element name="tpm">
      <ref name="supported"/>
      <ref name="enum"/>
    </element>
  </define>

  <define name="redirdev">
    <element name="redirdev">
      <ref name="supported"/>
      <ref name="enum"/>
    </element>
  </define>

  <define name="channel">
    <element name="channel">
      <ref name="supported"/>
      <ref name="enum"/>
    </element>
  </define>

  <define name="crypto">
    <element name="crypto">
      <ref name="supported"/>
      <ref name="enum"/>
    </element>
  </define>

  <define name="panic">
    <element name="panic">
      <ref name="supported"/>
      <ref name="enum"/>
    </element>
  </define>

  <define name="console">
    <element name="console">
      <ref name="supported"/>
      <ref name="enum"/>
    </element>
  </define>

  <define name="interface">
    <element name="interface">
      <ref name="supported"/>
      <ref name="enum"/>
    </element>
  </define>

  <define name="launchSecurity">
    <element name="launchSecurity">
      <ref name="supported"/>
      <ref name="enum"/>
    </element>
  </define>

  <define name="features">
    <element name="features">
      <optional>
        <ref name="gic"/>
      </optional>
      <optional>
        <ref name="vmcoreinfo"/>
      </optional>
      <optional>
        <ref name="vmgenid"/>
      </optional>
      <optional>
        <ref name="backingStoreInput"/>
      </optional>
      <optional>
        <ref name="backup"/>
      </optional>
      <optional>
        <ref name="async-teardown"/>
      </optional>
      <optional>
        <ref name="s390-pv"/>
      </optional>
      <optional>
        <ref name="ps2"/>
      </optional>
      <optional>
        <ref name="tdx"/>
      </optional>
      <optional>
        <ref name="sev"/>
      </optional>
      <optional>
        <ref name="sgx"/>
      </optional>
      <optional>
        <ref name="hyperv"/>
      </optional>
      <optional>
        <ref name='launchSecurity'/>
      </optional>
    </element>
  </define>

  <define name="async-teardown">
    <element name="async-teardown">
      <ref name="supported"/>
    </element>
  </define>

  <define name="gic">
    <element name="gic">
      <ref name="supported"/>
      <ref name="enum"/>
    </element>
  </define>

  <define name="vmcoreinfo">
    <element name="vmcoreinfo">
      <ref name="supported"/>
    </element>
  </define>

  <define name="vmgenid">
    <element name="genid">
      <ref name="supported"/>
    </element>
  </define>

  <define name="backingStoreInput">
    <element name="backingStoreInput">
      <ref name="supported"/>
    </element>
  </define>

  <define name="backup">
    <element name="backup">
      <ref name="supported"/>
    </element>
  </define>

  <define name="s390-pv">
    <element name="s390-pv">
      <ref name="supported"/>
    </element>
  </define>

  <define name="ps2">
    <element name="ps2">
      <ref name="supported"/>
    </element>
  </define>

  <define name="tdx">
    <element name="tdx">
      <ref name="supported"/>
    </element>
  </define>

  <define name="sev">
    <element name="sev">
      <ref name="supported"/>
      <optional>
        <element name="cbitpos">
          <data type="unsignedInt"/>
        </element>
        <element name="reducedPhysBits">
          <data type="unsignedInt"/>
        </element>
        <element name="maxGuests">
          <data type="unsignedInt"/>
        </element>
        <element name="maxESGuests">
          <data type="unsignedInt"/>
        </element>
      </optional>
      <optional>
        <element name="cpu0Id">
          <data type="string"/>
        </element>
      </optional>
    </element>
  </define>

  <define name="sgx">
    <element name="sgx">
      <ref name="supported"/>
      <optional>
        <element name="flc">
          <ref name="virYesNo"/>
        </element>
        <element name="sgx1">
          <ref name="virYesNo"/>
        </element>
        <element name="sgx2">
          <ref name="virYesNo"/>
        </element>
        <element name="section_size">
          <attribute name="unit">
            <value>KiB</value>
          </attribute>
          <data type="unsignedLong"/>
        </element>
        <optional>
          <element name="sections">
            <zeroOrMore>
              <element name="section">
                <attribute name="node">
                  <data type="unsignedInt"/>
                </attribute>
                <attribute name="size">
                  <data type="unsignedLong"/>
                </attribute>
                <attribute name="unit">
                  <value>KiB</value>
                </attribute>
              </element>
            </zeroOrMore>
          </element>
        </optional>
      </optional>
    </element>
  </define>

  <define name="hyperv">
    <element name="hyperv">
      <ref name="supported"/>
      <ref name="enum"/>
      <optional>
        <element name="defaults">
          <optional>
            <element name="spinlocks">
              <ref name="unsignedInt"/>
            </element>
          </optional>
          <optional>
            <element name="stimer_direct">
              <ref name="virOnOff"/>
            </element>
          </optional>
          <optional>
            <element name="tlbflush_direct">
              <ref name="virOnOff"/>
            </element>
          </optional>
          <optional>
            <element name="tlbflush_extended">
              <ref name="virOnOff"/>
            </element>
          </optional>
          <optional>
            <element name="vendor_id">
              <text/>
            </element>
          </optional>
        </element>
      </optional>
    </element>
  </define>

  <define name="value">
    <zeroOrMore>
      <element name="value">
        <text/>
      </element>
    </zeroOrMore>
  </define>

  <define name="supported">
    <attribute name="supported">
      <ref name="virYesNo"/>
    </attribute>
  </define>

  <define name="enum">
    <zeroOrMore>
      <element name="enum">
        <attribute name="name">
          <text/>
        </attribute>
        <ref name="value"/>
      </element>
    </zeroOrMore>
  </define>
</grammar>
