[pve-devel] [PATCH v2 container 3/3] pct: fsck: add missing call to activate volume

Fiona Ebner f.ebner at proxmox.com
Fri Apr 12 13:08:14 CEST 2024


Otherwise, running pct fsck for e.g. an LVM volume after shutting down
a container would fail.

The container is not running, so the volume should be deactivated
afterwards.

Suggested-by: Fabian Grünbichler <f.gruenbichler at proxmox.com>
Signed-off-by: Fiona Ebner <f.ebner at proxmox.com>
---

New in v2.

 src/PVE/CLI/pct.pm | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/PVE/CLI/pct.pm b/src/PVE/CLI/pct.pm
index 13aa4c1..c48321d 100755
--- a/src/PVE/CLI/pct.pm
+++ b/src/PVE/CLI/pct.pm
@@ -287,6 +287,7 @@ __PACKAGE__->register_method ({
 		die "unable to run fsck for '$volid' (format == $format)\n"
 		    if $format ne 'raw';
 
+		PVE::Storage::activate_volumes($storage_cfg, [$volid]);
 		$path = PVE::Storage::map_volume($storage_cfg, $volid);
 
 	    } else {
@@ -302,8 +303,12 @@ __PACKAGE__->register_method ({
 	    eval { PVE::Tools::run_command($command); };
 	    my $err = $@;
 
-	    eval { PVE::Storage::unmap_volume($storage_cfg, $volid) if $storage_id; };
-	    warn $@ if $@;
+	    if ($storage_id) {
+		eval { PVE::Storage::unmap_volume($storage_cfg, $volid); };
+		warn $@ if $@;
+		eval { PVE::Storage::deactivate_volumes($storage_cfg, [$volid]); };
+		warn $@ if $@;
+	    }
 
 	    die $err if $err;
 	};
-- 
2.39.2





More information about the pve-devel mailing list