Petr Šabata f5bf49
# Executed before VM starts
Petr Šabata f5bf49
on_build() {
Petr Šabata f5bf49
	img_inst_pkg "sshpass"
Petr Šabata f5bf49
	img_add_qemu_cmd "-nic socket,connect=127.0.0.1:8010,mac=52:54:00:12:34:57"
Petr Šabata f5bf49
}
Petr Šabata f5bf49
Petr Šabata f5bf49
on_test() {
Petr Šabata f5bf49
	local boot_count=$(get_test_boot_count)
Petr Šabata f5bf49
	local ssh_server=192.168.77.1
Petr Šabata f5bf49
Petr Šabata f5bf49
	if [ "$boot_count" -eq 1 ]; then
Petr Šabata f5bf49
cat << EOF > /etc/kdump.conf
Petr Šabata f5bf49
ssh root@192.168.77.1
DistroBaker 5cac7c
core_collector makedumpfile -l --message-level 7 -d 31 -F
Petr Šabata f5bf49
EOF
Petr Šabata f5bf49
DistroBaker 17a515
		ssh-keygen -q -t rsa -N '' -f /root/.ssh/id_rsa <<< y
Petr Šabata f5bf49
Petr Šabata f5bf49
		while ! ping -c 1 $ssh_server -W 1; do
Petr Šabata f5bf49
			sleep 1
Petr Šabata f5bf49
		done
Petr Šabata f5bf49
Petr Šabata f5bf49
		while [ -z "$(cat /root/.ssh/known_hosts)" ]; do
Petr Šabata f5bf49
			ssh-keyscan -H 192.168.77.1 > /root/.ssh/known_hosts
Petr Šabata f5bf49
		done
Petr Šabata f5bf49
DistroBaker 17a515
		sshpass -p fedora ssh $ssh_server "mkdir /root/.ssh"
DistroBaker 17a515
		cat /root/.ssh/id_rsa.pub | sshpass -p fedora ssh $ssh_server "cat >> /root/.ssh/authorized_keys"
Petr Šabata f5bf49
DistroBaker 17a515
		sshpass -p fedora kdumpctl propagate
DistroBaker 17a515
		cat /root/.ssh/kdump_id_rsa.pub | sshpass -p fedora ssh $ssh_server "cat >> /root/.ssh/authorized_keys"
Petr Šabata f5bf49
Petr Šabata f5bf49
		kdumpctl start || test_failed "Failed to start kdump"
Petr Šabata f5bf49
Petr Šabata f5bf49
		sync
Petr Šabata f5bf49
Petr Šabata f5bf49
		echo 1 > /proc/sys/kernel/sysrq
Petr Šabata f5bf49
		echo c > /proc/sysrq-trigger
Petr Šabata f5bf49
	else
Petr Šabata f5bf49
		shutdown -h 0
Petr Šabata f5bf49
	fi
Petr Šabata f5bf49
}