Last active
May 5, 2020 01:57
-
-
Save conorsch/316e11b7dc5211b4c84e77876dd23b6b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Test script to evaluate the qrexec service for Qubes VMs, | |
# depending on virt_mode=(hvm|pvh). Starts several test-only VMs | |
# of both virt types, then executes a command inside of them and reports | |
# the time to completion of that command. | |
function run_cmd_in_vm() { | |
vm_name="$1" | |
shift | |
start_time="$(date +%s)" | |
# sudo qubesctl --show-output --skip-dom0 --target $vm_name state.sls update.qubes-vm | |
qvm-run -q $vm_name "echo hello" | |
end_time="$(date +%s)" | |
run_time="$((end_time-start_time))" | |
echo "Run time for $vm_name: ${run_time}s" | |
} | |
# Cleanup from prior runs | |
for vm in $(qvm-ls --tags test-qrexec-timeout --raw-list); do | |
{ qvm-shutdown --wait $vm; qvm-remove -f $vm ; } & | |
done | |
wait | |
function handle_vm() { | |
vm_name="$1" | |
shift | |
if ! qvm-check -q $vm_name 2>/dev/null; then | |
qvm-create $vm_name --label blue --template securedrop-workstation-buster | |
fi | |
qvm-prefs $vm_name virt_mode "$virt_mode" | |
if [[ "$virt_mode" = "hvm" ]]; then | |
qvm-prefs $vm_name kernel '' | |
else | |
qvm-prefs $vm_name kernel "$(qubes-prefs default_kernel)" | |
fi | |
qvm-prefs $vm_name memory 400 | |
qvm-prefs $vm_name maxmem 400 | |
qvm-tags $vm_name add test-qrexec-timeout | |
run_cmd_in_vm $vm_name | |
} | |
for n in $(seq 3); do | |
for virt_mode in "hvm" "pvh"; do | |
vm_name="test-${virt_mode}-${n}" | |
handle_vm $vm_name & | |
done | |
done | |
wait |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment