Skip to content

Commit

Permalink
allow to send sysrq to VM builds (KVM only atm)
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianschroeter committed Feb 7, 2018
1 parent 97c3867 commit cb17150
Show file tree
Hide file tree
Showing 13 changed files with 72 additions and 2 deletions.
22 changes: 22 additions & 0 deletions build
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ Known Parameters:
--shell Instead of starting a build start a root shell in
the build root.
--sysrq $ Sends a single specifed char as sysrq to the running
kernel of the build.
--clean Delete old build root before initializing it
--wipe Completely removes build environment and exits.
Expand Down Expand Up @@ -727,6 +730,15 @@ wipe_build_environment() {
fi
}

sysrq_running_build() {
test -z "$SRCDIR" || usage
if test -n "$VM_TYPE" ; then
vm_sysrq "$1"
else
cleanup_and_exit 1 "can not send a sysrq to chroot builds"
fi
}

kill_running_build() {
test -z "$SRCDIR" || usage
(set -C; > "$BUILD_ROOT/exit" 2>/dev/null || true)
Expand Down Expand Up @@ -969,6 +981,11 @@ while test -n "$1"; do
BUILD_RPMS=
shift
;;
-sysrq)
needarg
SEND_SYSRQ="${ARG:0:1}"
shift
;;
-shell)
RUN_SHELL=1
shift
Expand Down Expand Up @@ -1055,6 +1072,11 @@ if test -n "$KILL" ; then
cleanup_and_exit
fi

if test -n "$SEND_SYSRQ" ; then
sysrq_running_build "$SEND_SYSRQ"
cleanup_and_exit
fi

if test -n "$CLEAN_BUILD" ; then
DO_INIT=true
DO_INIT_TOPDIR=true
Expand Down
7 changes: 6 additions & 1 deletion build-vm
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ vm_startup() {
vm_startup_$VM_TYPE "$@"
}

vm_sysrq() {
vm_sysrq_$VM_TYPE "$@"
}

vm_kill() {
vm_kill_$VM_TYPE "$@"
}
Expand Down Expand Up @@ -351,7 +355,7 @@ vm_img_wipe() {
vm_wipe_$VM_TYPE "$@"

if test -n "$VM_ROOT" -a "$VM_ROOT_TYPE" = file ; then
rm -f "$VM_ROOT"
rm -f "$VM_ROOT" "${VM_ROOT}.monitor"
fi
if test -n "$VM_SWAP" -a "$VM_SWAP_TYPE" = file ; then
rm -f "$VM_SWAP"
Expand Down Expand Up @@ -681,6 +685,7 @@ vm_setup() {
if test ! -e "$VM_ROOT" ; then
cleanup_and_exit 3 "you need to create $VM_ROOT first"
fi
mkfifo "${VM_ROOT}.monitor"
if test -n "$CLEAN_BUILD" ; then
vm_img_mkfs "$VMDISK_FILESYSTEM" "$VM_ROOT" || cleanup_and_exit 3
fi
Expand Down
4 changes: 4 additions & 0 deletions build-vm-docker
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ vm_cleanup_docker() {
:
}

vm_sysrq_docker() {
:
}

vm_wipe_docker() {
local name="obsbuild.${BUILD_ROOT##*/}"
docker rm "$name" >/dev/null 2>&1 || true
Expand Down
4 changes: 4 additions & 0 deletions build-vm-ec2
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,10 @@ vm_cleanup_ec2() {
test -n "$EC2_EXTRACT_VOLUME_swap" && ec2-delete-volume --region "$BUILD_EC2_REGION" "$EC2_EXTRACT_VOLUME_swap"
}

vm_sysrq_ec2() {
:
}

vm_kill_ec2() {
if ec2-describe-instance-status "$VM_BUILD_INSTANCE" --region "$BUILD_EC2_REGION" >/dev/null 2>&1 ; then
if ec2-terminate-instances "$VM_BUILD_INSTANCE" >/dev/null 2>&1 ; then
Expand Down
3 changes: 3 additions & 0 deletions build-vm-emulator
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ vm_detach_swap_emulator() {
vm_cleanup_emulator() {
:
}
vm_sysrq_emulator() {
:
}
vm_wipe_emulator() {
:
}
Expand Down
6 changes: 5 additions & 1 deletion build-vm-kvm
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ vm_startup_kvm() {
elif test -n "$VM_CONSOLE_INPUT" ; then
qemu_args=("${qemu_args[@]}" -serial mon:stdio)
else
qemu_args=("${qemu_args[@]}" -serial stdio)
qemu_args=("${qemu_args[@]}" -serial stdio -chardev socket,id=monitor,server,nowait,path="${VM_ROOT}.monitor" -mon chardev=monitor,mode=readline)
fi

if test -n "$BUILD_JOBS" -a "$icecream" = 0 -a -z "$BUILD_THREADS" ; then
Expand Down Expand Up @@ -327,6 +327,10 @@ vm_cleanup_kvm() {
:
}

vm_sysrq_kvm() {
echo "sendkey alt-print-$1" | socat - UNIX-CONNECT:"$VM_ROOT.monitor"
}

vm_wipe_kvm() {
:
}
4 changes: 4 additions & 0 deletions build-vm-lxc
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,10 @@ vm_detach_swap_lxc() {
:
}

vm_sysrq_lxc() {
:
}

vm_wipe_lxc() {
:
}
Expand Down
4 changes: 4 additions & 0 deletions build-vm-openstack
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,10 @@ vm_fixup_openstack() {
chmod 0755 "$BUILD_ROOT/sbin/init"
}

vm_sysrq_openstack() {
:
}

vm_wipe_openstack() {
if test -n "$VM_WORKER" ; then
$NOVACLIENT delete $VM_WORKER
Expand Down
4 changes: 4 additions & 0 deletions build-vm-pvm
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,10 @@ vm_cleanup_pvm(){
pvm_deletelv $swaplv
}

vm_sysrq_pvm(){
:
}

vm_wipe_pvm(){
:
}
Expand Down
4 changes: 4 additions & 0 deletions build-vm-qemu
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ vm_cleanup_qemu() {
vm_cleanup_kvm
}

vm_sysrq_qemu() {
:
}

vm_wipe_qemu() {
:
}
Expand Down
4 changes: 4 additions & 0 deletions build-vm-uml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ vm_cleanup_uml() {
:
}

vm_sysrq_uml() {
:
}

vm_wipe_uml() {
:
}
Expand Down
4 changes: 4 additions & 0 deletions build-vm-xen
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ vm_cleanup_xen() {
:
}

vm_sysrq_xen() {
:
}

vm_wipe_xen() {
:
}
Expand Down
4 changes: 4 additions & 0 deletions build-vm-zvm
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,10 @@ vm_cleanup_zvm() {
fi
}

vm_sysrq_zvm() {
:
}

vm_wipe_zvm() {
:
}

0 comments on commit cb17150

Please sign in to comment.