[lxc-devel] [lxd/master] Attempt to use get storage model from ID_MODEL_ENC before trying ID_MODEL(#7665)
ltrager on Github
lxc-bot at linuxcontainers.org
Thu Jul 16 22:34:43 UTC 2020
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 355 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20200716/10ef7e2a/attachment.bin>
-------------- next part --------------
From 4f6e2b966e1bd14647a9c7d02473fd50171666c2 Mon Sep 17 00:00:00 2001
From: Lee Trager <lee.trager at canonical.com>
Date: Thu, 16 Jul 2020 22:33:09 +0000
Subject: [PATCH] Attempt to use get storage model from ID_MODEL_ENC before
trying ID_MODEL(#7665)
Signed-off-by: Lee Trager <lee.trager at canonical.com>
---
lxd/resources/storage.go | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/lxd/resources/storage.go b/lxd/resources/storage.go
index 85ccfc9db6..3e11e2ebdc 100644
--- a/lxd/resources/storage.go
+++ b/lxd/resources/storage.go
@@ -84,8 +84,17 @@ func storageAddDriveInfo(devicePath string, disk *api.ResourcesStorageDisk) erro
disk.Serial = udevProperties["E:ID_SERIAL_SHORT"]
}
- // Model number
- if udevProperties["E:ID_MODEL"] != "" {
+ // Model number. Check the encoded model first to match what lsblk does.
+ if udevProperties["E:ID_MODEL_ENC"] != "" {
+ // The encoded model may contain escaped hex values which need to
+ // be converted to ASCII
+ model, err := strconv.Unquote(`"` + udevProperties["E:ID_MODEL_ENC"] + `"`)
+ if err == nil {
+ disk.Model = strings.TrimSpace(model)
+ } else if udevProperties["E:ID_MODEL"] != "" {
+ disk.Model = udevProperties["E:ID_MODEL"]
+ }
+ } else if udevProperties["E:ID_MODEL"] != "" {
disk.Model = udevProperties["E:ID_MODEL"]
}
More information about the lxc-devel
mailing list