core-admin/dom0/pm-utils/01qubes-suspend-netvm
Marek Marczykowski 369a8dc67e Down net ifaces on suspend (#146)
NetworkManager stop isn't enough
2011-04-30 23:55:15 +02:00

40 lines
880 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; for if in `ls /sys/class/net|grep -v "lo\|vif"`; do ip l s $if down; done'
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