Skip to content

Commit 13b74e6

Browse files
author
gitlab
committed
Merge branch 'ZSV-10987@@2' into 'zsv_4.10.28'
<fix>[host]: filter out disks of type loop and rom See merge request zstackio/zstack!9023
2 parents 7c60747 + 5ce64bd commit 13b74e6

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

header/src/main/java/org/zstack/header/host/BlockDevicesParser.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,8 @@ public void setModel(String model) {
136136
" ]\n" +
137137
"}\n" +
138138
"===\r\n" +
139-
"/dev/sr0:unknown\r\n\r\n" +
140139
"/dev/vda:\r\n" +
141-
"/dev/vdb:loop\r\n\r\n" +
140+
"/dev/vdb:msdos\r\n" +
142141
"/dev/vdc:unknown\r\n";
143142

144143
public static List<BlockDevice> parse(String blockDevices) {
@@ -157,7 +156,7 @@ public static List<BlockDevice> parse(String blockDevices) {
157156
}
158157
blockDevicePartitionTable.put(blockDeviceAndPartitionTable.get(0), blockDeviceAndPartitionTable.get(1));
159158
});
160-
allBlockDevices.forEach(blockDevice -> blockDevice.setPartitionTable(blockDevicePartitionTable.get(blockDevice.getName())));
159+
allBlockDevices.forEach(blockDevice -> blockDevice.setPartitionTable(blockDevicePartitionTable.getOrDefault(blockDevice.getName(), null)));
161160

162161
return allBlockDevices;
163162
}
@@ -173,7 +172,7 @@ public static List<BlockDevice> parse(List<String> blockDevices) {
173172

174173
public static String getBlockDevicesCommand() {
175174
String blockDevicesCommand = "lsblk -p -b -o NAME,TYPE,SIZE,PHY-SEC,LOG-SEC,MOUNTPOINT -J";
176-
String partitionTableInfoCommand = "for disk in $(lsblk -d -p -n -o NAME); do echo -n \"$disk:\"; " +
175+
String partitionTableInfoCommand = "for disk in $(lsblk -d -p -n -o NAME,TYPE | awk '$2!~/loop|rom/ {print $1}'); do echo -n \"$disk:\"; " +
177176
"parted -s $disk print 2>/dev/null | awk '/Partition Table/ {print $3} END{print \"\"}'; done";
178177
return String.format("%s ; echo === ; %s", blockDevicesCommand, partitionTableInfoCommand);
179178
}

0 commit comments

Comments
 (0)