[pve-devel] [PATCH container v2 03/11] alloc_disk: fail fast if storage does not support content type rootdir

Fiona Ebner f.ebner at proxmox.com
Thu Feb 20 13:15:57 CET 2025


I'd change the title to "alloc disk: fix content type check for ZFS
storages" because the check was missing for that branch ;)

The commit message should mention that there are already earlier checks
for the create operations. Moving a volume to a ZFS storage without
'rootdir' content type was still possible however, which this change
prohibits.

Am 11.02.25 um 17:08 schrieb Daniel Kral:
> Signed-off-by: Daniel Kral <d.kral at proxmox.com>

With the above:

Reviewed-by: Fiona Ebner <f.ebner at proxmox.com>

I also noticed that we have no check against starting a container with
volumes on a storage that does not support 'rootdir'. We have such a
check for VMs IIRC. Prohibiting that would also be good, but maybe
something for PVE 9 where we can also check for misconfigured
containers/storages via the pve8to9 script up front so users can adapt.

> ---
> 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 44e28fc..51457ec 100644
> --- a/src/PVE/LXC.pm
> +++ b/src/PVE/LXC.pm
> @@ -2158,7 +2158,11 @@ sub alloc_disk {
>  
>      eval {
>  	my $do_format = 0;
> -	if ($scfg->{content}->{rootdir} && $scfg->{path}) {
> +
> +	die "storage '$storage' does not support content type 'rootdir'\n"
> +	    if !$scfg->{content}->{rootdir};
> +
> +	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;
> @@ -2169,11 +2173,9 @@ sub alloc_disk {
>  	} elsif ($scfg->{type} eq 'zfspool') {
>  	    $volid = PVE::Storage::vdisk_alloc($storecfg, $storage, $vmid, 'subvol', undef, $size_kb);
>  	    $needs_chown = 1;
> -	} elsif ($scfg->{content}->{rootdir}) {
> +	} else {
>  	    $volid = PVE::Storage::vdisk_alloc($storecfg, $storage, $vmid, 'raw', undef, $size_kb);
>  	    $do_format = 1;
> -	} else {
> -	    die "content type 'rootdir' is not available or configured on storage '$storage'\n";
>  	}
>  	format_disk($storecfg, $volid, $root_uid, $root_gid) if $do_format;
>      };





More information about the pve-devel mailing list