From 33a178f76825da8f2656deedd1c73b1367091866 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= Date: Mon, 2 Sep 2024 02:31:47 -0400 Subject: [PATCH] incusd/storage/zfs: Only attempt to load the module if the tools exist MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Graber --- internal/server/storage/drivers/driver_zfs.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/internal/server/storage/drivers/driver_zfs.go b/internal/server/storage/drivers/driver_zfs.go index a600f2a2021..df5b7c5d902 100644 --- a/internal/server/storage/drivers/driver_zfs.go +++ b/internal/server/storage/drivers/driver_zfs.go @@ -71,12 +71,6 @@ func (d *zfs) load() error { return nil } - // Load the kernel module. - err := linux.LoadModule("zfs") - if err != nil { - return fmt.Errorf("Error loading %q module: %w", "zfs", err) - } - // Validate the needed tools are present. for _, tool := range []string{"zpool", "zfs"} { _, err := exec.LookPath(tool) @@ -85,6 +79,12 @@ func (d *zfs) load() error { } } + // Load the kernel module. + err := linux.LoadModule("zfs") + if err != nil { + return fmt.Errorf("Error loading %q module: %w", "zfs", err) + } + // Get the version information. if zfsVersion == "" { version, err := d.version()