Skip to content

Commit 7788bf2

Browse files
committed
BIOS: extend support for update & adopt_update on all devices
For dual boot, need to extend support for both. Also add kola test to verify that supports updating multiple EFIs.
1 parent 5550da5 commit 7788bf2

File tree

4 files changed

+57
-23
lines changed

4 files changed

+57
-23
lines changed

src/bios.rs

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -167,18 +167,11 @@ impl Component for Bios {
167167
return Ok(None);
168168
};
169169

170-
let mut parent_devices = rootcxt.devices.iter();
171-
let Some(parent) = parent_devices.next() else {
172-
anyhow::bail!("Failed to find parent device");
173-
};
174-
175-
if let Some(next) = parent_devices.next() {
176-
anyhow::bail!(
177-
"Found multiple parent devices {parent} and {next}; not currently supported"
178-
);
170+
for parent in rootcxt.devices.iter() {
171+
self.run_grub_install(rootcxt.path.as_str(), &parent)?;
172+
log::debug!("Install grub modules on {parent}");
179173
}
180-
self.run_grub_install(rootcxt.path.as_str(), &parent)?;
181-
log::debug!("Installed grub modules on {parent}");
174+
182175
Ok(Some(InstalledContent {
183176
meta: update.clone(),
184177
filetree: None,
@@ -195,20 +188,11 @@ impl Component for Bios {
195188
.query_update(&rootcxt.sysroot)?
196189
.expect("update available");
197190

198-
let mut parent_devices = rootcxt.devices.iter();
199-
let Some(parent) = parent_devices.next() else {
200-
anyhow::bail!("Failed to find parent device");
201-
};
202-
203-
if let Some(next) = parent_devices.next() {
204-
anyhow::bail!(
205-
"Found multiple parent devices {parent} and {next}; not currently supported"
206-
);
191+
for parent in rootcxt.devices.iter() {
192+
self.run_grub_install(rootcxt.path.as_str(), &parent)?;
193+
log::debug!("Install grub modules on {parent}");
207194
}
208195

209-
self.run_grub_install(rootcxt.path.as_str(), &parent)?;
210-
log::debug!("Install grub modules on {parent}");
211-
212196
let adopted_from = None;
213197
Ok(InstalledContent {
214198
meta: updatemeta,

tests/kola/raid1/config.bu

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
variant: fcos
2+
version: 1.5.0
3+
boot_device:
4+
mirror:
5+
devices:
6+
- /dev/vda
7+
- /dev/vdb

tests/kola/raid1/data/libtest.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../data/libtest.sh

tests/kola/raid1/test.sh

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/bash
2+
## kola:
3+
## # additionalDisks is only supported on qemu.
4+
## platforms: qemu
5+
## # Root reprovisioning requires at least 4GiB of memory.
6+
## minMemory: 4096
7+
## # Linear RAID is setup on these disks.
8+
## additionalDisks: ["10G"]
9+
## # This test includes a lot of disk I/O and needs a higher
10+
## # timeout value than the default.
11+
## timeoutMin: 15
12+
## description: Verify updating multiple EFIs using RAID 1 works.
13+
14+
set -xeuo pipefail
15+
16+
# shellcheck disable=SC1091
17+
. "$KOLA_EXT_DATA/libtest.sh"
18+
19+
tmpdir=$(mktemp -d)
20+
cd ${tmpdir}
21+
22+
srcdev=$(findmnt -nvr /sysroot -o SOURCE)
23+
[[ ${srcdev} == "/dev/md126" ]]
24+
25+
blktype=$(lsblk -o TYPE "${srcdev}" --noheadings)
26+
[[ ${blktype} == "raid1" ]]
27+
28+
fstype=$(findmnt -nvr /sysroot -o FSTYPE)
29+
[[ ${fstype} == "xfs" ]]
30+
ok "source is XFS on RAID1 device"
31+
32+
mount -o remount,rw /boot
33+
rm -f -v /boot/bootupd-state.json
34+
35+
bootupctl adopt-and-update | tee out.txt
36+
assert_file_has_content out.txt "Adopted and updated: BIOS: .*"
37+
assert_file_has_content out.txt "Adopted and updated: EFI: .*"
38+
39+
bootupctl status | tee out.txt
40+
assert_file_has_content_literal out.txt 'Component BIOS'
41+
assert_file_has_content_literal out.txt 'Component EFI'
42+
ok "bootupctl adopt-and-update supports multiple EFIs on RAID1"

0 commit comments

Comments
 (0)