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.
Description of problem:
For logical partition/lvm/iSCSI image with raw format, "qemu-img resize" should fail to decrease its size and provide reasonable error.
Currently, "qemu-img resize" will fail and print error when trying to enlarge its size.
Version-Release number of selected component (if applicable):
How reproducible: 100%
Steps to Reproduce:
1. Create a lvm
# lvcreate -L 4G -n yil_lv yil_vg
2. Check the image info
# qemu-img info /dev/yil_vg/yil_lv
image: /dev/yil_vg/yil_lv
file format: raw
virtual size: 4.0G (4294967296 bytes) ----------------- size is 4G
disk size: 0
3. Use "qemu-img resize" to decrease its size
# qemu-img resize -f raw /dev/yil_vg/yil_lv -2G
Image resized.
4. Check the image info again
# qemu-img info /dev/yil_vg/yil_lv
image: /dev/yil_vg/yil_lv
file format: raw
virtual size: 4.0G (4294967296 bytes) ----------------- size is still 4G
disk size: 0
Actual results:
In step3, decreasing the lvm image's size succeeds, but in step4 this lvm image's size is NOT changed
Expected results:
In step3, decreasing the lvm image's size should fail with error
Additional info:
Resizing a raw iSCSI image has the same problem, steps are as follows:
1. Prepare an iSCSI image
2. Check the image info
# qemu-img info iscsi://10.0.0.7/iqn.2017-08.com.yilzhang:libiscsi/0
image: json:{"driver": "raw", "file": {"lun": "0", "portal": "10.0.0.7", "driver": "iscsi", "transport": "tcp", "target": "iqn.2017-08.com.yilzhang:libiscsi"}}
file format: raw
virtual size: 5.0G (5368709120 bytes)
disk size: unavailable
3. Use "qemu-img resize" to decrease its size
# qemu-img resize -f raw iscsi://10.0.0.7/iqn.2017-08.com.yilzhang:libiscsi/0 -4G
Image resized.
[root@c155f2-u3 ~]# echo $?
0
4. Check the image info again
# qemu-img info iscsi://10.0.0.7/iqn.2017-08.com.yilzhang:libiscsi/0
image: json:{"driver": "raw", "file": {"lun": "0", "portal": "10.0.0.7", "driver": "iscsi", "transport": "tcp", "target": "iqn.2017-08.com.yilzhang:libiscsi"}}
file format: raw
virtual size: 5.0G (5368709120 bytes)
disk size: unavailable
This is platform unrelated, kernel and qemu-kvm used when doing testing:
PPC:
Host kernel: 4.14.0-11.el7a.ppc64le
qemu-kvm-rhev: qemu-kvm-rhev-2.10.0-11.el7
x86:
Host kernel: 3.10.0-799.el7.x86_64
qemu-kvm-rhev: qemu-kvm-rhev-2.10.0-10.el7
Hi,
This is actually intended, judging from the code. Both the iscsi and the block device truncation code explicitly only throw an error when you try to enlarge the volume and do nothing if the volume size you want is less than what it currently is.
The commit which added truncation for iscsi (cb1b83e740384b4e0d950f3d7c81c02b8ce86c2e) actually says why this is the case: Truncation here does not work through qemu. Instead, you have to manually resize the volume on the iscsi target and then call block_resize in a qemu instance (through QMP!) with the appropiate size so that qemu knows about the change. The same applies to block device files (see 55b949c84761ade81ca93b2596ea45b09ad6d60a).
I won't close this bug now, though, because I think that the offline qemu-img resize command should indeed print a message for such protocol drivers that do not really implement truncation, and which instead just cause qemu to refresh the image's current length.
Max
Verified the issue with below packages and steps.
Package version:
kernel-3.10.0-896.el7
qemu-kvm-rhev-2.12.0-3.el7
Steps:
1.Resize the size of raw image of LVM
1.1 Check the info of the image
# qemu-img info /dev/vgtest/lvtest
image: /dev/vgtest/lvtest
file format: raw
virtual size: 4.0G (4294967296 bytes)
disk size: 0
1.2 Decrease the size
# qemu-img resize -f raw --shrink /dev/vgtest/lvtest -2G -----> failed
qemu-img: Image was not resized; resizing may not be supported for this image
1.3 Check the image size
# qemu-img info /dev/vgtest/lvtest
image: /dev/vgtest/lvtest
file format: raw
virtual size: 4.0G (4294967296 bytes) ----> the size not changed
disk size: 0
2.Resize the size of raw image of ISCSI
2.1 Check the info of the image
# qemu-img info iscsi://10.66.11.19/iqn.2018-05.com.example.t1/0
image: json:{"driver": "raw", "file": {"lun": "0", "portal": "10.66.11.19", "driver": "iscsi", "transport": "tcp", "target": "iqn.2018-05.com.example.t1"}}
file format: raw
virtual size: 80G (85899345920 bytes)
disk size: unavailable
2.2 Decrease the size
# qemu-img resize --shrink -f raw iscsi://10.66.11.19/iqn.2018-05.com.example.t1/0 -5G -----> failed
qemu-img: Image was not resized; resizing may not be supported for this image
2.3 Check the size
# qemu-img info iscsi://10.66.11.19/iqn.2018-05.com.example.t1/0
image: json:{"driver": "raw", "file": {"lun": "0", "portal": "10.66.11.19", "driver": "iscsi", "transport": "tcp", "target": "iqn.2018-05.com.example.t1"}}
file format: raw
virtual size: 80G (85899345920 bytes) -----> the size not changed
disk size: unavailable
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-2018:3443
Description of problem: For logical partition/lvm/iSCSI image with raw format, "qemu-img resize" should fail to decrease its size and provide reasonable error. Currently, "qemu-img resize" will fail and print error when trying to enlarge its size. Version-Release number of selected component (if applicable): How reproducible: 100% Steps to Reproduce: 1. Create a lvm # lvcreate -L 4G -n yil_lv yil_vg 2. Check the image info # qemu-img info /dev/yil_vg/yil_lv image: /dev/yil_vg/yil_lv file format: raw virtual size: 4.0G (4294967296 bytes) ----------------- size is 4G disk size: 0 3. Use "qemu-img resize" to decrease its size # qemu-img resize -f raw /dev/yil_vg/yil_lv -2G Image resized. 4. Check the image info again # qemu-img info /dev/yil_vg/yil_lv image: /dev/yil_vg/yil_lv file format: raw virtual size: 4.0G (4294967296 bytes) ----------------- size is still 4G disk size: 0 Actual results: In step3, decreasing the lvm image's size succeeds, but in step4 this lvm image's size is NOT changed Expected results: In step3, decreasing the lvm image's size should fail with error Additional info: Resizing a raw iSCSI image has the same problem, steps are as follows: 1. Prepare an iSCSI image 2. Check the image info # qemu-img info iscsi://10.0.0.7/iqn.2017-08.com.yilzhang:libiscsi/0 image: json:{"driver": "raw", "file": {"lun": "0", "portal": "10.0.0.7", "driver": "iscsi", "transport": "tcp", "target": "iqn.2017-08.com.yilzhang:libiscsi"}} file format: raw virtual size: 5.0G (5368709120 bytes) disk size: unavailable 3. Use "qemu-img resize" to decrease its size # qemu-img resize -f raw iscsi://10.0.0.7/iqn.2017-08.com.yilzhang:libiscsi/0 -4G Image resized. [root@c155f2-u3 ~]# echo $? 0 4. Check the image info again # qemu-img info iscsi://10.0.0.7/iqn.2017-08.com.yilzhang:libiscsi/0 image: json:{"driver": "raw", "file": {"lun": "0", "portal": "10.0.0.7", "driver": "iscsi", "transport": "tcp", "target": "iqn.2017-08.com.yilzhang:libiscsi"}} file format: raw virtual size: 5.0G (5368709120 bytes) disk size: unavailable