The following pull request was submitted through Github.
It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/4835

This e-mail was sent by the LXC bot, direct replies will not reach the author
unless they happen to be subscribed to this list.

=== Description (from pull-request) ===
Signed-off-by: Stéphane Graber <stgra...@ubuntu.com>
From 945e29b0a58d3933e4c42a170fe45aeb03136037 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgra...@ubuntu.com>
Date: Wed, 25 Jul 2018 19:30:18 -0400
Subject: [PATCH] zfs: Support querying version through modinfo
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Stéphane Graber <stgra...@ubuntu.com>
---
 lxd/storage_zfs.go       |  2 +-
 lxd/storage_zfs_utils.go | 21 +++++++++++++++++----
 2 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/lxd/storage_zfs.go b/lxd/storage_zfs.go
index 4434255c3..0d0edbd46 100644
--- a/lxd/storage_zfs.go
+++ b/lxd/storage_zfs.go
@@ -52,7 +52,7 @@ func (s *storageZfs) StorageCoreInit() error {
        util.LoadModule("zfs")
 
        if !zfsIsEnabled() {
-               return fmt.Errorf("the \"zfs\" tool is not enabled")
+               return fmt.Errorf("The \"zfs\" tool is not enabled")
        }
 
        s.sTypeVersion, err = zfsModuleVersionGet()
diff --git a/lxd/storage_zfs_utils.go b/lxd/storage_zfs_utils.go
index 20ee1aa00..48995cdf8 100644
--- a/lxd/storage_zfs_utils.go
+++ b/lxd/storage_zfs_utils.go
@@ -28,12 +28,25 @@ func zfsIsEnabled() bool {
 
 // zfsModuleVersionGet returhs the ZFS module version
 func zfsModuleVersionGet() (string, error) {
-       zfsVersion, err := ioutil.ReadFile("/sys/module/zfs/version")
-       if err != nil {
-               return "", fmt.Errorf("could not determine ZFS module version")
+       var zfsVersion string
+
+       if shared.PathExists("/sys/module/zfs/version") {
+               out, err := ioutil.ReadFile("/sys/module/zfs/version")
+               if err != nil {
+                       return "", fmt.Errorf("Could not determine ZFS module 
version")
+               }
+
+               zfsVersion = string(out)
+       } else {
+               out, err := shared.RunCommand("modinfo", "-F", "version", "zfs")
+               if err != nil {
+                       return "", fmt.Errorf("Could not determine ZFS module 
version")
+               }
+
+               zfsVersion = out
        }
 
-       return strings.TrimSpace(string(zfsVersion)), nil
+       return strings.TrimSpace(zfsVersion), nil
 }
 
 // zfsPoolVolumeCreate creates a ZFS dataset with a set of given properties.
_______________________________________________
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to