#!/bin/bash set -e export LIBVIRT_DEFAULT_URI=lxc:/// DOMAIN=sl function cleanup () { set +x echo "Running cleanup" echo 0 > /sys/kernel/debug/tracing/events/cgroup/enable virsh -c lxc:/// destroy sl || true if [ -n "$SUCCESS" ]; then echo "Finished succesfully" else echo "Got an error." fi } trap cleanup exit cat <dom.xml sl 256000 256000 1 exe /bin/bash EOF virsh define dom.xml || true echo 1 > /sys/kernel/debug/tracing/events/cgroup/enable # Restart systemd, this triggers the problem echo "systemctl deamon-reload start" > /sys/kernel/debug/tracing/trace_marker systemctl daemon-reload echo "systemctl deamon-reload finished" > /sys/kernel/debug/tracing/trace_marker set -x # Start the lxc container echo "virsh start ${DOMAIN} start" > /sys/kernel/debug/tracing/trace_marker virsh start ${DOMAIN} echo "virsh start ${DOMAIN} finished" > /sys/kernel/debug/tracing/trace_marker virsh list PID=$(virsh -c lxc:/// list --state-running | sed -ne 's/ \([0-9]\+\) .*/\1/p') WATCH=/proc/$PID/cgroup echo "Before ${WATCH}" cat ${WATCH} sleep 1 # Restart libvirtd echo "sysemctl stop libvirtd start" > /sys/kernel/debug/tracing/trace_marker systemctl stop libvirtd echo "sysemctl stop libvirtd finished" > /sys/kernel/debug/tracing/trace_marker echo "sysemctl start libvirtd start" > /sys/kernel/debug/tracing/trace_marker systemctl start libvirtd echo "sysemctl start libvirtd finished" > /sys/kernel/debug/tracing/trace_marker # Check if container is still there echo "After" cat ${WATCH} if ! virsh list | grep -qs "${DOMAIN}[[:space:]]\+running"; then echo 'Domain disappeared!' exit 1 fi SUCCESS=1