Bug 1173468 - Domain configure xml validation fails when adding <link state='down'/> to network interface
Summary: Domain configure xml validation fails when adding <link state='down'/> to net...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libvirt
Version: 7.1
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: rc
: ---
Assignee: Peter Krempa
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-12-12 08:36 UTC by vivian zhang
Modified: 2015-11-19 05:58 UTC (History)
5 users (show)

Fixed In Version: libvirt-1.2.14-1.el7
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2015-11-19 05:58:13 UTC
Target Upstream Version:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2015:2202 0 normal SHIPPED_LIVE libvirt bug fix and enhancement update 2015-11-19 08:17:58 UTC

Description vivian zhang 2014-12-12 08:36:20 UTC
Description:
Domain configure xml validation fails when adding <link state='down'/> to network interface

Product version
libvirt-1.2.8-10.el7.x86_64
qemu-kvm-rhev-2.1.2-15.el7.x86_64

How producible
100%

Steps:
1. Prepare a running guest with below <link state='down'/>
# virsh dumpxml rhel7
...
<interface type='network'>
      <mac address='52:54:00:c6:3b:95'/>
      <source network='default'/>
      <bandwidth>
        <inbound average='1000' peak='5000' burst='1024'/>
        <outbound average='128' peak='256' burst='256'/>
      </bandwidth>
      <link state='down'/>   --------> notice this parameter
      <target dev='vnet1'/>
      <model type='virtio'/>
      <driver name='vhost' queues='5'/>
      <alias name='net1'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x10' function='0x0'/>
    </interface>
...
# virsh list --all
Id    Name                           State
----------------------------------------------------
 27    rbd                            running

2. dumpxm gest xml to file
# virsh dumpxml rhel7 > /tmp/rhel7full.xml

3.  #cat /tmp/rhel7full.xml
...
<interface type='network'>
      <mac address='52:54:00:c6:3b:95'/>
      <source network='default'/>
      <bandwidth>
        <inbound average='1000' peak='5000' burst='1024'/>
        <outbound average='128' peak='256' burst='256'/>
      </bandwidth>
      <link state='down'/>
      <target dev='vnet1'/>
      <model type='virtio'/>
      <driver name='vhost' queues='5'/>
      <alias name='net1'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x10' function='0x0'/>
    </interface>
...

4. validate
# virt-xml-validate /tmp/rhel7full.xml
Relax-NG validity error : Extra element devices in interleave
/tmp/rhel7full.xml:1: element domain: Relax-NG validity error : Element domain failed to validate content
/tmp/rhel7full.xml fails to validate


5. delete <link state='down'/> in xml
# virt-xml-validate rbd-test.xml
rbd-test.xml validates

#cat /tmp/rhel7full.xml  , without <link state='down'/>
...
<interface type='network'>
      <mac address='52:54:00:c6:3b:95'/>
      <source network='default'/>
      <bandwidth>
        <inbound average='1000' peak='5000' burst='1024'/>
        <outbound average='128' peak='256' burst='256'/>
      </bandwidth>
      <target dev='vnet1'/>
      <model type='virtio'/>
      <driver name='vhost' queues='5'/>
      <alias name='net1'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x10' function='0x0'/>
    </interface>
...

6. replace dump xml with <link state='up'/>, validation still failed

7. i think we should add this check  in /usr/share/libvirt/schemas/domaincommon.rng

Actual result:
In step 4, validation failed when adding <link state='down'/> to interface

Expected result:
Domain can start with the xml, so validation should pass

Comment 2 Peter Krempa 2015-03-03 08:56:46 UTC
Fixed upstream:

commit 8eb907b8d0fd73c8f88f9cd8df1fa0e7abf40c93
Author: Peter Krempa <pkrempa@redhat.com>
Date:   Mon Mar 2 17:21:23 2015 +0100

    schema: Fix interface link state schema
    
    In commit edd1295e1da6bfe8e4e257e5fbfad71ac0bf7c87 I've introduced an
    XML element that allows to configure state of the network interface
    link. Somehow the RNG schema hunk ended up in a weird place in the
    network schema definition. Move it to the right place and add a test
    case.
    
    Note that the link state is set up via the monitor at VM startup so I
    originally didn't think of adding a test case.

v1.2.13-34-g8eb907b

Comment 4 hongming 2015-07-16 06:56:00 UTC

[root@localhost images]# virsh start rhel7.0
Domain rhel7.0 started

[root@localhost images]# virsh dumpxml rhel7.0 > rhel7.0.xml

[root@localhost images]# virt-xml-validate rhel7.0.xml
Relax-NG validity error : Extra element devices in interleave
rhel7.0.xml:1: element domain: Relax-NG validity error : Element domain failed to validate content
rhel7.0.xml fails to validate


[root@localhost images]# cat rhel7.0.xml
<domain type='kvm' id='8'>
  <name>rhel7.0</name>
  <uuid>238d05f9-42e2-4f10-83ef-80c2121fecee</uuid>
  <memory unit='KiB'>1048576</memory>
  <currentMemory unit='KiB'>1048576</currentMemory>
  <vcpu placement='static' current='4'>8</vcpu>
  <cputune>
    <vcpupin vcpu='3' cpuset='3'/>
  </cputune>
  <resource>
    <partition>/machine</partition>
  </resource>
  <os>
    <type arch='x86_64' machine='pc-i440fx-rhel7.1.0'>hvm</type>
    <boot dev='hd'/>
  </os>
  <features>
    <acpi/>
    <apic/>
    <pae/>
  </features>
  <cpu mode='custom' match='exact'>
    <model fallback='allow'>SandyBridge</model>
  </cpu>
  <clock offset='utc'>
    <timer name='rtc' tickpolicy='catchup'/>
    <timer name='pit' tickpolicy='delay'/>
    <timer name='hpet' present='no'/>
  </clock>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>restart</on_crash>
  <pm>
    <suspend-to-mem enabled='no'/>
    <suspend-to-disk enabled='no'/>
  </pm>
  <devices>
    <emulator>/usr/libexec/qemu-kvm</emulator>
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/rhel7.0.qcow2'/>
      <backingStore/>
      <target dev='vda' bus='virtio'/>
      <alias name='virtio-disk0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
    </disk>
    <controller type='usb' index='0' model='ich9-ehci1'>
      <alias name='usb'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x7'/>
    </controller>
    <controller type='usb' index='0' model='ich9-uhci1'>
      <alias name='usb'/>
      <master startport='0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0' multifunction='on'/>
    </controller>
    <controller type='usb' index='0' model='ich9-uhci2'>
      <alias name='usb'/>
      <master startport='2'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x1'/>
    </controller>
    <controller type='usb' index='0' model='ich9-uhci3'>
      <alias name='usb'/>
      <master startport='4'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x2'/>
    </controller>
    <controller type='pci' index='0' model='pci-root'>
      <alias name='pci.0'/>
    </controller>
    <controller type='ide' index='0'>
      <alias name='ide'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
    </controller>
    <controller type='virtio-serial' index='0'>
      <alias name='virtio-serial0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
    </controller>
    <interface type='network'>
      <mac address='52:54:00:68:ce:60'/>
      <source network='default' bridge='virbr0'/>
      <target dev='vnet0'/>
      <model type='virtio'/>
      <link state='down'/>
      <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>
    <channel type='spicevmc'>
      <target type='virtio' name='com.redhat.spice.0' state='disconnected'/>
      <alias name='channel0'/>
      <address type='virtio-serial' controller='0' bus='0' port='1'/>
    </channel>
    <input type='tablet' bus='usb'>
      <alias name='input0'/>
    </input>
    <input type='mouse' bus='ps2'/>
    <input type='keyboard' bus='ps2'/>
    <graphics type='spice' port='5900' autoport='yes' listen='127.0.0.1'>
      <listen type='address' address='127.0.0.1'/>
    </graphics>
    <sound model='ich6'>
      <alias name='sound0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
    </sound>
    <video>
      <model type='qxl' ram='65536' vram='65536' vgamem='16384' heads='1'/>
      <alias name='video0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
    </video>
    <redirdev bus='usb' type='spicevmc'>
      <alias name='redir0'/>
    </redirdev>
    <redirdev bus='usb' type='spicevmc'>
      <alias name='redir1'/>
    </redirdev>
    <memballoon model='virtio'>
      <alias name='balloon0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
    </memballoon>
  </devices>
  <seclabel type='dynamic' model='selinux' relabel='yes'>
    <label>system_u:system_r:svirt_t:s0:c499,c851</label>
    <imagelabel>system_u:object_r:svirt_image_t:s0:c499,c851</imagelabel>
  </seclabel>
</domain>

It is still failed even if removing the sub elements under the <interface> one by one.It can be passed until removing the whole <interface> element. 

[root@localhost images]# vim rhel7.0.xml

[root@localhost images]# cat rhel7.0.xml |grep interface

[root@localhost images]# virt-xml-validate rhel7.0.xml
rhel7.0.xml validates

Comment 5 Peter Krempa 2015-07-16 08:00:59 UTC
The failure you see is unrelated to this bug report. The XML validator complains that the 'bridge' attribute is unexpected in the source element.

The bug is tracked as  https://bugzilla.redhat.com/show_bug.cgi?id=1177594

<source network='default' bridge='virbr0'/>

Please choose a different source element or wait until the above BZ is fixed.

Comment 7 hongming 2015-09-08 02:14:10 UTC
Remove the bridge attribute from source element because of bug1177594. The result is expected. Move its status to VERIFIED.


# rpm -q libvirt
libvirt-1.2.17-6.el7.x86_64

# cat r7.1.xml|grep /interface -B10
    <interface type='network'>
      <mac address='52:54:00:5a:ab:c5'/>
      <source network='default'/>
      <bandwidth>
        <inbound average='1000' peak='5000' floor='200' burst='1024'/>
        <outbound average='128' peak='256' burst='256'/>
      </bandwidth>
      <link state='down'/>
      <model type='rtl8139'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </interface>

# virt-xml-validate r7.1.xml
r7.1.xml validates

Comment 9 errata-xmlrpc 2015-11-19 05:58:13 UTC
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.

https://rhn.redhat.com/errata/RHBA-2015-2202.html


Note You need to log in before you can comment on or make changes to this bug.