core-admin/dom0/pm-utils/01qubes-suspend-netvm
Marek Marczykowski 212fd13957 Stop only NM on suspend. (#146)
Also remove ip_forward setting from sysctl, so NM will not reset it on restart
2011-03-31 00:19:41 +02:00

40 lines
805 B
Bash
Executable File

#!/bin/sh
. "${PM_FUNCTIONS}"
get_running_netvms() {
# Actually get running VMs with PCI devices attached
RUNNING_VMS=`xm list --state=Running | tail -n +3 | cut -f 1 -d " "`
RUNNING_NETVMS=""
for VM in $RUNNING_VMS; do
if [ -n "`xm pci-list $VM`" ]; then
echo "$VM"
fi
done
}
suspend_net()
{
for VM in `get_running_netvms`; do
qvm-run -u root --pass_io $VM "service NetworkManager stop"
done
# Ignore exit status from netvm...
return 0
}
resume_net()
{
for VM in `get_running_netvms`; do
qvm-run -u root --pass_io $VM "service NetworkManager start"
done
# Ignore exit status from netvm...
return 0
}
case "$1" in
resume) resume_net ;;
suspend) suspend_net ;;
*) exit 0 ;;
esac