[PATCH 00/15] schema: Fix forgotten interleaving of elements (part 1)

Context: https://listman.redhat.com/archives/libvir-list/2022-October/234860.html This series fixes the trivial/straightforward cases found by using Daniel's "fuzzing" script. Note that you have to exclude '-invalid.xml' files and all output-only XMLs (domaincaps, capabilities). Best viewed with 'git show -w'. There's 7 more pathces needed to fix the schema to work with the above mentioned script but they have more complex interactions and I'll need to re-consider them. Peter Krempa (15): schema: domain: Allow interleaving of character device config elements schema: domain: Allow interleaving of PCI controller config elements schema: domain: Allow interleaving of 'tpm' config elements schema: domain: Allow interleaving of subelements of 'memtune' schema: domain: Allow interleaving of subelements of disk's 'mirror' schema: domain: Allow interleaving 'ip' and 'route' sub-elements of interface schema: domain: Add the 'type' subelement of the osexe case of 'os' element to interleave schema: domain: Allow interleaving of <bootloader> and <os> schema: domain: Allow interleaving of 'watchdog' subelements schema: networkport: Allow interleaving of subelements of 'owner' schema: networkport: Allow interleaving of subelements of 'driver' subelement of hostdev-pci schema: nwfilter: Allow interleaving subelements of the top level 'filter' element schema: nwfilterbinding: Allow interleaving of subelements of 'owner' element schema: storagepool: Allow interleaving of per-pool custom namespace elements schema: cpu: include 'arch' subelement in interleave definition of 'hostcpu' src/conf/schemas/cputypes.rng | 6 +- src/conf/schemas/domaincommon.rng | 813 ++++++++++++++------------- src/conf/schemas/networkport.rng | 42 +- src/conf/schemas/nwfilter.rng | 36 +- src/conf/schemas/nwfilterbinding.rng | 14 +- src/conf/schemas/storagepool.rng | 12 +- 6 files changed, 476 insertions(+), 447 deletions(-) -- 2.37.3

Allow interleaving in the 'qemucdevSrcDef' definition which is shared by all places using character device as backend. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/conf/schemas/domaincommon.rng | 143 +++++++++++++++--------------- 1 file changed, 73 insertions(+), 70 deletions(-) diff --git a/src/conf/schemas/domaincommon.rng b/src/conf/schemas/domaincommon.rng index d346442510..49a61d2748 100644 --- a/src/conf/schemas/domaincommon.rng +++ b/src/conf/schemas/domaincommon.rng @@ -4716,82 +4716,85 @@ <ref name="qemucdevSrcTypeChoice"/> </attribute> </define> + <define name="qemucdevSrcDef"> - <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> + <interleave> + <zeroOrMore> + <element name="source"> <optional> - <ref name="clipboard"/> + <attribute name="mode"/> </optional> <optional> - <ref name="mousemode"/> + <attribute name="path"/> </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"/> + <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> - </element> - </optional> + <optional> + <attribute name="append"> + <ref name="virOnOff"/> + </attribute> + </optional> + </element> + </optional> + </interleave> </define> <!-- The description for a console -- 2.37.3

The 'model' and 'target' element can be freely moved around. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/conf/schemas/domaincommon.rng | 190 +++++++++++++++--------------- 1 file changed, 96 insertions(+), 94 deletions(-) diff --git a/src/conf/schemas/domaincommon.rng b/src/conf/schemas/domaincommon.rng index 49a61d2748..ecc9cd41c4 100644 --- a/src/conf/schemas/domaincommon.rng +++ b/src/conf/schemas/domaincommon.rng @@ -2691,103 +2691,105 @@ <attribute name="type"> <value>pci</value> </attribute> - <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"/> + <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> - </optional> - <optional> - <attribute name="index"> - <ref name="uint8"/> + <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> + </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> - <optional> - <attribute name="hotplug"> - <ref name="virOnOff"/> + <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> - </optional> - <optional> - <element name="node"> - <ref name="unsignedInt"/> - </element> - </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> + </group> + </choice> + </interleave> </group> <!-- virtio-serial has optional "ports" and "vectors" --> <group> -- 2.37.3

Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/conf/schemas/domaincommon.rng | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/conf/schemas/domaincommon.rng b/src/conf/schemas/domaincommon.rng index ecc9cd41c4..ea10d13a4f 100644 --- a/src/conf/schemas/domaincommon.rng +++ b/src/conf/schemas/domaincommon.rng @@ -5535,13 +5535,15 @@ </choice> </attribute> </optional> - <ref name="tpm-backend"/> - <optional> - <ref name="alias"/> - </optional> - <optional> - <ref name="address"/> - </optional> + <interleave> + <ref name="tpm-backend"/> + <optional> + <ref name="alias"/> + </optional> + <optional> + <ref name="address"/> + </optional> + </interleave> </element> </define> @@ -5556,10 +5558,12 @@ </group> <group> <attribute name="type"> - <value>emulator</value> + <value>emulator</value> </attribute> - <ref name="tpm-backend-emulator-encryption"/> - <ref name="tpm-backend-emulator-active-pcr-banks"/> + <interleave> + <ref name="tpm-backend-emulator-encryption"/> + <ref name="tpm-backend-emulator-active-pcr-banks"/> + </interleave> <optional> <attribute name="persistent_state"> <ref name="virYesNo"/> -- 2.37.3

Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/conf/schemas/domaincommon.rng | 50 ++++++++++++++++--------------- 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/src/conf/schemas/domaincommon.rng b/src/conf/schemas/domaincommon.rng index ea10d13a4f..99a705aa3c 100644 --- a/src/conf/schemas/domaincommon.rng +++ b/src/conf/schemas/domaincommon.rng @@ -956,30 +956,32 @@ <!-- All the memory/swap related tunables would go in the memtune --> <define name="memtune"> <element name="memtune"> - <!-- 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> + <!-- 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> -- 2.37.3

While for now the 'mirror' element is output only, the idea was to allow it to be used for input too to restore the mirror job if that becomes the necessity. Allowing interleaving of the subelements can be done regardless. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/conf/schemas/domaincommon.rng | 79 ++++++++++++++++--------------- 1 file changed, 41 insertions(+), 38 deletions(-) diff --git a/src/conf/schemas/domaincommon.rng b/src/conf/schemas/domaincommon.rng index 99a705aa3c..a1b004921b 100644 --- a/src/conf/schemas/domaincommon.rng +++ b/src/conf/schemas/domaincommon.rng @@ -7141,57 +7141,60 @@ <define name="diskMirror"> <element name="mirror"> - <choice> - <group> <!-- old format, for block copy back-compat --> - <attribute name="file"> - <ref name="absFilePath"/> - </attribute> - <optional> - <attribute name="format"> - <ref name="storageFormat"/> + <interleave> + <choice> + <group> <!-- old format, for block copy back-compat --> + <attribute name="file"> + <ref name="absFilePath"/> </attribute> - </optional> - <optional> + <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"> - <value>copy</value> + <choice> + <value>copy</value> + <value>active-commit</value> + </choice> </attribute> - </optional> - <optional> <interleave> - <ref name="diskSourceFile"/> + <ref name="diskSource"/> <optional> <ref name="diskFormat"/> </optional> </interleave> - </optional> - </group> - <group> <!-- preferred format --> - <attribute name="job"> + </group> + </choice> + <optional> + <attribute name="ready"> <choice> - <value>copy</value> - <value>active-commit</value> + <value>yes</value> + <value>abort</value> + <value>pivot</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"/> + </optional> + <ref name="diskBackingChain"/> + </interleave> </element> </define> + <define name="diskAuth"> <element name="auth"> <attribute name="username"> -- 2.37.3

Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/conf/schemas/domaincommon.rng | 50 ++++++++++++++++--------------- 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/src/conf/schemas/domaincommon.rng b/src/conf/schemas/domaincommon.rng index a1b004921b..b6371940e4 100644 --- a/src/conf/schemas/domaincommon.rng +++ b/src/conf/schemas/domaincommon.rng @@ -3806,32 +3806,34 @@ All ip-related info for either the host or guest side of an interface --> <define name="interface-ip-info"> - <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"> + <interleave> + <zeroOrMore> + <element name="ip"> + <attribute name="address"> <ref name="ipAddr"/> </attribute> - </optional> - <empty/> - </element> - </zeroOrMore> - <zeroOrMore> - <ref name="route"/> - </zeroOrMore> + <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="teaming"> -- 2.37.3

The 'type' element was outside of the 'interleave' definition. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/conf/schemas/domaincommon.rng | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/conf/schemas/domaincommon.rng b/src/conf/schemas/domaincommon.rng index b6371940e4..2801f8fcb8 100644 --- a/src/conf/schemas/domaincommon.rng +++ b/src/conf/schemas/domaincommon.rng @@ -438,15 +438,15 @@ <define name="osexe"> <element name="os"> - <element name="type"> - <optional> - <attribute name="arch"> - <ref name="archnames"/> - </attribute> - </optional> - <value>exe</value> - </element> <interleave> + <element name="type"> + <optional> + <attribute name="arch"> + <ref name="archnames"/> + </attribute> + </optional> + <value>exe</value> + </element> <optional> <element name="init"> <ref name="absFilePath"/> -- 2.37.3

Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/conf/schemas/domaincommon.rng | 203 +++++++++++++++--------------- 1 file changed, 103 insertions(+), 100 deletions(-) diff --git a/src/conf/schemas/domaincommon.rng b/src/conf/schemas/domaincommon.rng index 2801f8fcb8..57457d1aa8 100644 --- a/src/conf/schemas/domaincommon.rng +++ b/src/conf/schemas/domaincommon.rng @@ -281,116 +281,119 @@ </choice> </define> <define name="oshvm"> - <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"> + <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> - <attribute name="name"> + </optional> + <optional> + <attribute name="secure"> + <ref name="virYesNo"/> + </attribute> + </optional> + <optional> + <attribute name="type"> <choice> - <value>enrolled-keys</value> - <value>secure-boot</value> + <value>rom</value> + <value>pflash</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"> + </optional> + <optional> + <attribute name="stateless"> + <ref name="virYesNo"/> + </attribute> + </optional> + <optional> + <ref name="absFilePath"/> + </optional> + </element> + </optional> + <optional> + <element name="nvram"> + <optional> + <attribute name="template"> + <ref name="absFilePath"/> + </attribute> + </optional> + <optional> <choice> - <value>rom</value> - <value>pflash</value> + <group> + <ref name="absFilePath"/> + </group> + <group> + <ref name="diskSource"/> + </group> </choice> - </attribute> - </optional> - <optional> - <attribute name="stateless"> + </optional> + </element> + </optional> + <optional> + <ref name="osbootkernel"/> + </optional> + <zeroOrMore> + <ref name="osbootdev"/> + </zeroOrMore> + <optional> + <element name="bootmenu"> + <attribute name="enable"> <ref name="virYesNo"/> </attribute> - </optional> - <optional> - <ref name="absFilePath"/> - </optional> - </element> - </optional> - <optional> - <element name="nvram"> - <optional> - <attribute name="template"> - <ref name="absFilePath"/> - </attribute> - </optional> - <optional> - <choice> - <group> - <ref name="absFilePath"/> - </group> - <group> - <ref name="diskSource"/> - </group> - </choice> - </optional> - </element> - </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> + <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> -- 2.37.3

Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/conf/schemas/domaincommon.rng | 54 ++++++++++++++++--------------- 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/src/conf/schemas/domaincommon.rng b/src/conf/schemas/domaincommon.rng index 57457d1aa8..ebdf21fe99 100644 --- a/src/conf/schemas/domaincommon.rng +++ b/src/conf/schemas/domaincommon.rng @@ -5264,35 +5264,37 @@ </define> <define name="watchdog"> <element name="watchdog"> - <attribute name="model"> - <choice> - <value>i6300esb</value> - <value>ib700</value> - <value>diag288</value> - </choice> - </attribute> - <optional> - <attribute name="action"> + <interleave> + <attribute name="model"> <choice> - <value>reset</value> - <value>shutdown</value> - <value>poweroff</value> - <value>pause</value> - <value>none</value> - <value>dump</value> - <value>inject-nmi</value> + <value>i6300esb</value> + <value>ib700</value> + <value>diag288</value> </choice> </attribute> - </optional> - <optional> - <ref name="alias"/> - </optional> - <optional> - <ref name="acpi"/> - </optional> - <optional> - <ref name="address"/> - </optional> + <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"> -- 2.37.3

Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/conf/schemas/networkport.rng | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/conf/schemas/networkport.rng b/src/conf/schemas/networkport.rng index 1a12a32c3c..2ca76c10df 100644 --- a/src/conf/schemas/networkport.rng +++ b/src/conf/schemas/networkport.rng @@ -44,12 +44,14 @@ <define name="owner"> <element name="owner"> - <element name="name"> - <text/> - </element> - <element name="uuid"> - <ref name="UUID"/> - </element> + <interleave> + <element name="name"> + <text/> + </element> + <element name="uuid"> + <ref name="UUID"/> + </element> + </interleave> </element> </define> -- 2.37.3

Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/conf/schemas/networkport.rng | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/conf/schemas/networkport.rng b/src/conf/schemas/networkport.rng index 2ca76c10df..14db949578 100644 --- a/src/conf/schemas/networkport.rng +++ b/src/conf/schemas/networkport.rng @@ -143,20 +143,22 @@ <ref name="virYesNo"/> </attribute> </optional> - <optional> - <element name="driver"> - <attribute name="name"> - <choice> - <value>kvm</value> - <value>vfio</value> - </choice> - </attribute> - <empty/> + <interleave> + <optional> + <element name="driver"> + <attribute name="name"> + <choice> + <value>kvm</value> + <value>vfio</value> + </choice> + </attribute> + <empty/> + </element> + </optional> + <element name="address"> + <ref name="pciaddress"/> </element> - </optional> - <element name="address"> - <ref name="pciaddress"/> - </element> + </interleave> </define> </grammar> -- 2.37.3

Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/conf/schemas/nwfilter.rng | 36 ++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/src/conf/schemas/nwfilter.rng b/src/conf/schemas/nwfilter.rng index a75de7ed3e..262bd551e3 100644 --- a/src/conf/schemas/nwfilter.rng +++ b/src/conf/schemas/nwfilter.rng @@ -7,20 +7,21 @@ </start> <define name="filter"> <element name="filter"> - <ref name="filter-node-attributes"/> - <optional> - <element name="uuid"> - <ref name="UUID"/> - </element> - </optional> - <zeroOrMore> - <choice> - <element name="filterref"> - <ref name="filterref-node-attributes"/> + <interleave> + <ref name="filter-node-attributes"/> + <optional> + <element name="uuid"> + <ref name="UUID"/> </element> - <element name="rule"> - <ref name="rule-node-attributes"/> - <choice> + </optional> + <zeroOrMore> + <choice> + <element name="filterref"> + <ref name="filterref-node-attributes"/> + </element> + <element name="rule"> + <ref name="rule-node-attributes"/> + <choice> <empty/> <element name="mac"> <ref name="match-attribute"/> @@ -199,10 +200,11 @@ <ref name="common-ipv6-attributes-p2"/> <ref name="comment-attribute"/> </element> - </choice> - </element> - </choice> - </zeroOrMore> + </choice> + </element> + </choice> + </zeroOrMore> + </interleave> </element> </define> -- 2.37.3

Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/conf/schemas/nwfilterbinding.rng | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/conf/schemas/nwfilterbinding.rng b/src/conf/schemas/nwfilterbinding.rng index a0a956eb01..c91312b09d 100644 --- a/src/conf/schemas/nwfilterbinding.rng +++ b/src/conf/schemas/nwfilterbinding.rng @@ -12,12 +12,14 @@ <element name="filterbinding"> <interleave> <element name="owner"> - <element name="name"> - <text/> - </element> - <element name="uuid"> - <ref name="UUID"/> - </element> + <interleave> + <element name="name"> + <text/> + </element> + <element name="uuid"> + <ref name="UUID"/> + </element> + </interleave> </element> <element name="portdev"> -- 2.37.3

The custom namespace parameters for 'rbd' and 'netfs' pool types were not included in the interleave statement. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/conf/schemas/storagepool.rng | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/conf/schemas/storagepool.rng b/src/conf/schemas/storagepool.rng index d81ead532a..63a8b75fd8 100644 --- a/src/conf/schemas/storagepool.rng +++ b/src/conf/schemas/storagepool.rng @@ -69,10 +69,10 @@ <ref name="features"/> <ref name="sourcenetfs"/> <ref name="target"/> + <optional> + <ref name="fs_mount_opts"/> + </optional> </interleave> - <optional> - <ref name="fs_mount_opts"/> - </optional> </define> <define name="poollogical"> @@ -166,10 +166,10 @@ <ref name="features"/> <ref name="sourcerbd"/> <ref name="refresh"/> + <optional> + <ref name="rbd_config_opts"/> + </optional> </interleave> - <optional> - <ref name="rbd_config_opts"/> - </optional> </define> <define name="poolsheepdog"> -- 2.37.3

Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/conf/schemas/cputypes.rng | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/conf/schemas/cputypes.rng b/src/conf/schemas/cputypes.rng index 986a5f3715..3e79bdd563 100644 --- a/src/conf/schemas/cputypes.rng +++ b/src/conf/schemas/cputypes.rng @@ -323,10 +323,10 @@ <define name="hostcpu"> <element name="cpu"> - <element name="arch"> - <ref name="archnames"/> - </element> <interleave> + <element name="arch"> + <ref name="archnames"/> + </element> <optional> <element name="features"> <optional> -- 2.37.3

On a Monday in 2022, Peter Krempa wrote:
Context:
https://listman.redhat.com/archives/libvir-list/2022-October/234860.html
This series fixes the trivial/straightforward cases found by using Daniel's "fuzzing" script. Note that you have to exclude '-invalid.xml' files and all output-only XMLs (domaincaps, capabilities).
Best viewed with 'git show -w'.
There's 7 more pathces needed to fix the schema to work with the above mentioned script but they have more complex interactions and I'll need to re-consider them.
Peter Krempa (15): schema: domain: Allow interleaving of character device config elements schema: domain: Allow interleaving of PCI controller config elements schema: domain: Allow interleaving of 'tpm' config elements schema: domain: Allow interleaving of subelements of 'memtune' schema: domain: Allow interleaving of subelements of disk's 'mirror' schema: domain: Allow interleaving 'ip' and 'route' sub-elements of interface schema: domain: Add the 'type' subelement of the osexe case of 'os' element to interleave schema: domain: Allow interleaving of <bootloader> and <os> schema: domain: Allow interleaving of 'watchdog' subelements schema: networkport: Allow interleaving of subelements of 'owner' schema: networkport: Allow interleaving of subelements of 'driver' subelement of hostdev-pci schema: nwfilter: Allow interleaving subelements of the top level 'filter' element schema: nwfilterbinding: Allow interleaving of subelements of 'owner' element schema: storagepool: Allow interleaving of per-pool custom namespace elements schema: cpu: include 'arch' subelement in interleave definition of 'hostcpu'
src/conf/schemas/cputypes.rng | 6 +- src/conf/schemas/domaincommon.rng | 813 ++++++++++++++------------- src/conf/schemas/networkport.rng | 42 +- src/conf/schemas/nwfilter.rng | 36 +- src/conf/schemas/nwfilterbinding.rng | 14 +- src/conf/schemas/storagepool.rng | 12 +- 6 files changed, 476 insertions(+), 447 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano
participants (2)
-
Ján Tomko
-
Peter Krempa