[pve-devel] [PATCH pve-storage] qcow2: resize: add preallocation support

Fiona Ebner f.ebner at proxmox.com
Mon Feb 3 15:39:41 CET 2025


Am 19.12.24 um 17:18 schrieb Alexandre Derumier via pve-devel:
> Seem that we totally forgot to add it, it's available since 2017
> https://www.mail-archive.com/qemu-devel@nongnu.org/msg436979.html

Nit: it's better to link to the commit rather than the mailing list for
things that are already applied.

Missing your Signed-off-by.

Hmm, I wanted to suggest to query the image to see what kind of
preallocation it was created with and then use that setting to stay
consistent. But that information doesn't seem to get recorded (on an
image-wide level) AFAICS. It might be surprising that changes to the
storage configuration setting will also apply to already existing images
and we should document the behavior for resize in the description of the
'preallocation' setting.

Seems like the "block_resize" QMP command does not have the setting at
all, so if we add it here, the behavior would still be inconsistent in
that regard :/ But oh well, could still be added on top later if we can
get that feature in upstream. But should also be documented, that it
doesn't apply for live resize.

> ---
>  src/PVE/Storage/Plugin.pm | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/src/PVE/Storage/Plugin.pm b/src/PVE/Storage/Plugin.pm
> index 6a6a804..d0ce3ae 100644
> --- a/src/PVE/Storage/Plugin.pm
> +++ b/src/PVE/Storage/Plugin.pm
> @@ -1166,7 +1166,9 @@ sub volume_resize {
>  
>      my $format = ($class->parse_volname($volname))[6];
>  
> -    my $cmd = ['/usr/bin/qemu-img', 'resize', '-f', $format, $path , $size];
> +    my $prealloc_opt = preallocation_cmd_option($scfg, $format);
> +
> +    my $cmd = ['/usr/bin/qemu-img', 'resize', "--$prealloc_opt", '-f', $format, $path , $size];
>  
>      run_command($cmd, timeout => 10);
>  
> -- 
> 2.39.5
> 
> 





More information about the pve-devel mailing list