[lxc-devel] [lxd/master] lxd/resources: Use udev model data if available

stgraber on Github lxc-bot at linuxcontainers.org
Thu Jul 9 20:15:36 UTC 2020


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 354 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20200709/6b1a1052/attachment.bin>
-------------- next part --------------
From f1b9c49b14923d1e04b79dd86cdc6566755abe80 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Thu, 9 Jul 2020 16:13:37 -0400
Subject: [PATCH] lxd/resources: Use udev model data if available
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 lxd/resources/storage.go | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/lxd/resources/storage.go b/lxd/resources/storage.go
index d693441528..85ccfc9db6 100644
--- a/lxd/resources/storage.go
+++ b/lxd/resources/storage.go
@@ -74,16 +74,21 @@ func storageAddDriveInfo(devicePath string, disk *api.ResourcesStorageDisk) erro
 			disk.Type = "sata"
 		}
 
-		// Firmware version
+		// Firmware version (if not found in sysfs)
 		if udevProperties["E:ID_REVISION"] != "" && disk.FirmwareVersion == "" {
 			disk.FirmwareVersion = udevProperties["E:ID_REVISION"]
 		}
 
 		// Serial number
-		if udevProperties["E:ID_SERIAL_SHORT"] != "" && disk.Serial == "" {
+		if udevProperties["E:ID_SERIAL_SHORT"] != "" {
 			disk.Serial = udevProperties["E:ID_SERIAL_SHORT"]
 		}
 
+		// Model number
+		if udevProperties["E:ID_MODEL"] != "" {
+			disk.Model = udevProperties["E:ID_MODEL"]
+		}
+
 		// Rotation per minute
 		if udevProperties["E:ID_ATA_ROTATION_RATE_RPM"] != "" && disk.RPM == 0 {
 			valueUint, err := strconv.ParseUint(udevProperties["E:ID_ATA_ROTATION_RATE_RPM"], 10, 64)


More information about the lxc-devel mailing list