17492f0fbf
When using SystemD, NetworkManager is started directly, so use this way. /etc/init.d/qubes_core_netvm doesn't exists in such system... Even when existed - it was already started and SystemD doesn't allow to start it again (unlike upstart/sysvinit).
40 lines
1013 B
Bash
Executable File
40 lines
1013 B
Bash
Executable File
#!/bin/sh
|
|
|
|
. "${PM_FUNCTIONS}"
|
|
|
|
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 'service NetworkManager stop; for if in `ls /sys/class/net|grep -v "lo\|vif"`; do ip l s $if down; done; modprobe -r uhci_hcd ehci_hcd'
|
|
done
|
|
# Ignore exit status from netvm...
|
|
return 0
|
|
}
|
|
|
|
resume_net()
|
|
{
|
|
for VM in `get_running_netvms`; do
|
|
qvm-run -u root --pass_io $VM "modprobe ehci_hcd; modprobe uhci_hcd; [ -x /bin/systemctl ] && systemctl start NetworkManager.service || service qubes_core_netvm start"
|
|
done
|
|
# Ignore exit status from netvm...
|
|
return 0
|
|
}
|
|
|
|
|
|
case "$1" in
|
|
resume) resume_net ;;
|
|
suspend) suspend_net ;;
|
|
*) exit 0 ;;
|
|
esac
|