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 1126329 - Libvirt should forbid using relative path to the new overaly snapshot image for external snapshots
Summary: Libvirt should forbid using relative path to the new overaly snapshot image f...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libvirt
Version: 7.0
Hardware: Unspecified
OS: Unspecified
high
medium
Target Milestone: rc
: ---
Assignee: Peter Krempa
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On:
Blocks: 1127226
TreeView+ depends on / blocked
 
Reported: 2014-08-04 08:11 UTC by Shanzhi Yu
Modified: 2015-03-05 07:41 UTC (History)
6 users (show)

Fixed In Version: libvirt-1.2.8-1.el7
Doc Type: Bug Fix
Doc Text:
Clone Of:
: 1127226 (view as bug list)
Environment:
Last Closed: 2015-03-05 07:41:41 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2015:0323 0 normal SHIPPED_LIVE Low: libvirt security, bug fix, and enhancement update 2015-03-05 12:10:54 UTC

Description Shanzhi Yu 2014-08-04 08:11:59 UTC
Description of problem:



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

libvirt-1.1.1-29.el7_0.1.x86_64


How reproducible:
100%

Steps to Reproduce:

1. Create external disk snapshot with relative path

# pwd
/root

# virsh snapshot-create-as rhel6 s1 --diskspec vda,file=./rhel6.s1 --disk-only
Domain snapshot s1 created

# virsh snapshot-dumpxml rhel6 s1

<domainsnapshot>
  <name>s1</name>
  <state>disk-snapshot</state>
  <creationTime>1406813388</creationTime>
  <memory snapshot='no'/>
  <disks>
    <disk name='vda' snapshot='external' type='file'>
      <driver type='qcow2'/>
      <source file='./rhel6.s1'/>
    </disk>
  </disks>

# virsh dumpxml rhel6
..
<disk type='file' device='disk'>
      <driver type='qcow2' cache='none'/>
      <source file='./rhel6.s1'/>
      <backingStore type='file' index='1'>
        <format type='qcow2'/>
        <source file='/usr/local/var/lib/libvirt/images/rhel6.img'/>
        <backingStore/>
      </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 with absolute path

# virsh snapshot-create-as rhel6 s2 --diskspec vda,file=/usr/local/var/lib/libvirt/images/rhel6.s2 --disk-only
Domain snapshot s2 created

# virsh dumpxml rhel6

..
 <disk type='file' device='disk'>
      <driver type='qcow2' cache='none'/>
      <source file='/usr/local/var/lib/libvirt/images/rhel6.s2'/>
      <target dev='vda' bus='virtio'/>
      <alias name='virtio-disk0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
    </disk>
..

#qemu-img  info /usr/local/var/lib/libvirt/images/rhel6.s2
image: /usr/local/var/lib/libvirt/images/rhel6.s2
file format: qcow2
virtual size: 3.9G (4194304000 bytes)
disk size: 712K
cluster_size: 65536
backing file: ./rhel6.s1 (actual path: /usr/local/var/lib/libvirt/images/./rhel6.s1)


3. Create external disk snapshot 

# virsh snapshot-create-as rhel6 s3  --disk-only
error: internal error: unable to execute QEMU command 'transaction': Could not open '/usr/local/var/lib/libvirt/images/rhel6.s2': Could not open file: No such file or directory: No such file or directory


# ll /usr/local/var/lib/libvirt/images/rhel6.s2
-rw-------. 1 root root 2228224 Jul 31 21:42 /usr/local/var/lib/libvirt/images/rhel6.s2 

Actual results:


Expected results:


Additional info:

Comment 1 Peter Krempa 2014-08-06 12:29:54 UTC
Relative paths shouldn't be used for external snapshot file names. Libvirt shouldn't allow them and to create a relatively addressed snapshot we need a different mechanism.

Comment 2 Peter Krempa 2014-08-06 16:04:49 UTC
Fixed upstream:

commit 29bb066915d0d0480b65fe404479babf5e076ac7
Author: Peter Krempa <pkrempa>
Date:   Wed Aug 6 15:17:00 2014 +0200

    snapshot: conf: Enforce absolute paths on disk and memory images
    
    RNG schema as well as the qemu driver requires absolute paths for memory
    and disk snapshot image files but the XML parser was not enforcing it.
    Add checks to avoid problems in qemu where the configuration it creates
    is invalid.

v1.2.7-13-g29bb066

Comment 4 Yang Yang 2014-10-28 09:58:20 UTC
Verified on libvirt-1.2.8-5.el7.x86_64

Steps:
1. prepare a running vm
# virsh list --all
 Id    Name                           State
----------------------------------------------------
 4     qe-con1                        running

2. create external system checkpoint snapshot 
# virsh snapshot-create-as qe-con1 s1 --memspec file=./qe-con1.mem --diskspec vda,file=./qe-con1.s1
error: XML error: memory snapshot file path (./qe-con1.mem) must be absolute

3. create external disk only snapshot
# virsh snapshot-create-as qe-con1 s1 --disk-only --diskspec vda,file=./qe-con1.s1
error: XML error: disk snapshot image path './qe-con1.s1' must be absolute

4. create snapshot with xml
# cat qe-con1.s1.xml 
<domainsnapshot>
<name>s1</name>
<disks>
<disk name='vda'>
<source file='./qe-con1.s1'/>
</disk>
</disks>
</domainsnapshot>

# virsh snapshot-create qe-con1 qe-con1.s1.xml --disk-only
error: XML error: disk snapshot image path './qe-con1.s1' must be absolute

5. create snapshot with xml
# cat qe-con1.s1.xml 
<domainsnapshot>
<name>s1</name>
<memory snapshot='external' file='./qe-con1.mem'/>
<disks>
<disk name='vda'>
<source file='./qe-con1.s1'/>
</disk>
</disks>
</domainsnapshot>

# virsh snapshot-create qe-con1 qe-con1.s1.xml 
error: XML error: memory snapshot file path (./qe-con1.mem) must be absolute

Since all the steps got the expected results, set it to verified.

Comment 6 errata-xmlrpc 2015-03-05 07:41:41 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


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