qubes-core-admin-linux/pm-utils/51qubes-suspend-netvm
Marek Marczykowski-Górecki 2b716bc141 pm-utils: do not load PM_FUNCTIONS - not used in our scripts
And not available when called from systemd
2013-11-06 15:42:59 +01:00

38 lines
785 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"
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