feat: boot a test VM with mkosi -f vm

The [Runtime] section of mkosi.conf sets up mkosi vm for testing: it
passes the setup credentials (mkosi.credentials/agent.ssh-key prints your
own ssh keys), forwards ssh to port 2222 and adds the serial console,
since systemd-stub ignores the console= mkosi passes under Secure Boot.

Untested: in a container without systemd, mkosi vm hangs before qemu
starts, because it can't create a systemd scope.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Job79andClaude Opus 5.5 committed 2026-11-16 21:02:43 +01:00
1 parent ce1faca070
commit eb8e4b440a
5 files changed
+25 -13

No files matched your search

+14
View File
@@ -138,3 +138,17 @@ RemoveFiles=
SecureBoot=yes
SecureBootKey=mkosi.key
SecureBootCertificate=mkosi.crt
[Runtime]
# For testing with mkosi vm. It does the setup itself (the agent.* credentials,
# mkosi.extra/usr/libexec/agent-setup). Its console is hvc0, which the UKI
# doesn't use: with Secure Boot, systemd-stub ignores the console= mkosi
# passes. So the serial port joins that console, and replaces mkosi's network
# to forward ssh to port 2222. Ephemeral boots a copy, so test runs don't
# change the built image.
Ephemeral=yes
RAM=8G
RuntimeSize=40G
RuntimeNetwork=none
QemuArgs=-serial chardev:console -nic user,model=virtio-net-pci,hostfwd=tcp::2222-:22
Credentials=agent.password=test agent.hostname=agent-test mkosi.credentials/