qubes-core-admin-linux/pm-utils/51qubes-suspend-netvm
Simon Gaiser e7f4fa9a5d pm-utils: Fix handling of HVM domains
`xl list` reports the PCI devies for the stub domain. But we want to
call qubes.SuspendPre inside the domain itself.
2018-01-09 03:21:53 +01:00

38 lines
791 B
Bash
Executable File

#!/bin/sh
get_running_netvms() {
# Actually get running VMs with PCI devices attached
RUNNING_VMS=`xl list | tail -n +3 | cut -f 1 -d " "`
RUNNING_NETVMS=""
for VM in $RUNNING_VMS; do
if [ -n "`xl pci-list $VM|tail -n +2`" ]; then
echo "${VM%-dm}"
fi
done
}
suspend_net()
{
for VM in `get_running_netvms`; do
qvm-run -u root --pass-io $VM 'QUBESRPC qubes.SuspendPre dom0'
done
# Ignore exit status from netvm...
return 0
}
resume_net()
{
for VM in `get_running_netvms`; do
qvm-run -u root --pass-io $VM 'QUBESRPC qubes.SuspendPost dom0'
done
# Ignore exit status from netvm...
return 0
}
case "$1" in
resume) resume_net ;;
suspend) suspend_net ;;
*) exit 0 ;;
esac