Bug 1140984

Summary: sub-element in <disk>...</disk> change after create external disk snapshot
Product: Red Hat Enterprise Linux 7 Reporter: Shanzhi Yu <shyu>
Component: libvirtAssignee: Peter Krempa <pkrempa>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.1CC: dyuan, mzhan, rbalakri, yanyang
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: libvirt-1.2.8-3.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-03-05 07:44:25 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Shanzhi Yu 2014-09-12 07:35:27 UTC
Description of problem:

sub-element in <disk>...</disk> change after create external disk snapshot

Version-Release number of selected component (if applicable):

libvirt-1.2.7-2.el7.x86_64
libvirt-client-1.2.7-2.el7.x86_64


How reproducible:

100%

Steps to Reproduce:

1. Prepare a running guest 

# virsh dumpxml rhel7-qcow2 |grep disk -A 5 
..
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2' cache='none'/>
      <source file='/var/lib/libvirt/images/rhel7-qcow2.img'/>
      <backingStore/>
      <target dev='vda' bus='virtio'/>
      <alias name='virtio-disk0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
    </disk>
..

2. create external disk snapshot 

# virsh snapshot-create-as rhel7-qcow2 ss --disk-only

3. check guest xml 

# virsh dumpxml rhel7-qcow2 |grep disk -A 8
 <disk type='file' device='disk'>
      <driver type='qcow2' cache='none'/>
      <source file='/var/lib/libvirt/images/rhel7-qcow2.ss'/>
      <backingStore type='file' index='1'>
        <format type='qcow2'/>
        <source file='/var/lib/libvirt/images/rhel7-qcow2.img'/>
        <backingStore/>
      </backingStore>
      <target dev='vda' bus='virtio'/>
      <alias name='virtio-disk0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
    </disk>

4. validate xml for running guest 

#virsh dumpxml rhel7-qcow2 > r7.xml
# virt-xml-validate r7.xml 
Relax-NG validity error : Extra element devices in interleave
r7.xml:1: element domain: Relax-NG validity error : Element domain failed to validate content
r7.xml fails to validate

5. destroy/start guest and re-check guest xml

# virsh destroy rhel7-qcow2;virsh start rhel7-qcow2 
Domain rhel7-qcow2 destroyed

Domain rhel7-qcow2 started

#virsh dumpxml rhel7-qcow2
...
   <disk type='file' device='disk'>
      <driver type='qcow2' cache='none'/>
      <source file='/var/lib/libvirt/images/rhel7-qcow2.ss'/>
      <backingStore type='file' index='1'>
        <format type='qcow2'/>
        <source file='/var/lib/libvirt/images/rhel7-qcow2.img'/>
        <backingStore/>
      </backingStore>
      <target dev='vda' bus='virtio'/>
      <alias name='virtio-disk0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
    </disk>
...


Actual results:

In step 3, <driver name='qemu' type='qcow2' cache='none'/> change to <driver type='qcow2' cache='none'/>

Expected results:

driver name='qemu' type='qcow2' should not change in step 3 or virt-xml-validate pass in step 4 

Additional info:

# grep "driverFormat" docs/schemas/*.rng  -A 12
docs/schemas/domaincommon.rng:        <ref name="driverFormat"/>
docs/schemas/domaincommon.rng-      </optional>
docs/schemas/domaincommon.rng-      <optional>
docs/schemas/domaincommon.rng-        <ref name="driverCache"/>
docs/schemas/domaincommon.rng-      </optional>
docs/schemas/domaincommon.rng-      <optional>
docs/schemas/domaincommon.rng-        <ref name="driverErrorPolicy"/>
docs/schemas/domaincommon.rng-      </optional>
docs/schemas/domaincommon.rng-      <optional>
docs/schemas/domaincommon.rng-        <ref name="driverRerrorPolicy"/>
docs/schemas/domaincommon.rng-      </optional>
docs/schemas/domaincommon.rng-      <optional>
docs/schemas/domaincommon.rng-        <ref name="driverIO"/>
--
docs/schemas/domaincommon.rng:  <define name="driverFormat">
docs/schemas/domaincommon.rng-    <attribute name="name">
docs/schemas/domaincommon.rng-      <ref name="genericName"/>
docs/schemas/domaincommon.rng-    </attribute>
docs/schemas/domaincommon.rng-    <optional>
docs/schemas/domaincommon.rng-      <attribute name='type'>
docs/schemas/domaincommon.rng-        <choice>
docs/schemas/domaincommon.rng-          <ref name='storageFormat'/>
docs/schemas/domaincommon.rng-          <value>aio</value> <!-- back-compat for 'raw' -->
docs/schemas/domaincommon.rng-        </choice>
docs/schemas/domaincommon.rng-      </attribute>
docs/schemas/domaincommon.rng-    </optional>
docs/schemas/domaincommon.rng-  </define>

Comment 1 Peter Krempa 2014-09-16 16:11:00 UTC
Fixed upstream:

commit 865421c94a63f43c0164d598a73226d0e4231c93
Author: Peter Krempa <pkrempa>
Date:   Tue Sep 16 12:55:32 2014 +0200

    util: storage: Copy driver type when initializing chain element
    
    virStorageSourceInitChainElement initializes a new storage chain element
    for use as a new disk source. If the new element doesn't contain the
    driver name, copy it from the old source.
    
    This fixes issue where a disk would forget the driver after a snapshot.

Comment 4 Shanzhi Yu 2014-09-19 06:57:17 UTC
Verify this bug with libvirt-1.2.8-3.el7.x86_64.
Steps as comment 0. 

line "<driver name='qemu' type='qcow2' cache='none'/>" doesn't change after create external disk snapshot

Comment 6 errata-xmlrpc 2015-03-05 07:44:25 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/RHSA-2015-0323.html