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

Daniel Kral d.kral at proxmox.com
Tue Feb 11 17:08:17 CET 2025


Signed-off-by: Daniel Kral <d.kral 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 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;
     };
-- 
2.39.5





More information about the pve-devel mailing list