Bug 1655065 - [rhel.8.0][fast train]'qemu-img measure' size does not match the real allocated size for luks-inside-qcow2 image
Summary: [rhel.8.0][fast train]'qemu-img measure' size does not match the real allocat...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux Advanced Virtualization
Classification: Red Hat
Component: qemu-kvm
Version: 8.0
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: rc
: 8.0
Assignee: Stefan Hajnoczi
QA Contact: Tingting Mao
URL:
Whiteboard:
: 1542858 (view as bug list)
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2018-11-30 13:01 UTC by Tingting Mao
Modified: 2019-08-29 18:49 UTC (History)
12 users (show)

Fixed In Version: qemu-kvm-3.1.0-21.module+el8.0.1+3009+b48fff88
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2019-08-07 10:41:09 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2019:2395 0 None None None 2019-08-07 10:41:35 UTC

Description Tingting Mao 2018-11-30 13:01:07 UTC
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:

Comment 2 Tingting Mao 2018-12-17 08:18:06 UTC
*** Bug 1542858 has been marked as a duplicate of this bug. ***

Comment 3 Stefan Hajnoczi 2019-01-15 11:12:58 UTC
Patches posted upstream:
https://patchwork.ozlabs.org/patch/1025115/

Comment 5 Danilo de Paula 2019-03-06 18:02:25 UTC
knoel: this seems too late for 8.0.0.

Since it's advance virt, is it 8.0.1?

Comment 8 Danilo de Paula 2019-04-11 18:33:10 UTC
Fix included in qemu-kvm-3.1.0-21.module+el8.0.1+3009+b48fff88

Comment 10 Tingting Mao 2019-04-22 10:09:59 UTC
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)

Comment 12 errata-xmlrpc 2019-08-07 10:41:09 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://access.redhat.com/errata/RHBA-2019:2395


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