Skip to content

ephemeral: Add Ignition config injection support#232

Open
gursewak1997 wants to merge 1 commit intomainfrom
add-ignition-support
Open

ephemeral: Add Ignition config injection support#232
gursewak1997 wants to merge 1 commit intomainfrom
add-ignition-support

Conversation

@gursewak1997
Copy link
Collaborator

@gursewak1997 gursewak1997 commented Mar 20, 2026

Add support for injecting Ignition configuration files into ephemeral
VMs via QEMU's fw_cfg mechanism (x86_64/aarch64) and virtio-blk
(s390x/ppc64le). This enables first-boot provisioning for bootc-based
systems that use Ignition.

Implementation:

  • Architecture-specific config delivery per FCOS docs:
    • x86_64/aarch64: fw_cfg at opt/com.coreos/config
    • s390x/ppc64le: virtio-blk with serial 'ignition', readonly
  • Runtime architecture detection for correct method
  • Image validation via labels (coreos.ignition or com.coreos.osname)
  • Added readonly support for virtio-blk devices
  • Added ignition.platform.id=qemu kernel argument when config specified
  • Path validation with existence, type, and readability checks
  • Brief error messages with man page reference

Testing:

  • 5 comprehensive integration tests:
    • fw_cfg accessibility verification
    • Invalid path rejection
    • Directory rejection
    • Unsupported image detection
    • Kernel argument presence validation
  • All tests pass with FCOS image verification

Documentation:

  • Comprehensive man page section with working Ignition v3.3.0 example
  • SSH key injection and file creation demo
  • Architecture-specific delivery notes
  • Links to upstream Ignition and bootc documentation
  • Important notes about ephemeral boot behavior

The config is successfully passed to the guest (verified via
/sys/firmware/qemu_fw_cfg/ and /proc/cmdline). Ignition will process
it on first boot. For ephemeral testing with pre-built FCOS images,
Ignition skips as expected (subsequent boot behavior).

Useful for custom bootc images with Ignition (see bootc initramfs
docs) and future to-disk workflows.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds support for injecting Ignition configuration files into ephemeral VMs. The implementation correctly handles different injection methods for various architectures (fw_cfg for x86_64/aarch64 and virtio-blk for s390x/ppc64le). The changes include updates to QEMU configuration, command-line options, and logic to detect Ignition support in images.

My review includes a couple of suggestions to improve code clarity, reduce duplication, and enhance performance. Specifically, I've recommended refactoring the virtio-blk device addition methods for better maintainability and optimizing the Ignition support check to be more efficient.

@gursewak1997 gursewak1997 force-pushed the add-ignition-support branch 2 times, most recently from e74f5fd to 7be5f96 Compare March 20, 2026 23:05
Copy link
Collaborator

@cgwalters cgwalters left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this!

I think we really want an integration test for this. Did you test it with the fcos image? I have a suspicion that it may require an ignition.platform.id=qemu karg to be injected too.

And per discussion...some basic docs would be good, I think an example in the man page for ephemeral run is probably enough with a small concrete example?

Also, while starting with ephemeral is fine...we probably want libvirt support too.

(And yeah right now it definitely stinks to have direct qemu for ephemeral vs libvirt)

Comment on lines +946 to +947
if let Some(osname_value) = labels.get("com.coreos.osname") {
if !osname_value.is_empty() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If let Some(val) = labels.get().filter(|v| !v.is_empty())

));
}

cmd.args([
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What might be less cumbersome here is to pass it as an environment variable? Then we don't need to juggle paths across the mount, we just read it in here, and the code inside can just check for the env var.

if !has_ignition {
return Err(eyre!(
"Image does not support Ignition.\n\
\n\
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd lean towards us having a brief doc for this support instead of trying to have longer explanatory error messages like this.

match arch {
"x86_64" | "aarch64" => {
debug!("Adding Ignition config via fw_cfg: {}", ignition_path);
qemu_config.add_fw_cfg(IGNITION_FW_CFG_NAME.to_string(), ignition_path.to_owned());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although I guess if we accept it as an env-var externally, this case would require re-serializing to a file. Hmm. Dunno.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Current approach: File mount, direct passthrough to QEMU
Env var approach: Read → env var → write temp file → pass to QEMU

Would you still prefer the env var approach despite needing to re-materialize the file? Or should we keep the current mount approach since QEMU fundamentally needs a file anyway?

@gursewak1997 gursewak1997 force-pushed the add-ignition-support branch from 7be5f96 to 86e645a Compare March 23, 2026 22:06
Add support for injecting Ignition configuration files into ephemeral
VMs via QEMU's fw_cfg mechanism (x86_64/aarch64) and virtio-blk
(s390x/ppc64le). This enables first-boot provisioning for bootc-based
systems that use Ignition.

Implementation:
- Architecture-specific config delivery per FCOS docs:
  * x86_64/aarch64: fw_cfg at opt/com.coreos/config
  * s390x/ppc64le: virtio-blk with serial 'ignition', readonly
- Runtime architecture detection for correct method
- Image validation via labels (coreos.ignition or com.coreos.osname)
- Added readonly support for virtio-blk devices
- Added ignition.platform.id=qemu kernel argument when config specified
- Path validation with existence, type, and readability checks
- Brief error messages with man page reference

Testing:
- 5 comprehensive integration tests:
  * fw_cfg accessibility verification
  * Invalid path rejection
  * Directory rejection
  * Unsupported image detection
  * Kernel argument presence validation
- All tests pass with FCOS image verification

Documentation:
- Comprehensive man page section with working Ignition v3.3.0 example
- SSH key injection and file creation demo
- Architecture-specific delivery notes
- Links to upstream Ignition and bootc documentation
- Important notes about ephemeral boot behavior

The config is successfully passed to the guest (verified via
/sys/firmware/qemu_fw_cfg/ and /proc/cmdline). Ignition will process
it on first boot. For ephemeral testing with pre-built FCOS images,
Ignition skips as expected (subsequent boot behavior).

Useful for custom bootc images with Ignition (see bootc initramfs
docs) and future to-disk workflows.

Assisted-by: Claude Code (Sonnet 4.5)
Signed-off-by: gursewak1997 <gursmangat@gmail.com>
@gursewak1997 gursewak1997 force-pushed the add-ignition-support branch from 86e645a to 1b5eebe Compare March 24, 2026 22:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants