[pve-devel] [PATCH container v2 08/11] api: create: use volume content type assertion helpers

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


Make use of newly introduced content type assertion helpers in the
preconditions check path in the API handler for creating a container.

Signed-off-by: Daniel Kral <d.kral at proxmox.com>
---
changes since v1:
- new!

 src/PVE/API2/LXC.pm | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/src/PVE/API2/LXC.pm b/src/PVE/API2/LXC.pm
index 7cb5122..8e5e6a6 100644
--- a/src/PVE/API2/LXC.pm
+++ b/src/PVE/API2/LXC.pm
@@ -306,10 +306,9 @@ __PACKAGE__->register_method({
 	my $check_and_activate_storage = sub {
 	    my ($sid) = @_;
 
-	    my $scfg = PVE::Storage::storage_check_enabled($storage_cfg, $sid, $node);
-
-	    raise_param_exc({ storage => "storage '$sid' does not support container directories"})
-		if !$scfg->{content}->{rootdir};
+	    PVE::Storage::storage_check_enabled($storage_cfg, $sid, $node);
+	    eval { PVE::Storage::assert_content_type_supported($storage_cfg, $sid, 'rootdir', $node) };
+	    raise_param_exc({ storage => "$@" }) if $@;
 
 	    $rpcenv->check($authuser, "/storage/$sid", ['Datastore.AllocateSpace']);
 
-- 
2.39.5





More information about the pve-devel mailing list