Bug 1035001

Summary: VHDX: journal log should not be replayed by default, but rather via qemu-img check -r all
Product: Red Hat Enterprise Linux 7 Reporter: Jeff Cody <jcody>
Component: qemu-kvmAssignee: Jeff Cody <jcody>
Status: CLOSED CURRENTRELEASE QA Contact: Virtualization Bugs <virt-bugs>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.0CC: acathrow, jcody, juzhang, michen, sluo, virt-maint
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: qemu-kvm-1.5.3-36.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 1063559 (view as bug list) Environment:
Last Closed: 2014-06-13 11:56:54 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 Jeff Cody 2013-11-26 20:20:21 UTC
The VHDX r/w driver replays dirty log journals on open, if the image file is opened r/w.  The problem with this approach is two-fold:  1.) If the VHDX image format is in a r/o whitelist, then journal logs can not be replayed, and 2) even when the image file is r/w, we may want to allow the image files to be cleaned up without needing to launch a full guest instance in r/w.


The solution for this is pretty straightforward:

1.) Have qemu-img check (.bdrv_check) for VHDX check the log integrity, and replay the log if '-r all' is passed to qemu-img check.

2.) Do not automatically replay the log on .bdrv_open (vhdx_open), and return error if .bdrv_open is called on a VHDX image file that contains a dirty log (even if opened r/w).

3.) Optionally add in a drive option for VHDX, to provide the option of replaying the log on open if desired, if the image is opened r/w.


These changes should be pretty straightforward, and allow for qemu to support VHDX log files even if VHDX is only in the read-only whitelist.

Comment 2 Jeff Cody 2013-12-17 16:38:39 UTC
Posted upstream:

http://lists.gnu.org/archive/html/qemu-devel/2013-12/msg03087.html

The agreed above behavior is as follows:

1.) If the image is opened r/o, and has a dirty log, provide a helpful error message instructing the user to run qemu-img check -r all, to replay the image.

2.) If the image is opened r/w, and has a dirty log, replay the log automatically as we currently do.


It should be noted that even without the patch above, running qemu-img check r- all on a VHDX image file will replay the log, even though an error is printed about VHDX not supporting 'check'.  This is because prior to that error, the image file was already opened r/w by qemu-img.

The patch posted upstream provides a .bdrv_check() implementation, and a useful error output.

Comment 4 Miroslav Rezanina 2014-01-14 18:42:57 UTC
Fix included in qemu-kvm-1.5.3-36.el7

Comment 8 Sibiao Luo 2014-02-11 03:07:30 UTC
Reproduce and verified this issue with the instruction of comment #2 and comment #7.

######Reproduced:
host info:
# uname -r && rpm -q qemu-kvm
3.10.0-76.el7.x86_64
qemu-kvm-1.5.3-35.el7.x86_64

Steps and Results:
1. If the image is opened r/o.
# qemu-img check -f vhdx tests_qemu-iotests_sample_images_iotest-dirtylog-10G-4M.vhdx
qemu-img: Could not open 'tests_qemu-iotests_sample_images_iotest-dirtylog-10G-4M.vhdx': Could not open 'tests_qemu-iotests_sample_images_iotest-dirtylog-10G-4M.vhdx': Permission denied

2. If the image is opened r/w.
# qemu-img check -r all tests_qemu-iotests_sample_images_iotest-dirtylog-10G-4M.vhdx
qemu-img: This image format does not support checks
# qemu-img check -f vhdx tests_qemu-iotests_sample_images_iotest-dirtylog-10G-4M.vhdx
qemu-img: This image format does not support checks


######Verified:
host info:
# uname -r && rpm -q qemu-kvm
3.10.0-76.el7.x86_64
qemu-kvm-1.5.3-45.el7.x86_64

Steps and Results:
1. If the image is opened r/o, and has a dirty log, provide a helpful error message instructing the user to run qemu-img check -r all, to replay the image.
# qemu-img check -f vhdx tests_qemu-iotests_sample_images_iotest-dirtylog-10G-4M.vhdx
qemu-img: Could not open 'tests_qemu-iotests_sample_images_iotest-dirtylog-10G-4M.vhdx': VHDX image file 'tests_qemu-iotests_sample_images_iotest-dirtylog-10G-4M.vhdx' opened read-only, but contains a log that needs to be replayed.  To replay the log, execute:
 qemu-img check -r all 'tests_qemu-iotests_sample_images_iotest-dirtylog-10G-4M.vhdx': Operation not permitted

2. If the image is opened r/w, and has a dirty log, replay the log automatically as we currently do.
# qemu-img check -r all tests_qemu-iotests_sample_images_iotest-dirtylog-10G-4M.vhdx
The following inconsistencies were found and repaired:

    0 leaked clusters
    1 corruptions

Double checking the fixed image now...
No errors were found on the image.
# qemu-img check -f vhdx tests_qemu-iotests_sample_images_iotest-dirtylog-10G-4M.vhdx
No errors were found on the image.

Base on above, this issue has been fixed correctly, move to VERIFIED status, please correct me if any mistake, thanks in advance.

Best Regards,
sluo

Comment 10 Ludek Smid 2014-06-13 11:56:54 UTC
This request was resolved in Red Hat Enterprise Linux 7.0.

Contact your manager or support representative in case you have further questions about the request.