[pve-devel] [PATCH storage] (finally) fix #1099: return disklist correctly

Dominik Csapak d.csapak at proxmox.com
Wed Nov 8 09:01:58 CET 2017


in get_disks, when called with a parameter 'cciss/cXdY', we replaced
the '/' with '!' so that we can properly poll the information
about it from /sys/block/

but we have to replace the '!' with '/' again in our result list,
because the caller does not know anything about it and fails, because
the original dev is not in the list

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
we have to correct the regression test in this case,
but this is the correct way, because now a potential caller
does not have to care about ! or /

also we never explicitely use the key of the hash in any way
were this would matter
 PVE/Diskmanage.pm                            | 8 ++++++++
 test/disk_tests/cciss/disklist_expected.json | 2 +-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/PVE/Diskmanage.pm b/PVE/Diskmanage.pm
index e1db2ae..23e5b13 100644
--- a/PVE/Diskmanage.pm
+++ b/PVE/Diskmanage.pm
@@ -456,6 +456,14 @@ sub get_disks {
 
 	$used = 'ZFS' if $zfslist->{$devpath};
 
+	# we replaced cciss/ with cciss! above
+	# but in the result we need cciss/ again
+	# because the caller might want to check the
+	# result again with the original parameter
+	if ($dev =~ m|^cciss!|) {
+	    $dev =~ s|^cciss!|cciss/|;
+	}
+
 	$disklist->{$dev} = {
 	    vendor => $sysdata->{vendor},
 	    model => $data->{model} || $sysdata->{model},
diff --git a/test/disk_tests/cciss/disklist_expected.json b/test/disk_tests/cciss/disklist_expected.json
index 61f60bf..eff58db 100644
--- a/test/disk_tests/cciss/disklist_expected.json
+++ b/test/disk_tests/cciss/disklist_expected.json
@@ -1,5 +1,5 @@
 {
-    "cciss!c0d0" : {
+    "cciss/c0d0" : {
 	"wearout" : "N/A",
 	"vendor" : "HP",
 	"rpm" : -1,
-- 
2.11.0





More information about the pve-devel mailing list