Description of problem: 'qemu-img measure' size does not match the real allocated size for luks-inside-qcow2 image. Version-Release number of selected component (if applicable): qemu-kvm-3.1.0-0.module+el8+2266+616cf026.next.candidate kernel-4.18.0-45.el8 How reproducible: 100% Steps to Reproduce: 1.Create a qcow2 file, and write data to it. # qemu-img create -f qcow2 source.qcow2 4G # qemu-io -c 'write -P 1 0 1G' source.qcow2 wrote 1073741824/1073741824 bytes at offset 0 1 GiB, 1 ops; 0:00:09.97 (102.681 MiB/sec and 0.1003 ops/sec) 2.Measure the needed size for a luks-inside-qcow2 file # qemu-img measure -f qcow2 -O qcow2 --object secret,id=sec0,data=base -o encrypt.format=luks,encrypt.key-secret=sec0 source.qcow2 required size: 1074659328 fully allocated size: 4295884800 3.Convert to target file, and check the size # qemu-img convert -f qcow2 -O qcow2 --object secret,id=sec0,data=base -o encrypt.format=luks,encrypt.key-secret=sec0 source.qcow2 target_luks.qcow2 -p (100.00/100%) # stat -c %s target_luks.qcow2 1076232192 ------------> Larger than 'required size: 1074659328' 4. Convert with full allocated, and check the size # qemu-img convert -f qcow2 -O qcow2 --object secret,id=sec0,data=base -o encrypt.format=luks,encrypt.key-secret=sec0 source.qcow2 target_luks.qcow2 -S 0 -p (100.00/100%) # stat -c %s target_luks.qcow2 4297981952 --------------> Larger than 'fully allocated size: 4295884800' Actual results: As above. Expected results: The values reported from 'qemu-img measure' should be guaranteed to be large enough to fit the new images. Additional info:
*** Bug 1542858 has been marked as a duplicate of this bug. ***
Patches posted upstream: https://patchwork.ozlabs.org/patch/1025115/
knoel: this seems too late for 8.0.0. Since it's advance virt, is it 8.0.1?
Fix included in qemu-kvm-3.1.0-21.module+el8.0.1+3009+b48fff88
Verified this bug as below. Tested with: qemu-kvm-3.1.0-22.module+el8.0.1+3032+a09688b9 kernel-4.18.0-80.el8 Steps: 1. Measure the requied sizes for a luks-encrypted qcow2 image file # qemu-img info source.qcow2 image: source.qcow2 file format: qcow2 virtual size: 4.0G (4294967296 bytes) disk size: 1.0G cluster_size: 65536 Format specific information: compat: 1.1 lazy refcounts: false refcount bits: 16 corrupt: false # qemu-img measure -f qcow2 -O qcow2 --object secret,id=sec0,data=base -o encrypt.format=luks,encrypt.key-secret=sec0 source.qcow2 required size: 1076756480 fully allocated size: 4297981952 2. Convert with default config # qemu-img convert -f qcow2 -O qcow2 --object secret,id=sec0,data=base -o encrypt.format=luks,encrypt.key-secret=sec0 source.qcow2 target_luks.qcow2 -p (100.00/100%) 3. Check the size of the target image # stat -c %s target_luks.qcow2 1076232192 -------------- Smaller than the required size(1076756480) 4. Convert with full allocation # qemu-img convert -f qcow2 -O qcow2 --object secret,id=sec0,data=base -o encrypt.format=luks,encrypt.key-secret=sec0 source.qcow2 target_full_luks.qcow2 -S 0 -p (100.00/100%) 5. Check the size of the target image # stat -c %s target_full_luks.qcow2 4297981952 --------------- Equal to the required size(4297981952)
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://access.redhat.com/errata/RHBA-2019:2395