Skip to content

Commit

Permalink
Add OCP console hack
Browse files Browse the repository at this point in the history
If TERM=xterm is specified, connect to the vm console instead of the
container.

Signed-off-by: Roman Mohr <[email protected]>
  • Loading branch information
rmohr committed Apr 3, 2018
1 parent 8f3bbe6 commit d0aef06
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions cmd/virt-launcher/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ RUN dnf -y install \
test $(id -u qemu) = 107 # make sure that the qemu user really is 107

COPY sock-connector /sock-connector
COPY sh.sh /sh.sh
COPY virt-launcher /virt-launcher

COPY kubevirt-sudo /etc/sudoers.d/kubevirt
Expand Down
6 changes: 6 additions & 0 deletions cmd/virt-launcher/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ fi
chown :qemu /dev/kvm
chmod 660 /dev/kvm


# Cockpit/OCP hack to all shoing the vm terminal
mv /usr/bin/sh /usr/bin/sh.orig
mv /sh.sh /usr/bin/sh
chmod +x /usr/bin/sh

./virt-launcher $@
rc=$?

Expand Down
9 changes: 9 additions & 0 deletions cmd/virt-launcher/sh.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/sh.orig

if [ ${TERM} = "xterm" ] ; then
namespace="$(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace)"
name="$(ls /var/run/kubevirt-private/${namespace}/)"
/usr/bin/sh.orig -c "/sock-connector /var/run/kubevirt-private/${namespace}/${name}/virt-serial0"
else
/usr/bin/sh.orig "$@"
fi

0 comments on commit d0aef06

Please sign in to comment.