[pve-devel] [PATCH container v3 03/11] alloc disk: fix content type check for ZFS storages
Daniel Kral
d.kral at proxmox.com
Tue Apr 15 15:50:37 CEST 2025
There were existing assertions whether the underlying storage supports
the content type 'rootdir' for the case where volumes are created on ZFS
storages in the create_vm API handler and update_pct_config().
This assertion was missing from the case where volumes are copied with
copy_volume(), so always assert the support of rootdirs in storages when
allocating a volume with alloc_disk().
Signed-off-by: Daniel Kral <d.kral at proxmox.com>
---
changes since v2:
* change commit summary and message the change for zfs pools
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 a58c997..8581da6 100644
--- a/src/PVE/LXC.pm
+++ b/src/PVE/LXC.pm
@@ -2171,7 +2171,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;
@@ -2182,11 +2186,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