Bug 896403

Summary: delete snapshot which name contain '/' lead to libvirtd crash
Product: Red Hat Enterprise Linux 6 Reporter: yanbing du <ydu>
Component: libvirtAssignee: Peter Krempa <pkrempa>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: high Docs Contact:
Priority: high    
Version: 6.4CC: acathrow, bsarathy, dallan, dyasny, dyuan, mzhan, pkrempa, rwu, tlavigne, whuang
Target Milestone: rcKeywords: Regression
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: libvirt-0.10.2-17.el6 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-02-21 07:29:55 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:
Bug Depends On:    
Bug Blocks: 905536    
Attachments:
Description Flags
libvirtd-crash.log none

Description yanbing du 2013-01-17 08:34:16 UTC
Created attachment 680077 [details]
libvirtd-crash.log

Description of problem:
Create an internal snapshot which name contain '/', then delete it via virsh snapshot-delete command. This will lead to libvitd crash.

In fact, when create the snapshot, the snapshot xml doesn't create:
2013-01-17 08:09:26.925+0000: 24012: error : virFileRewrite:501 : cannot create file '/var/lib/libvirt/qemu/snapshot/test//tmp/test.sn.xml.new': No such file or directory
2013-01-17 08:09:26.925+0000: 24012: warning : qemuDomainSnapshotCreateXML:11790 : unable to save metadata for snapshot /tmp/test.sn

Version-Release number of selected component (if applicable):
libvirt-0.10.2-15.el6.x86_64
qemu-kvm-rhev-0.12.1.2-2.351.el6.x86_64
kernel-2.6.32-353.el6.x86_64 

How reproducible:
100% 

Steps to Reproduce:
1. Create an internal snapshot for a domain
# virsh snapshot-create-as test /tmp/test.sn
Domain snapshot /tmp/test.sn created

# virsh snapshot-list test
 Name                 Creation Time             State
------------------------------------------------------------
 /tmp/test.sn         2013-01-17 16:00:57 +0800 shutoff

# ls /var/lib/libvirt/qemu/snapshot/test//tmp/test.sn
ls: cannot access /var/lib/libvirt/qemu/snapshot/test//tmp/test.sn: No such file or directory

2. Delete the new created snapshot
# virsh snapshot-delete test /tmp/test.sn
error: Failed to delete snapshot /tmp/test.sn
error: End of file while reading data: Input/output error
error: Failed to reconnect to the hypervisor

3. Restart libvirtd and check the snapshot
#  virsh snapshot-list test
 Name                 Creation Time             State
------------------------------------------------------------
# qemu-img info /tmp/as2
image: /tmp/as2
file format: qcow2
virtual size: 1.0G (1073741824 bytes)
disk size: 160K
cluster_size: 65536
backing file: /tmp/asd
Snapshot list:
ID        TAG                 VM SIZE                DATE       VM CLOCK
3         /tmp/test.sn              0 2013-01-17 16:00:57   00:00:00.000

  
Actual results:
libvirtd crash 

Expected results:
libvirtd still running.
Or, when create snapshot, libvirt can refuse the snapshot name which contain '/'.

Additional info:
BTW, on libvirt-0.9.10-21.el6_3.8.x86_64, libvirtd will not crash. So this should be a regression bug.

Comment 3 Peter Krempa 2013-01-17 13:13:22 UTC
Patches for the issue posted upstream:
http://www.redhat.com/archives/libvir-list/2013-January/msg01220.html

Comment 4 Peter Krempa 2013-01-21 11:04:48 UTC
Fixed upstream:

commit 790f912b468657859466215312dbfb0b1a9a1f69
Author: Peter Krempa <pkrempa>
Date:   Thu Jan 17 14:07:10 2013 +0100

    qemu: Reject attempts to create snapshots with names containig '/'
    
    The snapshot name is used to create path to the definition save file.
    When the name contains slashes the creation of the file fails. Reject
    such names.

commit 27054e1217e2787b1806f55c5f6eb8908612d690
Author: Peter Krempa <pkrempa>
Date:   Thu Jan 17 14:04:01 2013 +0100

    qemu: Don't return success if creation of snapshot save file fails
    
    When the snapshot definition can't be saved, the
    qemuDomainSnapshotCreate function succeeded without filling some of the
    fields in the internal definition.
    
    This patch removes the snapshot and returns failure if the XML file
    cannot be written.

Comment 7 yanbing du 2013-01-24 05:08:16 UTC
Test with libvirt-0.10.2-17.el6.x86_64

# virsh snapshot-create-as test /tmp/test.sn
error: invalid snapshot name '/tmp/test.sn': name can't contain '/'

So, move but to VERIFIED.

Comment 8 errata-xmlrpc 2013-02-21 07:29:55 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.

http://rhn.redhat.com/errata/RHSA-2013-0276.html