From 2bcbc1742ea68dae5b55d7e5cdb3b65a0befae4a Mon Sep 17 00:00:00 2001 From: Marek Marczykowski Date: Tue, 29 Mar 2011 12:20:50 +0200 Subject: [PATCH 1/3] Run pm-utils scripts in netvm on suspend (#146) --- dom0/pm-utils/01qubes-suspend-netvm | 28 +++++++++++++++++ dom0/pm-utils/01qubes-swap-pci-devs | 48 ----------------------------- 2 files changed, 28 insertions(+), 48 deletions(-) create mode 100755 dom0/pm-utils/01qubes-suspend-netvm delete mode 100755 dom0/pm-utils/01qubes-swap-pci-devs diff --git a/dom0/pm-utils/01qubes-suspend-netvm b/dom0/pm-utils/01qubes-suspend-netvm new file mode 100755 index 00000000..1491bb47 --- /dev/null +++ b/dom0/pm-utils/01qubes-suspend-netvm @@ -0,0 +1,28 @@ +#!/bin/sh + +. "${PM_FUNCTIONS}" + +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" +} + +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" +} + + +case "$1" in + resume) resume_net ;; + suspend) suspend_net ;; + *) exit 0 ;; +esac diff --git a/dom0/pm-utils/01qubes-swap-pci-devs b/dom0/pm-utils/01qubes-swap-pci-devs deleted file mode 100755 index 2922c5b8..00000000 --- a/dom0/pm-utils/01qubes-swap-pci-devs +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/sh - -. "${PM_FUNCTIONS}" - -get_domain_pci_devs() -{ - VM=$1 - TMPFILE=$(mktemp -p /var/run/qubes/) - xm pci-list $VM > $TMPFILE - if grep -i -q vslt $TMPFILE ; then - slt=valid_identifier - else - slt="" - fi - cat $TMPFILE | grep -v domain | sed 's/0x//g'| \ - while read $slt a b c d; do echo $a:$b:$c.$d ; done > /var/run/qubes/$VM.pcidevs - rm -f $TMPFILE -} - -detach_pcis() -{ - NETVM=$(qvm-get-default-netvm) - if [ "X"$NETVM = "X""dom0" -o "X"$NETVM = "X" -o "X"$NETVM = "X""none"] ; then - exit 0 - fi - get_domain_pci_devs $NETVM - for dev in $(cat /var/run/qubes/$NETVM.pcidevs) ; do - xm pci-detach $NETVM $dev - done -} - -attach_pcis() -{ - NETVM=$(qvm-get-default-netvm) - if [ "X"$NETVM = "X""dom0" -o "X"$NETVM = "X" -o "X"$NETVM = "X""none"] ; then - exit 0 - fi - for dev in $(cat /var/run/qubes/$NETVM.pcidevs) ; do - xm pci-attach $NETVM $dev - done -} - - -case "$1" in - resume) attach_pcis ;; - suspend) detach_pcis ;; - *) exit 0 ;; -esac From 464337a24e1279b99dec2abfe6cd90d69ceeddcf Mon Sep 17 00:00:00 2001 From: Marek Marczykowski Date: Tue, 29 Mar 2011 12:22:31 +0200 Subject: [PATCH 2/3] Ignore exit status from netvm pm-scripts (#146) --- dom0/pm-utils/01qubes-suspend-netvm | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dom0/pm-utils/01qubes-suspend-netvm b/dom0/pm-utils/01qubes-suspend-netvm index 1491bb47..a0e2f447 100755 --- a/dom0/pm-utils/01qubes-suspend-netvm +++ b/dom0/pm-utils/01qubes-suspend-netvm @@ -9,6 +9,8 @@ suspend_net() exit 0 fi qvm-run -u root --pass_io $NETVM "source /usr/lib64/pm-utils/pm-functions; run_hooks sleep suspend suspend" + # Ignore exit status from netvm... + return 0 } resume_net() @@ -18,6 +20,8 @@ resume_net() exit 0 fi qvm-run -u root --pass_io $NETVM "source /usr/lib64/pm-utils/pm-functions; run_hooks sleep resume suspend reverse" + # Ignore exit status from netvm... + return 0 } From c2e0a84c222be070449c6d679ed43d0f0f48759e Mon Sep 17 00:00:00 2001 From: Marek Marczykowski Date: Tue, 29 Mar 2011 12:39:01 +0200 Subject: [PATCH 3/3] Add 01qubes-suspend-netvm to rpm (#146) --- rpm_spec/core-dom0.spec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rpm_spec/core-dom0.spec b/rpm_spec/core-dom0.spec index fcb5be8c..0fc1ab47 100644 --- a/rpm_spec/core-dom0.spec +++ b/rpm_spec/core-dom0.spec @@ -126,7 +126,7 @@ cp ../common/iptables $RPM_BUILD_ROOT/etc/sysconfig mkdir -p $RPM_BUILD_ROOT/usr/lib64/pm-utils/sleep.d cp pm-utils/01qubes-sync-vms-clock $RPM_BUILD_ROOT/usr/lib64/pm-utils/sleep.d/ -cp pm-utils/01qubes-swap-pci-devs $RPM_BUILD_ROOT/usr/lib64/pm-utils/sleep.d/ +cp pm-utils/01qubes-suspend-netvm $RPM_BUILD_ROOT/usr/lib64/pm-utils/sleep.d/ cp pm-utils/02qubes-pause-vms $RPM_BUILD_ROOT/usr/lib64/pm-utils/sleep.d/ mkdir -p $RPM_BUILD_ROOT/var/log/qubes @@ -306,7 +306,7 @@ fi /etc/NetworkManager/dispatcher.d/qubes_nmhook /etc/sysconfig/iptables /usr/lib64/pm-utils/sleep.d/01qubes-sync-vms-clock -/usr/lib64/pm-utils/sleep.d/01qubes-swap-pci-devs +/usr/lib64/pm-utils/sleep.d/01qubes-suspend-netvm /usr/lib64/pm-utils/sleep.d/02qubes-pause-vms /usr/bin/xenstore-watch /usr/lib/qubes/qubes_restore