Resizing luks encrypted disks fails with "unable to execute QEMU command 'block_resize': Cannot grow device files"

ONE 6.8.0.1
i’m currently trying to resize luks encrypted disks attached to VMs. the systemds is a iscsi san storage.
when i try to resize the disk i get the error

Wed Jan 15 14:16:44 2025 [Z0][VMM][D]: Message received: RESIZEDISK FAILURE 6 ERROR: resize_disk: Command "virsh --connect qemu:///system blockresize 490a48b5-4d33-4384-aa7c-0e8530b02af5 vdb 6144M" failed: error: Failed to resize block device 'vdb' error: internal error: unable to execute QEMU command 'block_resize': Cannot grow device files Failed to resize disk 2 on 490a48b5-4d33-4384-aa7c-0e8530b02af5 ExitCode: 1

did a little bit of testing and noticed:

Thu Jan 16 10:17:36 2025 [Z0][VMM][D]: Message received: RESIZEDISK FAILURE 6 ERROR: resize_disk: Command "virsh --connect qemu:///system blockresize 490a48b5-4d33-4384-aa7c-0e8530b02af5 vdc 512M" failed: error: Failed to resize block device 'vdc' error: internal error: unable to execute QEMU command 'block_resize': Cannot grow device files Failed to resize disk 4 on 490a48b5-4d33-4384-aa7c-0e8530b02af5 ExitCode: 1

Thu Jan 16 10:17:39 2025 [Z0][ReM][D]: Req:3456 UID:0 IP:127.0.0.1 one.zone.raftstatus invoked 
Thu Jan 16 10:17:39 2025 [Z0][ReM][D]: Req:3456 UID:0 one.zone.raftstatus result SUCCESS, "<RAFT><SERVER_ID>1</..."
^C
[oneadmin@one2 ~]$ virsh --connect qemu:///system blockresize 490a48b5-4d33-4384-aa7c-0e8530b02af5 vdc 512M
error: Failed to resize block device 'vdc'
error: internal error: unable to execute QEMU command 'block_resize': Cannot grow device files

[oneadmin@one2 ~]$ virsh --connect qemu:///system blockresize 490a48b5-4d33-4384-aa7c-0e8530b02af5 vdc 0
Block device 'vdc' is resized
[oneadmin@one2 ~]$ 
Thu Jan 16 10:19:15 2025 [Z0][VMM][D]: Message received: RESIZEDISK FAILURE 6 ERROR: resize_disk: Command "virsh --connect qemu:///system blockresize 490a48b5-4d33-4384-aa7c-0e8530b02af5 vdc 768M" failed: error: Failed to resize block device 'vdc' error: internal error: unable to execute QEMU command 'block_resize': Cannot grow device files Failed to resize disk 4 on 490a48b5-4d33-4384-aa7c-0e8530b02af5 ExitCode: 1

^C
[oneadmin@one2 ~]$ virsh --connect qemu:///system blockresize 490a48b5-4d33-4384-aa7c-0e8530b02af5 vdc 768M
error: Failed to resize block device 'vdc'
error: internal error: unable to execute QEMU command 'block_resize': Cannot grow device files

[oneadmin@one2 ~]$ virsh --connect qemu:///system blockresize 490a48b5-4d33-4384-aa7c-0e8530b02af5 vdc 760M
Block device 'vdc' is resized

i think it’s related to

# Extend the SIZE so the encrypted file fits in the LV
if [[ "$FILE_TYPE" =~ "LUKS encrypted file" ]]; then
    SIZE=$(( SIZE + 4 ))
fi

in tm/fs_lvm/clone

changing

retry_if "is in use" 3 5 \
    exec_and_log "virsh --connect ${LIBVIRT_URI} blockresize ${DOMAIN} ${DISK_TARGET} ${DISK_SIZE}M" \
    "Failed to resize disk ${DISK_ID} on ${DOMAIN}"

to

retry_if "is in use" 3 5 \
    exec_and_log "virsh --connect ${LIBVIRT_URI} blockresize ${DOMAIN} ${DISK_TARGET} 0" \
    "Failed to resize disk ${DISK_ID} on ${DOMAIN}"

seems to fix the issue, i’m not sure about the conseques though, because the qemu/libvirt luks encryption is new to me.

Hello @twa,

Apologies for the delay, and thanks for your patience. Our team is investigating this issue, as it’s not a straightforward fix.

This error seems to occur with specific disk sizes, likely because the virsh blockresize command doesn’t fully support resizing LUKS-encrypted disks. A possible workaround is to modify the OpenNebula transfer manager script to adjust the blockresize parameters.

Have you had a chance to check the documentation on LUKS-encrypted images? You can find relevant details here:
:link: LUKS-Encrypted Images Documentation

In any case, our team will provide you with a more precise response soon. Thanks again for your patience!

Cheers,

Thanks for your reply.
My biggest concern with modifying the tm is that i’m not sure if using just 0 as size could lead to any issues later. i did some basic tests and it seems everything is fine after resizing and checksums seem fine.