Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
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 1089924

Summary: There will be file lost in guest after do blockcommit when guest with non-cached qcow2 disk as source file
Product: Red Hat Enterprise Linux 6 Reporter: Shanzhi Yu <shyu>
Component: libvirtAssignee: Giuseppe Scrivano <gscrivan>
Status: CLOSED NOTABUG QA Contact: Virtualization Bugs <virt-bugs>
Severity: high Docs Contact:
Priority: high    
Version: 6.6CC: acathrow, bili, chhu, dallan, dyuan, jdenemar, jmiao, mzhan
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 1089921 Environment:
Last Closed: 2014-04-23 12:01: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:
Bug Depends On: 1089921    
Bug Blocks:    

Description Shanzhi Yu 2014-04-22 09:03:13 UTC
Also reproduce it on rhel6, so clone to rhel6

+++ This bug was initially created as a clone of Bug #1089921 +++

Description of problem:

There will be file lost in guest after do blockcommit when guest with non-cached qcow2 disk as source file

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

qemu-kvm-rhev-1.5.3-60.el7ev.x86_64
libvirt-1.1.1-29.el7.x86_64


How reproducible:

100%

Steps to Reproduce:

1.prepare an guest with non-cached qcow2 disk as source file

# virsh list
 Id    Name                           State
----------------------------------------------------
 17    rhel6                          running

# virsh domblklist rhel6
Target     Source
------------------------------------------------
sda        /var/lib/libvirt/images/base.img

#virsh dumpxml rhel6|grep disk -A 4

    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2' cache='none'/>
      <source file='/var/lib/libvirt/images/base.img'/>
      <target dev='sda' bus='scsi'/>
      <alias name='scsi0-0-0-0'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </disk>


2.create  external disk-only snapshot, and login guest to create
file with same name as snapshot name

# virsh snapshot-create-as rhel6 s1 --disk-only  
Domain snapshot s1 created

login guest and create file s1

[guest]# echo "hello s1" > s1

3. repeat step2, instead s1 with s2, s3 and s4

# virsh snapshot-list rhel6
 Name                 Creation Time             State
------------------------------------------------------------
 s1                   2014-04-21 17:35:44 +0800 disk-snapshot
 s2                   2014-04-21 17:36:13 +0800 disk-snapshot
 s3                   2014-04-21 17:36:27 +0800 disk-snapshot
 s4                   2014-04-21 17:36:42 +0800 disk-snapshot

# virsh domblklist rhel6
Target     Source
------------------------------------------------
sda        /var/lib/libvirt/images/base.s4

login guest and check the file created in step 2&3

[guest]# ll s*
-rw-r--r--. 1 root root     9 Apr 21 18:10 s1
-rw-r--r--. 1 root root     9 Apr 21 18:10 s2
-rw-r--r--. 1 root root     9 Apr 21 18:10 s3
-rw-r--r--. 1 root root     9 Apr 21 18:11 s4


4. do blockcommit from s2 to base; then check the disk chain

# virsh blockcommit rhel6 sda --top /var/lib/libvirt/images/base.s2  --base /var/lib/libvirt/images/base.img  --verbose --wait
Block Commit: [100 %]
Commit complete

# qemu-img info  --backing-chain /var/lib/libvirt/images/base.s4

/var/lib/libvirt/images/base.img <-- /var/lib/libvirt/images/base.s3 <-- /var/lib/libvirt/images/base.s4


5. change guest source file from base.s4 to base.img

# virsh domblklist rhel6
Target     Source
------------------------------------------------
sda        /var/lib/libvirt/images/base.img

login guest and check the file created in step 2&3

# ll s*
-rw-r--r--. 1 root root 0 Apr 21 18:10 s1
-rw-r--r--. 1 root root 0 Apr 21 18:10 s2

6. change guest source file from base.img to base.s4,
restart guest and login guest check file created in step 2&3

[guest]# ll s*

ls: cannot access s3: Input/output error
-rw-r--r--. 1 root root 0 Apr 21 18:10 s1
-rw-r--r--. 1 root root 0 Apr 21 18:10 s2
srwxr-xr-x. 1 gdm  gdm  0 Apr 21 18:17 s4

7. do blockcommit from s3 to base;then check the disk chain

# virsh blockcommit rhel6 sda --top /var/lib/libvirt/images/base.s3 --base /var/lib/libvirt/images/base.img  --verbose --wait
Block Commit: [100 %]
Commit complete

# qemu-img info  --backing-chain /var/lib/libvirt/images/base.s4

/var/lib/libvirt/images/base.img <-- /var/lib/libvirt/images/base.s4

8. change guest source file from base.s4 to base.img,
restart guest and login guest check file created in step 2&3

[guest]# ll s*
-rw-r--r--. 1 root root 0 Apr 21 18:10 s1
-rw-r--r--. 1 root root 0 Apr 21 18:10 s2




Actual results:

In step 5), the content of file s1 and s2 lost
In step 6), file s3 lost, file s4 change to socket file.
In step 8), file s3, lost

Expected results:



Additional info:

base.img is an qcow2 v2 format file, with rhel6.5 installed.

Comment 1 Jiri Denemark 2014-04-23 12:01:25 UTC
By booting the domain from base.img in step 5, you made any image based on base.img completely useless (i.e., base.s3 and base.s4 contain just garbage). This is because booting from the image changes it (and in case of ext3 even mounting the image which was not cleanly unmounted read-only would change it too).