Bug 1283085

Summary: Creating external disk snapshot for a guest which has two disks with the same prefix name,the disks become the same name in xml
Product: Red Hat Enterprise Linux 7 Reporter: lijuan men <lmen>
Component: libvirtAssignee: Peter Krempa <pkrempa>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: unspecified Docs Contact:
Priority: medium    
Version: 7.2CC: dyuan, hhan, mzhan, rbalakri, xuzhang, yanyang
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: libvirt-1.3.2-1.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-11-03 18:31:50 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 lijuan men 2015-11-18 08:30:06 UTC
Description of problem:
Creating external disk snapshot for a guest which has two disks with the same prefix name,the disks become the same name in xml

Version-Release number of selected component (if applicable):
libvirt-1.2.17-13.el7.x86_64

How reproducible:
100%

Steps to Reproduce:
1)prepare a guest having two disk,which have the same prefix name
[root@localhost ~]# virsh domblklist fs
Target     Source
------------------------------------------------
hda        /mnt/fs/f.qcow2
vda        /mnt/fs/f.qcow2-bak


2)create external disk snapshot
[root@localhost ~]# virsh snapshot-create-as fs test --disk-only
Domain snapshot test created

3)look at the xml file
[root@localhost ~]# virsh dumpxml fs | grep disk -A 10
    <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='/mnt/fs/f.test'/>
      <backingStore type='file' index='1'>
        <format type='raw'/>
       ***   <source file='/mnt/fs/f.qcow2-bak'/> ***
        <backingStore/>
      </backingStore>
      <target dev='hda' bus='ide'/>
      <alias name='ide0-0-0'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </disk>
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/mnt/fs/f.test'/>
      <backingStore type='file' index='1'>
        <format type='raw'/>
     ***     <source file='/mnt/fs/f.qcow2-bak'/> ***
        <backingStore/>
      </backingStore>
      <target dev='vda' bus='virtio'/>
      <alias name='virtio-disk0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
    </disk>

Actual results:
The names of the two disks become the same in the xml file.


Expected results:


Additional info:

Comment 2 Peter Krempa 2016-02-11 14:41:04 UTC
Fixed upstream:

commit b60af444ccc7ae2655af6753d62c7ee611a628b8
Author: Peter Krempa <pkrempa>
Date:   Thu Feb 11 09:57:45 2016 +0100

    conf: snapshot: Avoid autogenerating duplicate snapshot names
    
    The snapshot name generator truncates the original file name after a '.'
    and replaces the suffix with the snapshot name. If two disks source
    images differ only in the suffix portion, the generated name will be
    duplicate.
    
    Since this is a corner case just error out stating that a duplicate name
    was generated. The user can work around this situation by providing
    the file names explicitly.
    
    Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1283085

v1.3.1-217-gb60af44

Comment 4 Han Han 2016-04-21 07:49:14 UTC
I can reproduce it on libvirt-1.3.1-1.el7.x86_64.
Verify it on libvirt-1.3.3-2.el7.x86_64 :
1. Prepare a VM with two disks of the same prefix:
# virsh domblklist dup
Target     Source
------------------------------------------------
vda        /var/lib/libvirt/images/dup.qcow2
vdb        /var/lib/libvirt/images/dup.qcow2-bak

Create external snapshot:
# virsh snapshot-create-as dup s1 --disk-only
error: unsupported configuration: cannot generate external snapshot name for disk 'vdb': collision with disk 'vda'

Comment 6 errata-xmlrpc 2016-11-03 18:31:50 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-2016-2577.html