From 906332ea40e5a052079d44a7a298835905a62ca1 Mon Sep 17 00:00:00 2001 From: Marek Marczykowski Date: Fri, 13 Jul 2012 14:40:52 +0200 Subject: [PATCH] vm: export SuspendPre and SuspendPost qrexec services (#617) 1. Try to use NetworkManager sleep command instead of shutting it down 2. Move sleep action details (which is VM-specific) to VM 3. Export it as qrexec service(s) --- qubes_rpc/prepare-suspend | 16 ++++++++++++++++ qubes_rpc/qubes.SuspendPost | 1 + qubes_rpc/qubes.SuspendPre | 1 + rpm_spec/core-vm.spec | 5 +++++ 4 files changed, 23 insertions(+) create mode 100755 qubes_rpc/prepare-suspend create mode 100644 qubes_rpc/qubes.SuspendPost create mode 100644 qubes_rpc/qubes.SuspendPre diff --git a/qubes_rpc/prepare-suspend b/qubes_rpc/prepare-suspend new file mode 100755 index 00000000..4df1122e --- /dev/null +++ b/qubes_rpc/prepare-suspend @@ -0,0 +1,16 @@ +#!/bin/sh + +action=$1 +[ -z "$action" ] && action=suspend + +if [ x"$action" == x"suspend" ]; then + nmcli nm sleep true || service NetworkManager stop + # Force interfaces down, just in case when NM didn't done it + for if in `ls /sys/class/net|grep -v "lo\|vif"`; do + ip l s $if down + done + modprobe -r uhci_hcd ehci_hcd +else + modprobe ehci_hcd; modprobe uhci_hcd; + nmcli nm sleep false || { [ -x /bin/systemctl ] && systemctl start NetworkManager.service; } || service qubes_core_netvm start +fi diff --git a/qubes_rpc/qubes.SuspendPost b/qubes_rpc/qubes.SuspendPost new file mode 100644 index 00000000..73bf2ead --- /dev/null +++ b/qubes_rpc/qubes.SuspendPost @@ -0,0 +1 @@ +/usr/lib/qubes/prepare-suspend resume diff --git a/qubes_rpc/qubes.SuspendPre b/qubes_rpc/qubes.SuspendPre new file mode 100644 index 00000000..ad49fa65 --- /dev/null +++ b/qubes_rpc/qubes.SuspendPre @@ -0,0 +1 @@ +/usr/lib/qubes/prepare-suspend suspend diff --git a/rpm_spec/core-vm.spec b/rpm_spec/core-vm.spec index 829a6ec3..f24c679b 100644 --- a/rpm_spec/core-vm.spec +++ b/rpm_spec/core-vm.spec @@ -158,10 +158,12 @@ install qubes_rpc/qvm-copy-to-vm.gnome $RPM_BUILD_ROOT/usr/lib/qubes install qubes_rpc/{vm-file-editor,qfile-agent,qopen-in-vm,qfile-unpacker} $RPM_BUILD_ROOT/usr/lib/qubes install qubes_rpc/{vm-shell,qrun-in-vm} $RPM_BUILD_ROOT/usr/lib/qubes install qubes_rpc/sync-ntp-clock $RPM_BUILD_ROOT/usr/lib/qubes +install qubes_rpc/prepare-suspend $RPM_BUILD_ROOT/usr/lib/qubes install -d $RPM_BUILD_ROOT/%{kde_service_dir} install -m 0644 qubes_rpc/{qvm-copy.desktop,qvm-dvm.desktop} $RPM_BUILD_ROOT/%{kde_service_dir} install -d $RPM_BUILD_ROOT/etc/qubes_rpc install -m 0644 qubes_rpc/{qubes.Filecopy,qubes.OpenInVM,qubes.VMShell,qubes.SyncNtpClock} $RPM_BUILD_ROOT/etc/qubes_rpc +install -m 0644 qubes_rpc/{qubes.SuspendPre,qubes.SuspendPost} $RPM_BUILD_ROOT/etc/qubes_rpc install qrexec/qrexec_agent $RPM_BUILD_ROOT/usr/lib/qubes install qrexec/qrexec_client_vm $RPM_BUILD_ROOT/usr/lib/qubes @@ -371,6 +373,8 @@ rm -rf $RPM_BUILD_ROOT /etc/qubes_rpc/qubes.OpenInVM /etc/qubes_rpc/qubes.VMShell /etc/qubes_rpc/qubes.SyncNtpClock +/etc/qubes_rpc/qubes.SuspendPre +/etc/qubes_rpc/qubes.SuspendPost /etc/sudoers.d/qubes /etc/sysconfig/iptables /etc/sysconfig/modules/qubes_core.modules @@ -396,6 +400,7 @@ rm -rf $RPM_BUILD_ROOT /usr/lib/qubes/block_remove /usr/lib/qubes/dispvm-prerun.sh /usr/lib/qubes/sync-ntp-clock +/usr/lib/qubes/prepare-suspend /usr/lib/qubes/meminfo-writer /usr/lib/qubes/network-manager-prepare-conf-dir /usr/lib/qubes/qfile-agent