2011-03-29 12:20:50 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
. "${PM_FUNCTIONS}"
|
|
|
|
|
2011-03-30 22:29:57 +02:00
|
|
|
get_running_netvms() {
|
|
|
|
# Actually get running VMs with PCI devices attached
|
2011-06-01 23:44:06 +02:00
|
|
|
RUNNING_VMS=`xl list | tail -n +3 | cut -f 1 -d " "`
|
2011-03-30 22:29:57 +02:00
|
|
|
RUNNING_NETVMS=""
|
|
|
|
for VM in $RUNNING_VMS; do
|
2011-06-01 23:44:06 +02:00
|
|
|
if [ -n "`xl pci-list $VM|tail -n +2`" ]; then
|
2011-03-30 22:29:57 +02:00
|
|
|
echo "$VM"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2011-03-29 12:20:50 +02:00
|
|
|
suspend_net()
|
|
|
|
{
|
2011-03-30 22:29:57 +02:00
|
|
|
for VM in `get_running_netvms`; do
|
2012-07-13 14:42:54 +02:00
|
|
|
qvm-run -u root --pass-io $VM 'QUBESRPC qubes.SuspendPre dom0'
|
2011-03-30 22:29:57 +02:00
|
|
|
done
|
2011-03-29 12:22:31 +02:00
|
|
|
# Ignore exit status from netvm...
|
|
|
|
return 0
|
2011-03-29 12:20:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
resume_net()
|
|
|
|
{
|
2011-03-30 22:29:57 +02:00
|
|
|
for VM in `get_running_netvms`; do
|
2012-07-13 14:42:54 +02:00
|
|
|
qvm-run -u root --pass-io $VM 'QUBESRPC qubes.SuspendPost dom0'
|
2011-03-30 22:29:57 +02:00
|
|
|
done
|
2011-03-29 12:22:31 +02:00
|
|
|
# Ignore exit status from netvm...
|
|
|
|
return 0
|
2011-03-29 12:20:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
resume) resume_net ;;
|
|
|
|
suspend) suspend_net ;;
|
|
|
|
*) exit 0 ;;
|
|
|
|
esac
|