[lxc-devel] [lxd/master] lxd/resources/storage: Improve cdrom handling

stgraber on Github lxc-bot at linuxcontainers.org
Fri Nov 1 01:45:46 UTC 2019


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 370 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20191031/9859a832/attachment.bin>
-------------- next part --------------
From bbcd863dd6d09310dd861fc597af1dbd9cdfff4b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Fri, 1 Nov 2019 02:44:20 +0100
Subject: [PATCH] lxd/resources/storage: Improve cdrom handling
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Closes #6378

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

diff --git a/lxd/resources/storage.go b/lxd/resources/storage.go
index 2e66e7274c..ee0a00162c 100644
--- a/lxd/resources/storage.go
+++ b/lxd/resources/storage.go
@@ -203,6 +203,16 @@ func GetStorage() (*api.ResourcesStorage, error) {
 				disk.WWN = strings.TrimSpace(string(diskWWN))
 			}
 
+			// Try to guess if dealing with CD-ROM
+			if strings.HasPrefix(disk.ID, "sr") && disk.Removable {
+				disk.Type = "cdrom"
+
+				// Most cdrom drives report this as size regardless of media
+				if disk.Size == 0x1fffff*512 {
+					disk.Size = 0
+				}
+			}
+
 			// Look for partitions
 			disk.Partitions = []api.ResourcesStorageDiskPartition{}
 			for _, subEntry := range entries {


More information about the lxc-devel mailing list