virsh blockresize should not require --size for block devices
Goal
The goal of this feature request is to give administrators greater confidence in resizing block-storage-backed virtual disks.
Technical details
I'm using virsh 4.5.0 from libvirt-4.5.0-36.el7_9.5.x86_64
virsh blockresize today, requires --size. Specifically the manpage says:
blockresize domain path size with domain and path being single arguments, and size being the "--size" flag and then an integer with a suffix for units.
(--flags are superfluous if used for mandatory arguments. If size is always required, it should probably not use a -- flag, but instead be a required ordinal argument.)
Additional information
I believe virsh blockresize requires --size because with file-backed disks (which perhaps at one point in the past were the only type supported) virsh actually causes the work to be done of performing the resize.
I (and probably some other weird people) use LVM LVs for my virtual disks. Actually it's raid, lvm, dmcrypt, and then drbd... But the end result is that I plan and perform the physical grow operation at each layer before I involve virsh. I wouldn't really want virsh to do it on its own. But I need libvirt to eventually detect and pass through the new size to the vm.
virsh blockresize looks like the right tool to cause libvirtd to notify the vm of a resized block device, but the documentation is unclear what happens I give it the wrong size, or how even how exactly I should determine the size. I presume most admins would know that, but for an operation that could damage a production service, it would be nice to see the method the developers expect us to use, written out in the manpage.
I used blockdev --getsize64 /dev/drbd8 to get my size in bytes and specified that size with a lower case b:
virsh blockresize myvmhere vdb --size 4980351905792b and that seems to have worked okay.
Suggestion:
-
First: update the documentation to note "If your virtual disk is block-based (lvm/raid/iscsi) and you have already grown it, specify the --size as reported by blockdev --getsize64 /dev/" Hopefully the distributions can pick up this update to documentation for the existing installbase, or its availability online or perhaps in this very ticket visible online, will help other admins confidently resize their disks.
-
At the next major release: change the syntax of virsh blockresize from
virsh blockresize <domain> <disk> --size <size>tovirsh blockresize <domain> <disk> [size]If size is not specified and it's a file-backed store, do nothing and exit with an explanatory error. if size is not specified and it's a block-backed store, detect the current size of that store and use that. ** If size is specified, then do as before with --size .
**This is consistent with the behavior of other resize commands: pvresize, cryptsetup, drmdadm, resize2fs