[pve-devel] [PATCH container v3 11/11] mount: raw/iso: use volume content type assertion helpers

Daniel Kral d.kral at proxmox.com
Tue Apr 15 15:50:45 CEST 2025


Make use of the newly introduced content type assertion helpers at
verifying the content type when mounting mountpoints, which have the
format "raw" or "iso".

Signed-off-by: Daniel Kral <d.kral at proxmox.com>
---
changes since v2:
  * rename helper from *_supported to *_available

I already pointed that out in a response to a v2 patch, but this already
existing check in __mountpoint_mount will make it impossible AFAICS for
users to move out of the error state of a root disk / mountpoint being
on a storage that doesn't support the content type 'rootdir'. But this
would be a follow-up if we want to change it.

Also there is no check for subvols made here, i.e. container root disks
/ mountpoints on a ZFS pool can be started fine, while ones on e.g.
directory storages cannot (because they are 'raw').

And on another note: The error message from this is rather cryptic for
an end user and is only a little bit clarified in the output of `pct
start ... --debug`, but else the user must guess:

run_buffer: 571 Script exited with status 25
lxc_init: 845 Failed to run lxc.hook.pre-start for container "101"
__lxc_start: 2034 Failed to initialize container "101"
TASK ERROR: startup for container '101' failed

I skipped adding a patch for this now, as it's out of scope of this
already long patch series.

 src/PVE/LXC.pm | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/src/PVE/LXC.pm b/src/PVE/LXC.pm
index 799aa9a..0beb49c 100644
--- a/src/PVE/LXC.pm
+++ b/src/PVE/LXC.pm
@@ -1978,17 +1978,17 @@ sub __mountpoint_mount {
 		}
 	    };
 	    my $use_loopdev = 0;
-	    if ($scfg->{content}->{rootdir}) {
-		if ($scfg->{path}) {
-		    $mounted_dev = run_with_loopdev($domount, $path, $readonly);
-		    $use_loopdev = 1;
-		} else {
-		    $mounted_dev = $path;
-		    &$domount($path);
-		}
+
+	    PVE::Storage::assert_content_type_available($storage_cfg, $storage, 'rootdir');
+
+	    if ($scfg->{path}) {
+		$mounted_dev = run_with_loopdev($domount, $path, $readonly);
+		$use_loopdev = 1;
 	    } else {
-		die "storage '$storage' does not support containers\n";
+		$mounted_dev = $path;
+		&$domount($path);
 	    }
+
 	    return wantarray ? ($path, $use_loopdev, $mounted_dev) : $path;
 	} else {
 	    die "unsupported image format '$format'\n";
-- 
2.39.5





More information about the pve-devel mailing list