Skip to content

Commit

Permalink
xen-tools: add eve-enter-container script
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
rouming committed Nov 3, 2023
1 parent 2735602 commit 6830fa9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/xen-tools/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ COPY initrd/init-initrd initrd/mount_disk.sh initrd/udhcpc_script.sh /
COPY initrd/poweroff /sbin/poweroff
COPY initrd/chroot2.c initrd/hacf.c /tmp/
COPY initrd/00000080 /etc/acpi/PWRF/
COPY initrd/eve-enter-container /bin/
RUN gcc -s -o /chroot2 /tmp/chroot2.c
RUN gcc -s -o /hacf /tmp/hacf.c
RUN mkinitfs -n -F base -i /init-initrd -o /runx-initrd
Expand Down
1 change: 1 addition & 0 deletions pkg/xen-tools/initrd/base.files
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/bin/busybox
/bin/eve-enter-container
/sbin/agetty
/sbin/mke2fs
/lib/libext2fs.so.2*
Expand Down
13 changes: 13 additions & 0 deletions pkg/xen-tools/initrd/eve-enter-container
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/sh

# PID of the started entrypoint container process.
# PID file is created from the `init-initrd` script.
PID_FILE="/mnt/entrypoint-pid"

if [ ! -f "$PID_FILE" ]; then
echo "Error: PID file '$PID_FILE' not found. Container did not start?"
exit 1
fi

PID=$(cat "$PID_FILE")
nsenter -t "$PID" -m -u -i -n -p -r/mnt/rootfs -w/mnt/rootfs

0 comments on commit 6830fa9

Please sign in to comment.