The exact same element can appear in <hostdev> and <interface
type='hostdev'>, and nearly identical in <network> and
<networkport>
(these latter two don't include "xen" as a possible driver, but that's
coincidental - there's no reason Xen couldn't also use the VF pools in
virtual networks, it just doesn't).
This patch modifies all 4 to use the same <ref name="hostdevDriver"/>
so that it is simpler to add something new.
A side effect of this patch is that the grammar for the <interface>
element in domain XML has been tightened up a bit - previously it was
accepted by the schema (but nonsensical) to have virtio and network
interface options specified; as a part of making the two different
<driver> choices each a complete element (rather than each being a
collection of attributes and subelements) these extra
attributes/subelements that were irrelevant to the hostdev-type
<driver> were made to be valid only for an emulated interface's
<driver>.
Signed-off-by: Laine Stump <laine(a)redhat.com>
---
src/conf/schemas/basictypes.rng | 13 +++
src/conf/schemas/domaincommon.rng | 173 ++++++++++++++----------------
src/conf/schemas/network.rng | 10 +-
src/conf/schemas/networkport.rng | 10 +-
4 files changed, 94 insertions(+), 112 deletions(-)
diff --git a/src/conf/schemas/basictypes.rng b/src/conf/schemas/basictypes.rng
index 26eb538077..8d5f4475ca 100644
--- a/src/conf/schemas/basictypes.rng
+++ b/src/conf/schemas/basictypes.rng
@@ -656,4 +656,17 @@
</choice>
</define>
+ <define name="hostdevDriver">
+ <element name="driver">
+ <attribute name="name">
+ <choice>
+ <value>kvm</value>
+ <value>vfio</value>
+ <value>xen</value>
+ </choice>
+ </attribute>
+ <empty/>
+ </element>
+ </define>
+
</grammar>
diff --git a/src/conf/schemas/domaincommon.rng b/src/conf/schemas/domaincommon.rng
index a26986b5ce..002587db58 100644
--- a/src/conf/schemas/domaincommon.rng
+++ b/src/conf/schemas/domaincommon.rng
@@ -3759,18 +3759,12 @@
</element>
</optional>
<optional>
- <element name="driver">
- <choice>
- <group>
- <attribute name="name">
- <choice>
- <value>kvm</value>
- <value>vfio</value>
- <value>xen</value>
- </choice>
- </attribute>
- </group>
- <group>
+ <choice>
+ <group>
+ <ref name="hostdevDriver"/>
+ </group>
+ <group>
+ <element name="driver">
<optional>
<attribute name="name">
<choice>
@@ -3808,90 +3802,90 @@
<optional>
<ref name="event_idx"/>
</optional>
- </group>
- </choice>
- <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>
+ <ref name="virtioOptions"/>
+ <interleave>
<optional>
- <attribute name="tso4">
- <ref name="virOnOff"/>
- </attribute>
+ <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>
- <attribute name="tso6">
- <ref name="virOnOff"/>
- </attribute>
+ <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="ecn">
+ <attribute name="rss">
<ref name="virOnOff"/>
</attribute>
</optional>
<optional>
- <attribute name="ufo">
+ <attribute name="rss_hash_report">
<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>
+ </interleave>
+ </element>
+ </group>
+ </choice>
</optional>
<optional>
<ref name="alias"/>
@@ -6182,16 +6176,7 @@
</attribute>
<interleave>
<optional>
- <element name="driver">
- <attribute name="name">
- <choice>
- <value>kvm</value>
- <value>vfio</value>
- <value>xen</value>
- </choice>
- </attribute>
- <empty/>
- </element>
+ <ref name="hostdevDriver"/>
</optional>
<optional>
<ref name="teaming"/>
diff --git a/src/conf/schemas/network.rng b/src/conf/schemas/network.rng
index cda174ab4b..e56e07d130 100644
--- a/src/conf/schemas/network.rng
+++ b/src/conf/schemas/network.rng
@@ -179,15 +179,7 @@
</element>
</optional>
<optional>
- <element name="driver">
- <attribute name="name">
- <choice>
- <value>kvm</value>
- <value>vfio</value>
- </choice>
- </attribute>
- <empty/>
- </element>
+ <ref name="hostdevDriver"/>
</optional>
<optional>
<element name="nat">
diff --git a/src/conf/schemas/networkport.rng b/src/conf/schemas/networkport.rng
index 14db949578..50995559e8 100644
--- a/src/conf/schemas/networkport.rng
+++ b/src/conf/schemas/networkport.rng
@@ -145,15 +145,7 @@
</optional>
<interleave>
<optional>
- <element name="driver">
- <attribute name="name">
- <choice>
- <value>kvm</value>
- <value>vfio</value>
- </choice>
- </attribute>
- <empty/>
- </element>
+ <ref name="hostdevDriver"/>
</optional>
<element name="address">
<ref name="pciaddress"/>
--
2.41.0