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 843372 - disk-only snapshot create external file even if snapshot command failed
Summary: disk-only snapshot create external file even if snapshot command failed
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: libvirt
Version: 6.4
Hardware: x86_64
OS: Linux
medium
medium
Target Milestone: rc
: ---
Assignee: Gunannan Ren
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2012-07-26 07:14 UTC by Huang Wenlong
Modified: 2013-10-20 21:45 UTC (History)
11 users (show)

Fixed In Version: libvirt-0.10.2-0rc1.el6
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2013-02-21 07:20:02 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2013:0276 0 normal SHIPPED_LIVE Moderate: libvirt security, bug fix, and enhancement update 2013-02-20 21:18:26 UTC

Description Huang Wenlong 2012-07-26 07:14:54 UTC
Description of problem:
disk-only snapshot create external file even if snapshot command failed

Version-Release number of selected component (if applicable):
libvirt-0.9.13-3.el6.x86_64

How reproducible:
100%

Steps to Reproduce:

1.# prepare a qcow2 domain with 2 disk
...
  <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2' cache='none'/>
      <source file='/var/lib/libvirt/images/q2.new2'/>
      <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' cache='none'/>
      <source file='/var/lib/libvirt/images/q2-2-new2'/>
      <target dev='vda' bus='virtio'/>
      <alias name='virtio-disk0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
    </disk>

...

2.  try to create disk-only snapshot with xml   file
<domainsnapshot>
<description>Snapshot of OS install and updates</description>
<disks>
<disk name='/var/lib/libvirt/images/q2.new2'>
<source file='/var/lib/libvirt/images/q2.new3'/>
</disk>
<disk name='/var/lib/libvirt/images/q2-2-new2'>
<source file='/var/lib/libvirt/images/q2-2-new3'/>
</disk>
</disks>
</domainsnapshot>

3. do some operation  to make snapshot failed , you can do other option to make snapshot fail .too
# chmod 000 /var/lib/libvirt/images/q2-2-new2

4.  check whether file is exist before  the run the virsh snapshot cmd
#ll /var/lib/libvirt/images/*new3*
ls: cannot access /var/lib/libvirt/images/*new3*: No such file or directory

# virsh snapshot-create q2 --disk-only snap-disk.xml
error: internal error unable to execute QEMU command 'transaction': Could not open '/var/lib/libvirt/images/q2-2-new3'

# ll /var/lib/libvirt/images/*new3*
-rw-------. 1 root root 262144 Jul 26 11:25 /var/lib/libvirt/images/q2.new3

NOTE: snapshot cmd failed but  q2.new3 file is created .

Actual results:
as step4

Expected results:
clean the file after snapshot failed or do not create it when snapshot failed

Additional info:

Comment 2 Gunannan Ren 2012-08-22 07:45:09 UTC
This is the normal result if --atomic option is not specified.
But right now, atomic live snapshot of multiple disks is unsupported:

# virsh snapshot-create-as rhel6u3qcow2 s2 --disk-only --atomic
error: unsupported configuration: atomic live snapshot of multiple disks is unsupported

This is not a bug currently, or it could be changed to a RFE.

Comment 3 Huang Wenlong 2012-08-22 07:46:30 UTC
Hi, Eric 

This bug relates "--atomic" option but disk-snapshot do not support it now .

Does libvirt purpose to support  "atomic live snapshot of multiple disks"  in the RHEL6.4 or RHEL7, if there is a plan to support it , I will change this bug name to "[RFE] support atomic live snapshot of multiple disks " if not  this bug will be closed , because --atomic disk snapshot will not support in the RHEL 
Thanks very much .


Wenlong

Comment 4 Eric Blake 2012-08-22 11:55:33 UTC
Are you using qemu-kvm (disk snapshots not supported) or qemu-kvm-rhev (disk snapshots ARE supported) in your testing?  Do not change this to RFE, because this feature was supposed to work in 6.3, and must work in 6.4, when you are using the correct qemu.

Comment 5 Huang Wenlong 2012-08-23 02:26:50 UTC
(In reply to comment #4)
> Are you using qemu-kvm (disk snapshots not supported) or qemu-kvm-rhev (disk
> snapshots ARE supported) in your testing?  Do not change this to RFE,
> because this feature was supposed to work in 6.3, and must work in 6.4, when
> you are using the correct qemu.

I am using qemu-kvm-rhev in the disk-snapshot testing 
In this case I need --atomic in the --disk-only snapshot it can not support as comment 2 ,it just support internal snapshot with atomic .
Dose libvirt purpose to support atomic disk snapshot in the rhel6.4 ?

Comment 6 Eric Blake 2012-08-23 05:56:43 UTC
(In reply to comment #5)
> I am using qemu-kvm-rhev in the disk-snapshot testing 

Good.

> In this case I need --atomic in the --disk-only snapshot it can not support
> as comment 2 ,it just support internal snapshot with atomic .

Here's how --atomic is supposed to work:

                              omitted          --atomic
no snapshot support           fail             fail
only blockdev-snapshot-sync   use blockdev     fail
also has transaction          use transaction  use transaction

Older qemu (such as in RHEL 6.1), and qemu-kvm in RHEL 6.3, lacks snapshot support altogether.  The qemu shipped in RHEL 6.2 had blockdev-snapshot-sync but not transaction.  qemu-kvm-rhev (introduced in 6.3) has both methods.

> Dose libvirt purpose to support atomic disk snapshot in the rhel6.4 ?

There should be no change in behavior between atomic disk snapshot support in RHEL 6.3 and RHEL 6.4.  Either you have identified a bug in RHEL 6.3, or a regression in RHEL 6.4.

Comment 7 Huang Wenlong 2012-08-23 08:15:41 UTC
Close this bug as NOTABUG :

virsh man doc has covered his use case and atomic live snapshot of multiple disks is unsupported 

man virsh : 

...
 If --atomic is specified, libvirt will guarantee that the snapshot either succeeds, or fails with
           no changes; not all hypervisors support this.  If this flag is not specified, then some hypervisors
           may fail after partially performing the action, and dumpxml must be used to see whether any partial
           changes occurred.
...

Comment 8 Gunannan Ren 2012-09-11 12:28:28 UTC
I need to reopen this bug, because as Eric said, if the qemu you are testing on is qemu-kvm-rhev, this is a bug, because the qemu-kvm-rhev should support transaction, the libvirt should rollback.

If it is the qemu-kvm with only blockdev-snapshot-sync support, it is not a bug.
Wenlong, could you confirm this or let me check it.

Comment 9 Huang Wenlong 2012-09-12 02:14:29 UTC
(In reply to comment #8)
> I need to reopen this bug, because as Eric said, if the qemu you are testing
> on is qemu-kvm-rhev, this is a bug, because the qemu-kvm-rhev should support
> transaction, the libvirt should rollback.
> 
> If it is the qemu-kvm with only blockdev-snapshot-sync support, it is not a
> bug.
> Wenlong, could you confirm this or let me check it.

Hi,Guannan 
I am sure this case using qemu-kvm-rhev . and it can not run the --disk-only with qemu-kvm which not support disk snapshot.

Comment 10 Gunannan Ren 2012-09-14 03:31:11 UTC
Yes, it is a bug, The reason and steps to reproduce by using qemu command line is described in libvirt commit log.
upstream mail discusstion link:
https://www.redhat.com/archives/libvir-list/2012-September/msg00796.html

commit ac89a611d487bd273c539eac891525da9795241d
Author: Guannan Ren <gren>
Date:   Thu Sep 13 18:09:44 2012 +0800

    snapshot: fix rollback failure in transaction mode
    
    BZ:https://bugzilla.redhat.com/show_bug.cgi?id=843372
    when qemu supports the 'transaction' monitor command,
    and libvirt's --reuse-ext flag was not specified, libvirt created
    a stub file with zero size in first place. After the failure of
    QEMU transaction command performing qcow2 snapshots on more than
    one drives, the stub file is left behind with non-empty
    by the QEMU transaction command.
    In order to unlink the file, the patch removes the file size checking.
    
    Steps to reproduce the issue:
    Steps:
     1, Create a qemu instance with two drive images of qcow2 type (root user)
        /usr/libexec/qemu-kvm -m 1024 -smp 1 -name "rhel6u1" \
          -drive file=/var/lib/libvirt/images/firstqcow2,if=none,id=drive-virtio-disk0,format=qcow2,cache=none
          -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x5,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \
          -drive file=/var/lib/libvirt/images/secondqcow2,if=none,id=drive-virtio-disk1,format=qcow2,cache=none \
          -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x7,drive=drive-virtio-disk1,id=virtio-disk1 -qmp stdio
    
     2, Initialize qemu qmp
        {"execute":"qmp_capabilities"}
    
     3, Remove the second drive image file
        rm -f /var/lib/libvirt/images/secondqcow2
    
     4, Run 'transaction' command with snapshot qemu commands in.
        {"execute":"transaction","arguments":
          {"actions":
            [{"type":"blockdev-snapshot-sync","data":
              {"device":"drive-virtio-disk0","snapshot-file":"/var/lib/libvirt/images/firstqcow2-snapshot.img","format":"qcow2"}
             },
             {"type":"blockdev-snapshot-sync","data":
              {"device":"drive-virtio-disk1","snapshot-file":"/var/lib/libvirt/images/secondqcow2-snapshot.img","format":"qcow2"}
             }]
          },
       "id":"libvirt-6"}
    
     5, Got the error as follows:
        {"id": "libvirt-6",
          "error": {"class": "OpenFileFailed", "desc": "Could not open '/var/lib/libvirt/images/secondqcow2-snapshot.img'",
                    "data": {"filename": "/var/lib/libvirt/images/secondqcow2-snapshot.img"}
                   }
        }
    
     6, List first newly-created snapshot file:
        -rw-r--r--. 1 root root     262144 Sep 13 11:43 firstqcow2-snapshot.img

Comment 11 Eric Blake 2012-09-14 03:38:50 UTC
It might be nice if qemu didn't write metadata into the file (or, if it does write, that it then does ftruncate() back to 0 to undo the write) in the cases where 'transaction' fails; but that question was posed to the upstream qemu list, and meanwhile libvirt still has to deal with current qemu, so it is not worth creating a BZ against qemu at this time.

Comment 13 zhpeng 2012-09-19 08:21:31 UTC
Test with:
libvirt-0.10.2-0rc1.el6.x86_64


#virsh dumpxml bbb
...
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2' cache='none'/>
      <source file='/var/lib/libvirt/images/bbb.qcow2'/>
      <target dev='vda' bus='virtio'/>
      <alias name='virtio-disk0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
    </disk>
    <disk type='file' device='disk'>
      <driver name='qemu' type='raw' cache='none'/>
      <source file='/var/lib/libvirt/images/rhel62.qcow2'/>
      <target dev='vdb' bus='virtio'/>
      <alias name='virtio-disk1'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
    </disk>
...
# cat snaplive.xml
<domainsnapshot>
<description>snapsnap</description>
<disks>
<disk name='/var/lib/libvirt/images/bbb.qcow2'>
<source file='/var/lib/libvirt/images/bbb.qcow2.new'/>
</disk>
<disk name='/var/lib/libvirt/images/rhel62.qcow2'>
<source file='/var/lib/libvirt/images/rhel62.qcow2.new'/>
</disk>
</disks>
</domainsnapshot>

# virsh start bbb
# chmod 000 /var/lib/libvirt/images/rhel62.qcow2

# ll /var/lib/libvirt/images/*.new
ls: cannot access /var/lib/libvirt/images/*.new: No such file or directory

# virsh snapshot-create bbb --disk-only snaplive.xml 
error: internal error unable to execute QEMU command 'transaction': Could not open '/var/lib/libvirt/images/rhel62.qcow2.new'

# ll /var/lib/libvirt/images/*.new
ls: cannot access /var/lib/libvirt/images/*.new: No such file or directory

So, this is verified.

Comment 14 errata-xmlrpc 2013-02-21 07:20:02 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


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