Stop only NM on suspend. (#146)

Also remove ip_forward setting from sysctl, so NM will not reset it on restart
This commit is contained in:
Marek Marczykowski 2011-03-30 22:29:57 +02:00
parent c2e0a84c22
commit 212fd13957
2 changed files with 20 additions and 10 deletions

View File

@ -2,24 +2,31 @@
. "${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()
{
NETVM=$(qvm-get-default-netvm)
if [ "X"$NETVM = "X""dom0" -o "X"$NETVM = "X" -o "X"$NETVM = "X""none"] ; then
exit 0
fi
qvm-run -u root --pass_io $NETVM "source /usr/lib64/pm-utils/pm-functions; run_hooks sleep suspend suspend"
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()
{
NETVM=$(qvm-get-default-netvm)
if [ "X"$NETVM = "X""dom0" -o "X"$NETVM = "X" -o "X"$NETVM = "X""none"] ; then
exit 0
fi
qvm-run -u root --pass_io $NETVM "source /usr/lib64/pm-utils/pm-functions; run_hooks sleep resume suspend reverse"
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
}

View File

@ -73,6 +73,9 @@ cp ../common/vif-route-qubes $RPM_BUILD_ROOT/etc/xen/scripts
chkconfig --add qubes_core_netvm || echo "WARNING: Cannot add service qubes_core!"
chkconfig qubes_core_netvm on || echo "WARNING: Cannot enable service qubes_core!"
# Remove ip_forward setting from sysctl, so NM will not reset it
sed 's/^net.ipv4.ip_forward.*/#\0/' -i /etc/sysctl.conf
%preun
if [ "$1" = 0 ] ; then
# no more packages left