Skip to content

Commit 5618a2b

Browse files
committed
xen-tools: add eve-enter-container script
Once terminal is attached to the Vm console which hosts a container user can execute `eve-enter-container` script and enter corresponding container. Script uses `nsenter -t $pid` and pid is extracted from the /mnt/entrypoint-pid file, created by the chroot2 utility. Signed-off-by: Roman Penyaev <[email protected]>
1 parent 2243d20 commit 5618a2b

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

pkg/xen-tools/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ COPY initrd/init-initrd initrd/mount_disk.sh initrd/udhcpc_script.sh /
1212
COPY initrd/poweroff /sbin/poweroff
1313
COPY initrd/chroot2.c initrd/hacf.c /tmp/
1414
COPY initrd/00000080 /etc/acpi/PWRF/
15+
COPY initrd/eve-enter-container /bin/
1516
RUN gcc -s -o /chroot2 /tmp/chroot2.c
1617
RUN gcc -s -o /hacf /tmp/hacf.c
1718
RUN mkinitfs -n -F base -i /init-initrd -o /runx-initrd

pkg/xen-tools/initrd/base.files

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/bin/busybox
2+
/bin/eve-enter-container
23
/sbin/agetty
34
/sbin/mke2fs
45
/lib/libext2fs.so.2*
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/sh
2+
3+
# PID of the started entrypoint container process.
4+
# PID file is created from the `init-initrd` script.
5+
PID_FILE="/mnt/entrypoint-pid"
6+
7+
if [ ! -f "$PID_FILE" ]; then
8+
echo "Error: PID file '$PID_FILE' not found. Container did not start?"
9+
exit 1
10+
fi
11+
12+
PID=$(cat "$PID_FILE")
13+
nsenter -t "$PID" -m -u -i -n -p -r/mnt/rootfs -w/mnt/rootfs

0 commit comments

Comments
 (0)