Description of problem: when device/interface/source element has a bridge attribute (which is produced by lxc creation) as follow, virt-xml-validate will pop an error. <interface type='network'> <mac address='00:16:3e:54:f2:8c'/> <source network='default' bridge='virbr0'/> <target dev='vnet7'/> <guest dev='eth0'/> </interface> Version-Release number of selected component (if applicable): libvirt-1.2.8-11.el7.x86_64 qemu-kvm-rhev-2.1.2-17.el7.x86_64 kernel-3.10.0-220.el7.x86_64 How reproducible: 100% repro Steps to Reproduce: 1. create /tmp/test.xml as follow: <domain type='lxc' id='3211'> <name>test</name> <uuid>02ea2ce6-55c7-4c4b-aef2-cddf9edecc8f</uuid> <memory unit='KiB'>1048576</memory> <currentMemory unit='KiB'>1048576</currentMemory> <vcpu placement='static'>1</vcpu> <resource> <partition>/machine</partition> </resource> <os> <type arch='x86_64'>exe</type> <init>/bin/sh</init> </os> <clock offset='utc'/> <on_poweroff>destroy</on_poweroff> <on_reboot>restart</on_reboot> <on_crash>restart</on_crash> <devices> <emulator>/usr/libexec/libvirt_lxc</emulator> <filesystem type='mount' accessmode='passthrough'> <source dir='/'/> <target dir='/'/> </filesystem> <interface type='network'> <mac address='00:16:3e:54:f2:8c'/> <source network='default'/> <target dev='vnet0'/> </interface> <console type='pty' tty='/dev/pts/1'> <source path='/dev/pts/1'/> <target type='lxc' port='0'/> <alias name='console0'/> </console> </devices> <seclabel type='none' model='selinux'/> </domain> 2. create and start a lxc with following cmds: #virsh -c lxc:/// define test.xml #virsh -c lxc:/// start test 3. dumpxml the lxc "tset" as follow: #virsh -c lxc:/// dumpxml test > /tmp/a.xml 4.#vim /tmp/a.xml In /tmp/a.xml, we can see a "bridge" attribute added in "device/interface/source" element, as follow: ... <interface type='network'> <mac address='00:16:3e:54:f2:8c'/> <source network='default' bridge='virbr0'/> <target dev='vnet7'/> <guest dev='eth0'/> </interface> ... 5. use virt-xml-validate to validate /tmp/test.xml and /tmp/a.xml test.xml successes but a.xml fails! as follow: # virt-xml-validate /tmp/test.xml test.xml validates # virt-xml-validate /tmp/a.xml Relax-NG validity error : Extra element devices in interleave a.xml:1: element domain: Relax-NG validity error : Element domain failed to validate content a.xml fails to validate Actual results: test.xml validated but a.xml fails to validate. Expected results: both test.xml and a.xml should be validated. Additional info: The only difference is that a.xml include a device/interface/source/bridge attribute.
*** Bug 1261790 has been marked as a duplicate of this bug. ***
Add one more scenario, on domain type of 'kvm', the validate command will fail as well. Version-Release number of selected component (if applicable): libvirt-1.3.2-1.el7.x86_64 qemu-kvm-rhev-2.3.0-31.el7_2.5.x86_64 steps to reproduce: 1. # virsh start R7.2 Domain R7.2 started 2. # virsh dumpxml R7.2 <domain type='kvm' id='33'> <name>R7.2</name> ...... <interface type='network'> <mac address='52:54:00:fa:12:cc'/> <source network='default' bridge='virb119'/> <target dev='vnet1'/> <model type='rtl8139'/> <alias name='net0'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> </interface> ..... # virsh dumpxml R7.2 > b.xml # virt-xml-validate b.xml Relax-NG validity error : Extra element devices in interleave b.xml:34: element devices: Relax-NG validity error : Element domain failed to validate content b.xml fails to validate 3. delete the "bridge='virbr119'" in b.xml # vim b.xml # virt-xml-validate b.xml b.xml validates # echo $? 0
The attribute 'macTableManager' has same issue. Add latest test results here for your reference: RHEL7.5 # rpm -q libvirt qemu-kvm-rhev libvirt-3.9.0-7.el7.x86_64 qemu-kvm-rhev-2.10.0-16.el7.x86_64 1.# cat V-bridge-macTableManager.xml|grep 'source network' <source network='default' bridge='virbr0' macTableManager='libvirt'/> # virt-xml-validate V-bridge-macTableManager.xml V-bridge-macTableManager.xml validates # echo $? 0 2.If use "virsh edit", the domain xml can be successfully saved. But the "bridge='virbr0' macTableManager='libvirt'" will disappear When check the xml again by virsh edit. RHEL7.3 libvirt-2.0.0-10.el7_3.11.x86_64 qemu-kvm-rhev-2.6.0-28.el7_3.15.x86_64 1.# cat q35-bridge.xml |grep 'source network' <source network='default' bridge='virbr0' macTableManager='libvirt'/> # virt-xml-validate q35-bridge.xml Relax-NG validity error : Extra element devices in interleave q35-bridge.xml:33: element devices: Relax-NG validity error : Element domain failed to validate content q35-bridge.xml fails to validate # cat q35-macTableManager.xml |grep 'source network' <source network='default' macTableManager='libvirt' /> # virt-xml-validate q35-macTableManager.xml Relax-NG validity error : Extra element devices in interleave q35-macTableManager.xml:33: element devices: Relax-NG validity error : Element domain failed to validate content q35-macTableManager.xml fails to validate 2.If use virsh edit, both of xml with them will fail to save: # virsh edit q35 error: XML document failed to validate against schema: Unable to validate doc against /usr/share/libvirt/schemas/domain.rng Extra element devices in interleave Element domain failed to validate content Failed. Try again? [y,n,i,f,?]:
Thank you for reporting this issue to the libvirt project. Unfortunately we have been unable to resolve this issue due to insufficient maintainer capacity and it will now be closed. This is not a reflection on the possible validity of the issue, merely the lack of resources to investigate and address it, for which we apologise. If you none the less feel the issue is still important, you may choose to report it again at the new project issue tracker https://gitlab.com/libvirt/libvirt/-/issues The project also welcomes contribution from anyone who believes they can provide a solution.