Bug 685083
| Summary: | virt-xml-validate fails if xml is generated from running domain | ||
|---|---|---|---|
| Product: | Red Hat Enterprise Linux 6 | Reporter: | weizhang <weizhan> |
| Component: | libvirt | Assignee: | Osier Yang <jyang> |
| Status: | CLOSED ERRATA | QA Contact: | Virtualization Bugs <virt-bugs> |
| Severity: | high | Docs Contact: | |
| Priority: | low | ||
| Version: | 6.1 | CC: | berrange, dallan, dyuan, eblake, gren, jyang, llim, mshao, mzhan, rwu, veillard, yupzhang |
| Target Milestone: | rc | Keywords: | Reopened |
| Target Release: | --- | ||
| Hardware: | x86_64 | ||
| OS: | Linux | ||
| Whiteboard: | |||
| Fixed In Version: | libvirt-0.9.10-1.el6 | Doc Type: | Bug Fix |
| Doc Text: |
No documentation needed.
|
Story Points: | --- |
| Clone Of: | Environment: | ||
| Last Closed: | 2012-06-20 06:26:32 UTC | Type: | --- |
| Regression: | --- | Mount Type: | --- |
| Documentation: | --- | CRM: | |
| Verified Versions: | Category: | --- | |
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
| Cloudforms Team: | --- | Target Upstream Version: | |
| Embargoed: | |||
# diff -Nurb vr-rhel6-x86_64-kvm.xml vr-rhel6-x86_64-kvm-shut.xml
--- vr-rhel6-x86_64-kvm.xml 2011-03-15 17:09:46.434524674 +0800
+++ vr-rhel6-x86_64-kvm-shut.xml 2011-03-15 16:59:22.593712597 +0800
@@ -1,4 +1,4 @@
-<domain type='kvm' id='6'>
+<domain type='kvm'>
<name>vr-rhel6-x86_64-kvm</name>
<uuid>697d236f-56a4-0f83-e40e-6b5d93a46415</uuid>
<memory>524288</memory>
@@ -23,50 +23,35 @@
<driver name='qemu' type='raw'/>
<source file='/var/lib/libvirt/images/vr-rhel6-x86_64-kvm'/>
<target dev='hda' bus='ide'/>
- <alias name='ide0-0-0'/>
<address type='drive' controller='0' bus='0' unit='0'/>
</disk>
<controller type='ide' index='0'>
- <alias name='ide0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
</controller>
<interface type='network'>
<mac address='52:54:00:48:a1:db'/>
<source network='default'/>
- <target dev='vnet0'/>
<model type='rtl8139'/>
- <alias name='net0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</interface>
<serial type='pty'>
- <source path='/dev/pts/2'/>
<target port='0'/>
- <alias name='serial0'/>
</serial>
- <console type='pty' tty='/dev/pts/2'>
- <source path='/dev/pts/2'/>
+ <console type='pty'>
<target type='serial' port='0'/>
- <alias name='serial0'/>
</console>
<input type='mouse' bus='ps2'/>
- <graphics type='vnc' port='5900' autoport='yes' keymap='en-us'/>
+ <graphics type='vnc' port='-1' autoport='yes' keymap='en-us'/>
<sound model='ac97'>
- <alias name='sound0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
</sound>
<video>
<model type='cirrus' vram='9216' heads='1'/>
- <alias name='video0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
</video>
<memballoon model='virtio'>
- <alias name='balloon0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
</memballoon>
</devices>
- <seclabel type='dynamic' model='selinux'>
- <label>system_u:system_r:svirt_t:s0:c765,c889</label>
- <imagelabel>system_u:object_r:svirt_image_t:s0:c765,c889</imagelabel>
- </seclabel>
</domain>
It's caused by the element "<alias>", domain schema XML doesn't has the definition for "<alias>", as they are generated automatically when domain is running, and is ignored when defining a domain. And as the offline domain xml could be validated successfully. Close it as NOTABUG. (In reply to comment #2) > It's caused by the element "<alias>", domain schema XML doesn't has the > definition for "<alias>", as they are generated automatically when domain is > running, and is ignored when defining a domain. > > And as the offline domain xml could be validated successfully. > > Close it as NOTABUG. no , with no <alias>, it also can not be validated successfully cat /tmp/test.xml <domain type='kvm' id='39'> <name>rhel6-x86_64</name> <uuid>32202e35-d1bd-7f01-fe8d-11c3e181e579</uuid> <memory>524288</memory> <currentMemory>524288</currentMemory> <vcpu cpuset='0-1,3'>4</vcpu> <os> <type arch='x86_64' machine='rhel6.1.0'>hvm</type> <boot dev='hd'/> </os> <features> <acpi/> <apic/> <pae/> </features> <clock offset='utc'/> <on_poweroff>destroy</on_poweroff> <on_reboot>restart</on_reboot> <on_crash>restart</on_crash> <devices> <emulator>/usr/libexec/qemu-kvm</emulator> <disk type='file' device='disk'> <driver name='qemu' type='raw'/> <source file='/var/lib/libvirt/images/kvm-rhel6-x86_64'/> <target dev='hda' bus='ide'/> <address type='drive' controller='0' bus='0' unit='0'/> </disk> <controller type='ide' index='0'> <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> </controller> <interface type='network'> <mac address='52:54:00:90:3c:46'/> <source network='default'/> <target dev='vnet1'/> <model type='rtl8139'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> </interface> <serial type='pty'> <source path='/dev/pts/2'/> <target port='0'/> </serial> <console type='pty' tty='/dev/pts/2'> <source path='/dev/pts/2'/> <target type='serial' port='0'/> </console> <input type='mouse' bus='ps2'/> <graphics type='vnc' port='5901' autoport='yes' keymap='en-us'/> <sound model='ac97'> <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/> </sound> <video> <model type='cirrus' vram='9216' heads='1'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/> </video> <memballoon model='virtio'> <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/> </memballoon> </devices> <seclabel type='dynamic' model='selinux'> <label>system_u:system_r:svirt_t:s0:c375,c692</label> <imagelabel>system_u:object_r:svirt_image_t:s0:c375,c692</imagelabel> </seclabel> </domain> > (In reply to comment #3)
> no , with no <alias>, it also can not be validated successfully
> cat /tmp/test.xml
> </domain>
with this xml, the domain can be defined and started successfully
<imagelabel> lacks a definition in the domain schemas, that's still true upstream: paphio:~/libvirt -> grep imagelabel docs/schemas/*.rng paphio:~/libvirt -> Daniel patch posted to upstream: http://www.redhat.com/archives/libvir-list/2011-March/msg00938.html patch committed to upstream commit 918c8193e228a98ce002e98671cd0f9dcbc04ef2 Author: Osier Yang <jyang> Date: Mon Mar 21 15:58:51 2011 +0800 Test it with libvirt-0.9.9-1.el6 and it failed.
The test steps and errors are the same as that in comments 1 and the domain xml is as follows:
# cat vr-rhel6-x86_64-kvm.xml
<domain type='kvm' id='6'>
<name>vr-rhel6-x86_64-kvm</name>
<uuid>2ee6db9e-6445-46a4-7c12-622c5436f9da</uuid>
<memory>524288</memory>
<currentMemory>524288</currentMemory>
<vcpu>1</vcpu>
<os>
<type arch='x86_64' machine='rhel6.2.0'>hvm</type>
<boot dev='hd'/>
</os>
<features>
<acpi/>
<apic/>
<pae/>
</features>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<devices>
<emulator>/usr/libexec/qemu-kvm</emulator>
<disk type='file' device='disk'>
<driver name='qemu' type='raw'/>
<source file='/var/lib/libvirt/images/vr-rhel6-x86_64-kvm'/>
<target dev='hda' bus='ide'/>
<alias name='ide0-0-0'/>
<address type='drive' controller='0' bus='0' unit='0'/>
</disk>
<controller type='ide' index='0'>
<alias name='ide0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
</controller>
<interface type='network'>
<mac address='52:54:00:71:f7:b7'/>
<source network='default'/>
<target dev='vnet0'/>
<model type='rtl8139'/>
<alias name='net0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</interface>
<interface type='network'>
<mac address='52:54:00:2a:9c:c0'/>
<source network='default'/>
<target dev='vnet1'/>
<model type='virtio'/>
<alias name='net1'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
</interface>
<interface type='network'>
<mac address='52:54:00:90:f4:66'/>
<source network='default'/>
<target dev='vnet2'/>
<model type='virtio'/>
<alias name='net2'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
</interface>
<serial type='pty'>
<source path='/dev/pts/3'/>
<target port='0'/>
<alias name='serial0'/>
</serial>
<console type='pty' tty='/dev/pts/3'>
<source path='/dev/pts/3'/>
<target type='serial' port='0'/>
<alias name='serial0'/>
</console>
<input type='mouse' bus='ps2'/>
<graphics type='vnc' port='5900' autoport='yes' keymap='en-us'/>
<sound model='ac97'>
<alias name='sound0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
</sound>
<video>
<model type='cirrus' vram='9216' heads='1'/>
<alias name='video0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
</video>
<memballoon model='virtio'>
<alias name='balloon0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
</memballoon>
</devices>
<seclabel type='dynamic' model='selinux' relabel='yes'>
<label>system_u:system_r:svirt_t:s0:c276,c1008</label>
<imagelabel>system_u:object_r:svirt_image_t:s0:c276,c1008</imagelabel>
</seclabel>
</domain>
See comment 3, It's caused by the "alias"es, "alias" is used only by libvirt internally, you won't see it in the persistent XML config. And it's ignored when defining a domain. And IMO it's not right to add "alias" to the device XML schemas, as it's really an libvirt internal stuff. The question is how the XML with <alias> was obtained ? If it's the result of a virsh dump (or API operation) then we need to fix this so that this doesn't show up (that's a separate bug). If that was obtained by getting the files from the internal directory of libvirt under /etc/ then if this break validation that's not a bug, as those files are specific to libvirt and not for user consumption. Daniel (In reply to comment #15) > The question is how the XML with <alias> was obtained ? If it's the result > of a virsh dump (or API operation) then we need to fix this so that > this doesn't show up (that's a separate bug). If that was obtained > by getting the files from the internal directory of libvirt under /etc/ > then if this break validation that's not a bug, as those files are > specific to libvirt and not for user consumption. > > Daniel My thought is constast. :) If the XML file is virsh dump, it's not bug, as 1) we never store <alias> in the persistent conf, 2) it's ignored when defining, even if it exists, so it's meaningless to validate it 3) I can't see a reason to validate the dumped XML which is already worked well with libvirt. Though yes, we don't do RNG validation inside libvirt, bug probaly we will do that in future, right before parsing the XML. If the XML file is from /etc, it's not bug too, as we don't write any <alias> into the persistent conf, it must be caused by one copy some running def there. That's not responsiable by libvirt. Anyway, If it's bug, it's a separate bug. Hi Daniel, (In reply to comment #15) > The question is how the XML with <alias> was obtained ? If it's the result > of a virsh dump (or API operation) then we need to fix this so that > this doesn't show up (that's a separate bug). If I use virt-xml-validate to check the xml generated by virsh dump of a running guest, it will failed. You mean I open a new bug for it? > If that was obtained by getting the files from the internal directory > of libvirt under /etc/ then if this break validation that's not a bug, as those files are specific to libvirt and not for user consumption. > Daniel If I use virt-xml-validate to check the /etc/libvirt/qemu/${domain_name}.xml, it is ok. > It's caused by the "alias"es, "alias" is used only by libvirt
> internally, you won't see it in the persistent XML config. And it's ignored
> when defining a domain. And IMO it's not right to add "alias" to the device XML
> schemas, as it's really an libvirt internal stuff.
No, this is incorrect. <alias> elements *are* part of the public XML schema, intended to be shown to users by dumpxml. Any device can contain an <alias> element or <address> element, or both. They need to be added to the XML.
(In reply to comment #18) > > It's caused by the "alias"es, "alias" is used only by libvirt > > internally, you won't see it in the persistent XML config. And it's ignored > > when defining a domain. And IMO it's not right to add "alias" to the device XML > > schemas, as it's really an libvirt internal stuff. > > No, this is incorrect. <alias> elements *are* part of the public XML schema, > intended to be shown to users by dumpxml. Any device can contain an <alias> > element or <address> element, or both. They need to be added to the XML. I agree that <alias> is part of the public XML. It only makes sense on a running domain (which is why it is ignored when defining an inactive domain, and stripped when exporting dumpxml --inactive), but we have documented API that uses an alias name: at least virDomainOpenConsole. Therefore, I agree that we need to update the RNG to validate anything that 'virsh dumpxml' outputs, and that this includes adding <alias> support into RNG. Fair enough, :) I will post the patch to upstream. Patches posted to upstream.
commit 487bdbd8e08c7327c15e286a09f9b23abc2b9dae
Author: Osier Yang <jyang>
Date: Mon Jan 16 17:28:51 2012 +0800
docs: Expose alias tag in domain RNG schema
Though <alias> is ignored when defining a domain, it can cause
failure if one validates (e.g. virt-xml-validate) the XML dumped
from a running domain. This patch expose it in domain RNG schema
for all the devices which support it.
commit 4447d2cbdf70aa71af19c0b8a9b73b2c2ad4cd7b
Author: Osier Yang <jyang>
Date: Mon Jan 16 17:17:26 2012 +0800
docs: Add readonly to filesystem RNG schema
"<readonly/>" is supported by filesystem XML, and also documented.
Verified PASS with libvirt-0.9.10-1.el6.
# virsh list --all
Id Name State
----------------------------------------------------
1 rhel62 running
# virsh dumpxml rhel62
<domain type='kvm' id='1'>
<name>rhel62</name>
<uuid>6a6839c3-8b51-125e-262f-f2d384367c49</uuid>
<memory>1048576</memory>
<currentMemory>1048576</currentMemory>
<vcpu>1</vcpu>
<os>
<type arch='x86_64' machine='rhel6.2.0'>hvm</type>
<boot dev='hd'/>
</os>
<features>
<acpi/>
<apic/>
<pae/>
</features>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<devices>
<emulator>/usr/libexec/qemu-kvm</emulator>
<disk type='file' device='disk'>
<driver name='qemu' type='raw' cache='none'/>
<source file='/var/lib/libvirt/images/rhel62.img'/>
<target dev='vda' bus='virtio'/>
<alias name='virtio-disk0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
</disk>
<controller type='usb' index='0'>
<alias name='usb0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
</controller>
<interface type='network'>
<mac address='52:54:00:32:3e:2f'/>
<source network='default'/>
<target dev='vnet0'/>
<model type='virtio'/>
<alias name='net0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</interface>
<serial type='pty'>
<source path='/dev/pts/1'/>
<target port='0'/>
<alias name='serial0'/>
</serial>
<console type='pty' tty='/dev/pts/1'>
<source path='/dev/pts/1'/>
<target type='serial' port='0'/>
<alias name='serial0'/>
</console>
<input type='tablet' bus='usb'>
<alias name='input0'/>
</input>
<input type='mouse' bus='ps2'/>
<graphics type='vnc' port='5900' autoport='yes'/>
<sound model='ich6'>
<alias name='sound0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
</sound>
<video>
<model type='cirrus' vram='9216' heads='1'/>
<alias name='video0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
</video>
<memballoon model='virtio'>
<alias name='balloon0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
</memballoon>
</devices>
<seclabel type='dynamic' model='selinux' relabel='yes'>
<label>system_u:system_r:svirt_t:s0:c505,c866</label>
<imagelabel>system_u:object_r:svirt_image_t:s0:c505,c866</imagelabel>
</seclabel>
</domain>
save the xml to /tmp/rhel62.xml
# virt-xml-validate /tmp/rhel62.xml
/tmp/rhel62.xml validates
Technical note added. If any revisions are required, please edit the "Technical Notes" field
accordingly. All revisions will be proofread by the Engineering Content Services team.
New Contents:
No documentation needed.
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. http://rhn.redhat.com/errata/RHSA-2012-0748.html |
Description of problem: When domain is running, dumpxml to an xml file and validate with virt-xml-validate, there is an error: Relax-NG validity error : Extra element devices in interleave /tmp/vr-rhel6-x86_64-kvm.xml:1: element domain: Relax-NG validity error : Element domain failed to validate content /tmp/vr-rhel6-x86_64-kvm.xml fails to validate Version-Release number of selected component (if applicable): libvirt-0.8.7-11.el6.x86_64 qemu-kvm-0.12.1.2-2.150.el6.x86_64 kernel-2.6.32-120.el6.x86_64 How reproducible: 100% Steps to Reproduce: 1.Start a guest and dump xml, save to /tmp/vr-rhel6-x86_64-kvm.xml <domain type='kvm' id='6'> <name>vr-rhel6-x86_64-kvm</name> <uuid>697d236f-56a4-0f83-e40e-6b5d93a46415</uuid> <memory>524288</memory> <currentMemory>524288</currentMemory> <vcpu>1</vcpu> <os> <type arch='x86_64' machine='rhel6.1.0'>hvm</type> <boot dev='hd'/> </os> <features> <acpi/> <apic/> <pae/> </features> <clock offset='utc'/> <on_poweroff>destroy</on_poweroff> <on_reboot>restart</on_reboot> <on_crash>restart</on_crash> <devices> <emulator>/usr/libexec/qemu-kvm</emulator> <disk type='file' device='disk'> <driver name='qemu' type='raw'/> <source file='/var/lib/libvirt/images/vr-rhel6-x86_64-kvm'/> <target dev='hda' bus='ide'/> <alias name='ide0-0-0'/> <address type='drive' controller='0' bus='0' unit='0'/> </disk> <controller type='ide' index='0'> <alias name='ide0'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> </controller> <interface type='network'> <mac address='52:54:00:48:a1:db'/> <source network='default'/> <target dev='vnet0'/> <model type='rtl8139'/> <alias name='net0'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> </interface> <serial type='pty'> <source path='/dev/pts/2'/> <target port='0'/> <alias name='serial0'/> </serial> <console type='pty' tty='/dev/pts/2'> <source path='/dev/pts/2'/> <target type='serial' port='0'/> <alias name='serial0'/> </console> <input type='mouse' bus='ps2'/> <graphics type='vnc' port='5900' autoport='yes' keymap='en-us'/> <sound model='ac97'> <alias name='sound0'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/> </sound> <video> <model type='cirrus' vram='9216' heads='1'/> <alias name='video0'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/> </video> <memballoon model='virtio'> <alias name='balloon0'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/> </memballoon> </devices> <seclabel type='dynamic' model='selinux'> <label>system_u:system_r:svirt_t:s0:c765,c889</label> <imagelabel>system_u:object_r:svirt_image_t:s0:c765,c889</imagelabel> </seclabel> </domain> 2.run #virt-xml-validate /tmp/vr-rhel6-x86_64-kvm.xml 3. Actual results: report an error: Relax-NG validity error : Extra element devices in interleave /tmp/vr-rhel6-x86_64-kvm.xml:1: element domain: Relax-NG validity error : Element domain failed to validate content /tmp/vr-rhel6-x86_64-kvm.xml fails to validate Expected results: /tmp/vr-rhel6-x86_64-kvm.xml validates Additional info: if shutdown domain and dump xml, the xml can be successfully validated. shutdown domain xml for the same guest <domain type='kvm'> <name>vr-rhel6-x86_64-kvm</name> <uuid>697d236f-56a4-0f83-e40e-6b5d93a46415</uuid> <memory>524288</memory> <currentMemory>524288</currentMemory> <vcpu>1</vcpu> <os> <type arch='x86_64' machine='rhel6.1.0'>hvm</type> <boot dev='hd'/> </os> <features> <acpi/> <apic/> <pae/> </features> <clock offset='utc'/> <on_poweroff>destroy</on_poweroff> <on_reboot>restart</on_reboot> <on_crash>restart</on_crash> <devices> <emulator>/usr/libexec/qemu-kvm</emulator> <disk type='file' device='disk'> <driver name='qemu' type='raw'/> <source file='/var/lib/libvirt/images/vr-rhel6-x86_64-kvm'/> <target dev='hda' bus='ide'/> <address type='drive' controller='0' bus='0' unit='0'/> </disk> <controller type='ide' index='0'> <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> </controller> <interface type='network'> <mac address='52:54:00:48:a1:db'/> <source network='default'/> <model type='rtl8139'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> </interface> <serial type='pty'> <target port='0'/> </serial> <console type='pty'> <target type='serial' port='0'/> </console> <input type='mouse' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes' keymap='en-us'/> <sound model='ac97'> <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/> </sound> <video> <model type='cirrus' vram='9216' heads='1'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/> </video> <memballoon model='virtio'> <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/> </memballoon> </devices> </domain>