Skip to content

Commit e9b0c47

Browse files
allisonkarlitskayacgwalters
authored andcommitted
examples: add test.thing workarounds
We want to start running images with test.thing, so add the workarounds for improved ssh-vsock support. These are no longer necessary in arch and fedora-rawhide. Unfortunately we can't put these in common/ because it's outside of the build context. Using an extra build context also seems not to work because symlinks aren't copied properly unless it's from the primary context. Make a small fix to a comment in examples/uki/Containerfile that should have been cleaned up as part of a4cbd3e ("Update approach to handling boot resources"). Signed-off-by: Allison Karlitskaya <[email protected]>
1 parent d6f5761 commit e9b0c47

File tree

19 files changed

+104
-3
lines changed

19 files changed

+104
-3
lines changed

examples/bls/Containerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ EOF
1717

1818
COPY cfsctl /usr/bin
1919
COPY extra /
20+
COPY test-thing.workarounds/fedora-42 /
2021
RUN --mount=type=cache,target=/var/cache/libdnf5 <<EOF
2122
kernel-install add-all
2223
systemctl enable systemd-networkd

examples/bls/Containerfile.rhel9

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ EOF
1919

2020
COPY cfsctl /usr/bin
2121
COPY extra /
22+
COPY test-thing.workarounds/rhel9 /
2223
RUN <<EOF
2324
set -eux
2425
mkdir -p /etc/kernel

examples/bls/Containerfile.ubuntu

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,5 @@ RUN <<EOF
3535
passwd -d root
3636
mkdir /sysroot
3737
EOF
38+
COPY test-thing.workarounds/debian /
3839
COPY cfsctl /usr/bin
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Guest support workarounds
2+
3+
These are extra files that you can add to virtual machine guests to enable
4+
support for missing features required by `test.thing`:
5+
6+
- [debian/](debian/): enables ephemeral ssh key support
7+
- [fedora-42/](fedora-42/): enables ephemeral ssh key support ([this is
8+
supported without a workaround in Fedora 43 and
9+
later](https://src.fedoraproject.org/rpms/openssh/pull-request/101))
10+
- [rhel9/](rhel9/): enables sshd vsock listener (with ephemeral ssh key
11+
support) and sends the expected `sd_notify` message when the guest reaches
12+
`multi-user.target`
13+
14+
`test.thing` can also work with guests lacking support for ephemeral ssh keys
15+
by including a fixed ssh key in the image, or by using the
16+
`ssh.authorized_keys.root` credential (since systemd 252), but this requires
17+
modifying root's home directory at runtime and only works if another ssh key
18+
isn't already present, so it isn't enabled by default.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Debian
2+
SSHD_OPTS=-o "AuthorizedKeysFile /run/credentials/@system/ssh.ephemeral-authorized_keys-all .ssh/authorized_keys"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Needed for Fedora 42
2+
# https://src.fedoraproject.org/rpms/openssh/pull-request/101
3+
OPTIONS=-o "AuthorizedKeysFile /run/credentials/@system/ssh.ephemeral-authorized_keys-all .ssh/authorized_keys"
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/python3
2+
3+
"""Notify that the system has reached multi-user.target."""
4+
5+
import os
6+
import socket
7+
from pathlib import Path
8+
9+
credentials = Path(os.environ["CREDENTIALS_DIRECTORY"])
10+
notify_socket = (credentials / "vmm.notify_socket").read_text()
11+
af, cid, port = notify_socket.split(":")
12+
assert af == "vsock"
13+
sock = socket.socket(socket.AF_VSOCK, socket.SOCK_SEQPACKET)
14+
sock.connect((int(cid), int(port)))
15+
sock.sendmsg([b"X_SYSTEMD_UNIT_ACTIVE=multi-user.target\n"])
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../notify-multiuser.service
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[Unit]
2+
After=multi-user.target
3+
Wants=multi-user.target
4+
5+
[Service]
6+
LoadCredential=vmm.notify_socket
7+
ExecStart=/etc/notify-multiuser.py
8+
Type=exec
9+
RemainAfterExit=yes
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../sshd-vsock.socket

0 commit comments

Comments
 (0)