Skip to content

Commit

Permalink
Merge pull request #1070 from jlebon/pr/s390x-ignition
Browse files Browse the repository at this point in the history
  • Loading branch information
jlebon authored Mar 9, 2023
2 parents f7a7bca + 8fd5ee0 commit 90b6775
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 3 deletions.
1 change: 1 addition & 0 deletions docs/release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ nav_order: 8
Major changes:

- Add Fedora 39 signing key; drop Fedora 36 signing key
- iso: Support Ignition embedding on s390x by using `igninfo.json` if present

Minor changes:

Expand Down
16 changes: 16 additions & 0 deletions fixtures/iso/INDEX
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,19 @@ embed-areas-2022-09.iso.xz
features.json: installer-config, installer-config-directives,
live-initrd-network
installer-config-directives from 0.16.0

embed-areas-2023-03.x86_64.iso.xz
igninfo.json pointing to ignition.img (no offset and no length)
kargs.json pointing to kargs areas and embedding defaults
miniso.dat version 1
features.json: installer-config, installer-config-directives,
live-initrd-network
installer-config-directives from 0.16.0

embed-areas-2023-03.s390x.iso.xz
igninfo.json pointing to cdboot.img (offset and length)
no kargs.json
miniso.dat version 1
features.json: installer-config, installer-config-directives,
live-initrd-network
installer-config-directives from 0.16.0
Binary file added fixtures/iso/embed-areas-2023-03.s390x.iso.xz
Binary file not shown.
Binary file added fixtures/iso/embed-areas-2023-03.x86_64.iso.xz
Binary file not shown.
34 changes: 31 additions & 3 deletions src/live/embed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ lazy_static! {
GlobMatcher::new(&[&format!("{INITRD_NETWORK_DIR}/*")]).unwrap();
}

const COREOS_INITRD_EMBED_PATH: &str = "IMAGES/IGNITION.IMG";
const COREOS_IGNINFO_PATH: &str = "COREOS/IGNINFO.JSO";
const COREOS_INITRD_DEFAULT_EMBED_PATH: &str = "IMAGES/IGNITION.IMG";
const COREOS_INITRD_HEADER_SIZE: u64 = 24;
const COREOS_KARG_EMBED_AREA_HEADER_MAGIC: &[u8] = b"coreKarg";
const COREOS_KARG_EMBED_AREA_HEADER_SIZE: u64 = 72;
Expand Down Expand Up @@ -503,14 +504,41 @@ struct InitrdEmbedArea {
initrd: Initrd,
}

#[derive(Deserialize)]
struct IgnInfo {
file: String,
offset: Option<u64>,
length: Option<usize>,
}

impl InitrdEmbedArea {
pub fn for_iso(iso: &mut IsoFs) -> Result<Self> {
let igninfo: IgnInfo = match iso.get_path(COREOS_IGNINFO_PATH) {
Ok(record) => {
let f = record.try_into_file()?;
serde_json::from_reader(iso.read_file(&f).context("reading igninfo")?)
.context("decoding igninfo")?
}
// old ISO without info JSON; assume ignition.img
Err(e) if e.is::<iso9660::NotFound>() => IgnInfo {
file: COREOS_INITRD_DEFAULT_EMBED_PATH.to_string(),
offset: None,
length: None,
},
Err(e) => return Err(e),
};

let f = iso
.get_path(COREOS_INITRD_EMBED_PATH)
.get_path(&igninfo.file.to_uppercase())
.context("finding initrd embed area")?
.try_into_file()?;
let file_offset = igninfo.offset.unwrap_or(0);
let iso_offset = f.address.as_offset() + file_offset;
let length = igninfo
.length
.unwrap_or(f.length as usize - file_offset as usize);
// read (checks offset/length as a side effect)
let mut region = Region::read(iso.as_file()?, f.address.as_offset(), f.length as usize)
let mut region = Region::read(iso.as_file()?, iso_offset, length)
.context("reading initrd embed area")?;
let initrd = if region.contents.iter().any(|v| *v != 0) {
Initrd::from_reader(&*region.contents).context("decoding initrd embed area")?
Expand Down
2 changes: 2 additions & 0 deletions tests/images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ fixtures=(
embed-areas-2021-12.iso.xz
embed-areas-2022-02.iso.xz
embed-areas-2022-09.iso.xz
embed-areas-2023-03.x86_64.iso.xz
embed-areas-2023-03.s390x.iso.xz
)

msg() {
Expand Down
5 changes: 5 additions & 0 deletions tests/images/iso-extract-minimal-iso.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ grepq() {
iso=$1; shift
iso=$(realpath "${iso}")

if [[ "${iso}" == *.s390x.* ]]; then
echo "Skipped; minimal ISO not supported on s390x"
exit 0
fi

tmpd=$(mktemp -d)
trap 'rm -rf "${tmpd}"' EXIT
cd "${tmpd}"
Expand Down
5 changes: 5 additions & 0 deletions tests/images/iso-kargs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ grepq() {
iso=$1; shift
iso=$(realpath "${iso}")

if [[ "${iso}" == *.s390x.* ]]; then
echo "Skipped; kargs not supported on s390x"
exit 0
fi

tmpd=$(mktemp -d)
trap 'rm -rf "${tmpd}"' EXIT
cd "${tmpd}"
Expand Down

0 comments on commit 90b6775

Please sign in to comment.