From 212fd13957fff8eac1d39dc610cbda4575e58826 Mon Sep 17 00:00:00 2001 From: Marek Marczykowski Date: Wed, 30 Mar 2011 22:29:57 +0200 Subject: [PATCH] Stop only NM on suspend. (#146) Also remove ip_forward setting from sysctl, so NM will not reset it on restart --- dom0/pm-utils/01qubes-suspend-netvm | 27 +++++++++++++++++---------- rpm_spec/core-netvm.spec | 3 +++ 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/dom0/pm-utils/01qubes-suspend-netvm b/dom0/pm-utils/01qubes-suspend-netvm index a0e2f447..cf635ae6 100755 --- a/dom0/pm-utils/01qubes-suspend-netvm +++ b/dom0/pm-utils/01qubes-suspend-netvm @@ -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 } diff --git a/rpm_spec/core-netvm.spec b/rpm_spec/core-netvm.spec index b4f1eb34..d09139b0 100644 --- a/rpm_spec/core-netvm.spec +++ b/rpm_spec/core-netvm.spec @@ -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