[pve-devel] [PATCH container v2 04/11] alloc_disk: factor out common arguments for call to vdisk_alloc
Fiona Ebner
f.ebner at proxmox.com
Thu Feb 20 14:11:33 CET 2025
Am 11.02.25 um 17:08 schrieb Daniel Kral:
> Signed-off-by: Daniel Kral <d.kral at proxmox.com>
Reviewed-by: Fiona Ebner <f.ebner at proxmox.com>
> ---
> changes since v1:
> - new!
>
> src/PVE/LXC.pm | 10 ++++++----
> 1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/src/PVE/LXC.pm b/src/PVE/LXC.pm
> index 51457ec..1152131 100644
> --- a/src/PVE/LXC.pm
> +++ b/src/PVE/LXC.pm
> @@ -2157,6 +2157,7 @@ sub alloc_disk {
> # fixme: use better naming ct-$vmid-disk-X.raw?
>
> eval {
> + my $format = 'raw';
> my $do_format = 0;
>
> die "storage '$storage' does not support content type 'rootdir'\n"
> @@ -2164,19 +2165,20 @@ sub alloc_disk {
>
> if ($scfg->{path}) {
> if ($size_kb > 0 && !($scfg->{type} eq 'btrfs' && $scfg->{quotas})) {
> - $volid = PVE::Storage::vdisk_alloc($storecfg, $storage, $vmid, 'raw', undef, $size_kb);
> $do_format = 1;
> } else {
> - $volid = PVE::Storage::vdisk_alloc($storecfg, $storage, $vmid, 'subvol', undef, $size_kb);
> + $format = 'subvol';
> $needs_chown = 1;
> }
> } elsif ($scfg->{type} eq 'zfspool') {
> - $volid = PVE::Storage::vdisk_alloc($storecfg, $storage, $vmid, 'subvol', undef, $size_kb);
> + $format = 'subvol';
> $needs_chown = 1;
> } else {
> - $volid = PVE::Storage::vdisk_alloc($storecfg, $storage, $vmid, 'raw', undef, $size_kb);
> $do_format = 1;
> }
> +
> + $volid = PVE::Storage::vdisk_alloc($storecfg, $storage, $vmid, $format, undef, $size_kb);
> +
> format_disk($storecfg, $volid, $root_uid, $root_gid) if $do_format;
> };
> if (my $err = $@) {
More information about the pve-devel
mailing list