Skip to content

Commit

Permalink
fix choosing priority device causing bootloader crash (bnc#890204)
Browse files Browse the repository at this point in the history
  • Loading branch information
jreidinger committed Aug 4, 2014
1 parent fefcbba commit 0ea488a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
9 changes: 4 additions & 5 deletions src/modules/BootStorage.rb
Expand Up @@ -802,14 +802,13 @@ def changeOrderInDeviceMapping(device_mapping, bad_devices: [], priority_device:
device_mapping = device_mapping.dup
first_available_id = 0
keys = device_mapping.keys
result = {}

if priority_device
result[priority_device] = "hd0"
first_available_id = 1
old_first_device = device_mapping.key("hd0")
old_device_id = device_mapping[priority_device]
device_mapping[old_first_device] = old_device_id
device_mapping[priority_device] = "hd0"
end

# put bad_devices at bottom
Expand All @@ -827,14 +826,14 @@ def changeOrderInDeviceMapping(device_mapping, bad_devices: [], priority_device:
tmp = device_mapping.key("hd#{first_available_id}")

# swap tmp and key devices (swap their mapping)
result[tmp] = value
result[key] = "hd#{first_available_id}"
device_mapping[tmp] = value
device_mapping[key] = "hd#{first_available_id}"

first_available_id += 1
end
end

result
device_mapping
end

# Check if MD raid is build on disks not on paritions
Expand Down
6 changes: 3 additions & 3 deletions test/boot_storage_test.rb
Expand Up @@ -5,12 +5,12 @@
describe Yast::BootStorage do
describe ".changeOrderInDeviceMapping" do
it "place priority device on top of device mapping" do
device_map = { "/dev/sda" => "hd0", "/dev/sdb" => "hd1" }
result = { "/dev/sda" => "hd1", "/dev/sdb" => "hd0" }
device_map = { "/dev/sda" => "hd1", "/dev/sdb" => "hd0" }
result = { "/dev/sda" => "hd0", "/dev/sdb" => "hd1" }
expect(
Yast::BootStorage.changeOrderInDeviceMapping(
device_map,
priority_device: "/dev/sdb"
priority_device: "/dev/sda"
)
).to eq(result)
end
Expand Down

0 comments on commit 0ea488a

Please sign in to comment.