Instruct qubesd to suspend VMs before going to sleep
Move suspend handling into qubesd.
This commit is contained in:
parent
9b75dd1321
commit
51abb471b9
@ -1,37 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
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 'QUBESRPC qubes.SuspendPre dom0'
|
||||
done
|
||||
# Ignore exit status from netvm...
|
||||
return 0
|
||||
}
|
||||
|
||||
resume_net()
|
||||
{
|
||||
for VM in `get_running_netvms`; do
|
||||
qvm-run -u root --pass-io $VM 'QUBESRPC qubes.SuspendPost dom0'
|
||||
done
|
||||
# Ignore exit status from netvm...
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
case "$1" in
|
||||
resume) resume_net ;;
|
||||
suspend) suspend_net ;;
|
||||
*) exit 0 ;;
|
||||
esac
|
@ -1,27 +1,12 @@
|
||||
#!/usr/bin/python
|
||||
#!/bin/sh
|
||||
|
||||
from qubes.qubes import QubesVmCollection,QubesException
|
||||
import sys
|
||||
|
||||
qc = QubesVmCollection()
|
||||
qc.lock_db_for_reading()
|
||||
qc.load()
|
||||
qc.unlock_db()
|
||||
|
||||
if sys.argv[1] in ["suspend", "hibernate"]:
|
||||
for vm in qc.values():
|
||||
if vm.is_running():
|
||||
try:
|
||||
vm.run_service("qubes.SuspendPreAll", user="root")
|
||||
vm.suspend()
|
||||
except Exception as e:
|
||||
print >>sys.stderr, "Failed to suspend VM %s: %s" % (vm.name, e.message)
|
||||
|
||||
elif sys.argv[1] in ["resume", "thaw"]:
|
||||
for vm in qc.values():
|
||||
if vm.get_power_state() in ["Paused", "Suspended"]:
|
||||
try:
|
||||
vm.resume()
|
||||
vm.run_service("qubes.SuspendPostAll", user="root")
|
||||
except Exception as e:
|
||||
print >>sys.stderr, "Failed to resume VM %s: %s" % (vm.name, e.message)
|
||||
case "$1" in
|
||||
suspend|hibernate)
|
||||
qubesd-query -e --fail -c /var/run/qubesd.internal.sock \
|
||||
dom0 internal.SuspendPre dom0
|
||||
;;
|
||||
resume|thaw)
|
||||
qubesd-query -e --fail -c /var/run/qubesd.internal.sock \
|
||||
dom0 internal.SuspendPost dom0
|
||||
;;
|
||||
esac
|
||||
|
@ -8,10 +8,8 @@ Type=oneshot
|
||||
RemainAfterExit=yes
|
||||
StandardOutput=syslog
|
||||
ExecStartPre=/usr/lib64/pm-utils/sleep.d/01qubes-sync-vms-clock suspend suspend
|
||||
ExecStartPre=/usr/lib64/pm-utils/sleep.d/51qubes-suspend-netvm suspend suspend
|
||||
ExecStart=/usr/lib64/pm-utils/sleep.d/52qubes-pause-vms suspend suspend
|
||||
ExecStop=/usr/lib64/pm-utils/sleep.d/52qubes-pause-vms resume suspend
|
||||
ExecStopPost=/usr/lib64/pm-utils/sleep.d/51qubes-suspend-netvm resume suspend
|
||||
ExecStopPost=/usr/lib64/pm-utils/sleep.d/01qubes-sync-vms-clock resume suspend
|
||||
|
||||
[Install]
|
||||
|
@ -113,7 +113,6 @@ cp qrexec/qubes-rpc-multiplexer $RPM_BUILD_ROOT/usr/lib/qubes
|
||||
### pm-utils
|
||||
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/51qubes-suspend-netvm $RPM_BUILD_ROOT/usr/lib64/pm-utils/sleep.d/
|
||||
cp pm-utils/52qubes-pause-vms $RPM_BUILD_ROOT/usr/lib64/pm-utils/sleep.d/
|
||||
mkdir -p $RPM_BUILD_ROOT/usr/lib/systemd/system
|
||||
cp pm-utils/qubes-suspend.service $RPM_BUILD_ROOT/usr/lib/systemd/system/
|
||||
@ -212,7 +211,6 @@ chmod -x /etc/grub.d/10_linux
|
||||
/usr/lib/qubes/qfile-dom0-agent
|
||||
# pm-utils
|
||||
/usr/lib64/pm-utils/sleep.d/01qubes-sync-vms-clock
|
||||
/usr/lib64/pm-utils/sleep.d/51qubes-suspend-netvm
|
||||
/usr/lib64/pm-utils/sleep.d/52qubes-pause-vms
|
||||
/usr/lib/systemd/system/qubes-suspend.service
|
||||
# Others
|
||||
|
Loading…
Reference in New Issue
Block a user