RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1220197 - Domain XML is invalid with "<source startupPolicy='optional'/>"
Summary: Domain XML is invalid with "<source startupPolicy='optional'/>"
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: libvirt
Version: 6.7
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: rc
: ---
Assignee: Ján Tomko
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-05-11 01:48 UTC by Pei Zhang
Modified: 2016-05-10 19:23 UTC (History)
7 users (show)

Fixed In Version: libvirt-0.10.2-55.el6
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-05-10 19:23:39 UTC
Target Upstream Version:
Embargoed:
pzhang: needinfo-


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2016:0738 0 normal SHIPPED_LIVE libvirt bug fix update 2016-05-12 18:40:37 UTC

Description Pei Zhang 2015-05-11 01:48:24 UTC
description of problem :
Start guest with <source  startupPolicy='optional'/> will get bad xml using dumpxml to check .validates failed too .

version:
libvirt-0.10.2-54.el6.x86_64

How producible
100%

steps to reproduce :
1.start guest with following XML
<disk type='block' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source  startupPolicy='optional'/>
      <target dev='hdc' bus='ide'/>
      <readonly/>
      <alias name='ide0-1-0'/>
      <address type='drive' controller='0' bus='1' target='0' unit='0'/>
    </disk>

2.check domain xml using dumpxml --inactive,  <source> element is moved .
#virsh dumpxml r6 --inactive | grep cdrom -A 9
<disk type='block' device='cdrom'>
      <driver name='qemu' type='raw'/> <====== <source> element is moved.
      <target dev='hdc' bus='ide'/>
      <readonly/>
      <alias name='ide0-1-0'/>
      <address type='drive' controller='0' bus='1' target='0' unit='0'/>
    </disk>

2.check domain xml using dumpxml without --inactive
#virsh dumpxml r6 | grep cdrom -A 9
<disk type='block' device='cdrom'>
      <driver name='qemu' type='raw'/>
startupPolicy='optional'/>  <===== get bad XML .
      <target dev='hdc' bus='ide'/>
      <readonly/>
      <alias name='ide0-1-0'/>
      <address type='drive' controller='0' bus='1' target='0' unit='0'/>
    </disk>

3.Using virt-xml-validate to check

check XML with  <source  startupPolicy='optional'/>:
# virt-xml-validate r6.xml
Relax-NG validity error : Extra element devices in interleave
r6.xml:20: element devices: Relax-NG validity error : Element domain failed to validate content
r6.xml fails to validate

remove <source  startupPolicy='optional'/> from domain XML  to check :
# virt-xml-validate r6.xml
r6.xml validates

Actual results:
As step2 and step3 , domain XML with <source  startupPolicy='optional'/> is invalid .

Expected result:
Should get accurate XML not the bad one using dumpxml .
and domian xml with  <source  startupPolicy='optional'/> should be valid.

Additional info:
This issue can not reproduce in rhel7.

Comment 1 Jaroslav Suchanek 2015-05-25 15:18:28 UTC
Hi, is it reproducible with libvirt-0.10.2-46.el6 build?

Comment 2 Pei Zhang 2015-05-26 04:56:29 UTC
Firstly , sorry for my mistaken . "startupPolicy" just be used disk type is "file / volume " . it is a invalid operation . so please ignore virt-xml-validate . but it will also get a bad domain xml after libvirt format it .

If I configure XML like following (using type is 'file'). it is all right (dumpxml and start):
<disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source startupPolicy='optional'/>
      <target dev='hdc' bus='ide'/>
      <readonly/>
      <address type='drive' controller='0' bus='1' target='0' unit='0'/>
    </disk>

Then I change disk type to 'block' :
1. For a running domain , using edit to change 'file' to 'block'
#virsh edit r6 
 <disk type='block' device='cdrom'>
......
It can be saved , but it just remove "<source" rather than all of them .
It should remove " <source startupPolicy='optional'/> " all after I edit and saved If libvirt try to format it . so that is not expected result I think .

using dumpxml to check , the result likes following :

# virsh dumpxml r6 --inactive |grep cdrom -A 9
    <disk type='block' device='cdrom'>
      <driver name='qemu' type='raw'/>
 startupPolicy='optional'/>
......

2. for a shut off domain ,configure guest XML like following :
......
<disk type='block' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source startupPolicy='optional'/>
......
start guest 
# virsh start r6
Domain r6 started

# virsh dumpxml r6 | grep cdrom -A 9
    <disk type='block' device='cdrom'>
      <driver name='qemu' type='raw'/>
 startupPolicy='optional'/>  <===it still exists.
 ......

# virsh dumpxml r6 --inactive | grep cdrom -A 9
    <disk type='block' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <target dev='hdc' bus='ide'/>
......

And these operations (edit and dumpxml guest) can reproduce it with libvirt-0.10.2-46.el6 and libvirt-0.10.2-46.el6_6.6.x86_64 . 
Thanks .

Comment 4 Ján Tomko 2015-05-28 09:24:07 UTC
Fixed upstream by:
commit 4b5652d0dcb2d53fd4240f589a63aaa434650fe0
Author:     Doug Goldstein <cardoe>
CommitDate: 2013-09-17 14:10:40 -0500

    Allow <source> for type=block to have no dev
    
    Currently the XML parser already allows the following syntax:
      <disk type='block' device='cdrom'>
        <source startupPolicy='optional'/>
        <target dev='hda' bus='ide'/>
        <address type='drive' controller='0' bus='0' target='0' unit='0'/>
      </disk>
    
    But it if the dev value is NULL then it would not have the leading
    "<source ", resulting in invalid XML.

git describe: v1.1.2-162-g4b5652d contains: v1.1.3-rc1~115

Comment 7 lijuan men 2015-12-07 02:26:32 UTC
version:
libvirt-0.10.2-55.el6.x86_64

steps:

scenario 1:
1.start guest with following XML
<disk type='block' device='cdrom'>
      <driver name='qemu' type='raw' cache='none'/>
      <source startupPolicy='optional'/>
      <target dev='hdc' bus='ide'/>
      <readonly/>
      <alias name='ide0-1-0'/>
      <address type='drive' controller='0' bus='1' target='0' unit='0'/>
    </disk>
2.check domain xml with --inactive flag
[root@lmen ~]# virsh dumpxml rhel6 --inactive | grep cdrom -A 9
    <disk type='block' device='cdrom'>
      <driver name='qemu' type='raw' cache='none'/>
      <source startupPolicy='optional'/>
      <target dev='hdc' bus='ide'/>
      <readonly/>
      <address type='drive' controller='0' bus='1' target='0' unit='0'/>
    </disk>
3.check domain xml without --inactive flag
[root@lmen ~]# virsh dumpxml rhel6  | grep cdrom -A 9
    <disk type='block' device='cdrom'>
      <driver name='qemu' type='raw' cache='none'/>
      <source startupPolicy='optional'/>
      <target dev='hdc' bus='ide'/>
      <readonly/>
      <address type='drive' controller='0' bus='1' target='0' unit='0'/>
    </disk>
4.Using virt-xml-validate to check
[root@lmen ~]# virsh dumpxml rhel6 --inactive >rhel6.xml 
[root@lmen ~]# virt-xml-validate rhel6.xml 
rhel6.xml validates


scenario 2:
1.start guest with following XML
<disk type='file' device='cdrom'>
      <driver name='qemu' type='raw' cache='none'/>
      <source startupPolicy='optional'/>
      <target dev='hdc' bus='ide'/>
      <readonly/>
      <address type='drive' controller='0' bus='1' target='0' unit='0'/>
    </disk>
2.edit the xml to change 'file' to 'block'
#virsh edit rhel6
 <disk type='block' device='cdrom'>
.....
3.check domain xml without --inactive flag
[root@lmen ~]# virsh dumpxml rhel6  | grep cdrom -A 9
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw' cache='none'/>
      <source startupPolicy='optional'/>
      <target dev='hdc' bus='ide'/>
      <readonly/>
      <alias name='ide0-1-0'/>
      <address type='drive' controller='0' bus='1' target='0' unit='0'/>
    </disk>
4.check domain xml with --inactive flag
[root@lmen ~]# virsh dumpxml rhel6  --inactive | grep cdrom -A 9
    <disk type='block' device='cdrom'>
      <driver name='qemu' type='raw' cache='none'/>
      <source startupPolicy='optional'/>
      <target dev='hdc' bus='ide'/>
      <readonly/>
      <address type='drive' controller='0' bus='1' target='0' unit='0'/>
    </disk>
5.Use virt-xml-validate to check
[root@lmen ~]# virsh dumpxml rhel6  --inactive >rhel6.xml 
[root@lmen ~]# virt-xml-validate rhel6.xml 
rhel6.xml validates
6.reboot rhe guest
[root@lmen ~]# virsh destroy rhel6
Domain rhel6 destroyed

[root@lmen ~]# virsh start rhel6
Domain rhel6 started

7.check domain xml without --inactive flag
[root@lmen ~]# virsh dumpxml rhel6  | grep cdrom -A 9
    <disk type='block' device='cdrom'>
      <driver name='qemu' type='raw' cache='none'/>
      <source startupPolicy='optional'/>
      <target dev='hdc' bus='ide'/>
      <readonly/>
      <alias name='ide0-1-0'/>
      <address type='drive' controller='0' bus='1' target='0' unit='0'/>
    </disk>


the bug is verified.

Comment 9 errata-xmlrpc 2016-05-10 19:23:39 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-2016-0738.html


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