[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [vfio-users] Preventing host from going into sleep



The thing is that I want my computer to be able to go to sleep at the press of a button *unless* I'm running a VM. Systemd-inhibit does exactly what a want here, complete with a warning and an override prompt, but I haven't managed to get it to communicate properly with the system dbus when it's being launched by libvirt.

- Nicolas


On 2016-06-22 12:42, Laszlo Ersek wrote:
On 06/22/16 07:01, Nicolas Roy-Renaud wrote:
I've had my fair share of lockups because I forgot to turn off my VM
before putting my host to sleep, and I've started looking into some sort
of lock to prevent that kind of mistake. Normally, I'd use something
like `systemd-inhibit
<https://www.freedesktop.org/software/systemd/man/systemd-inhibit.html>`
to do that, except the calls libvirt makes to its hook scripts are
self-contained while sysd-inhibit is completely synchroneous (you use it
just like `time`). I've looked into using the underlying dbus calls
instead, and it appears that since Inhibit()
<https://www.freedesktop.org/wiki/Software/systemd/inhibit/> returns a
file descriptor which expires as soon as its owner is closed, I can't
just lock it before the VM starts and close it when it stops.

By the looks of it, I can't write a wrapper script for qemu-system
either since libvirt doesn't launch it with the same capabilities as a
regular user, and the dbus calls coming from sysd-inhibit fail.

I can't seem to find a simple solution to that issue, which is a pretty
big deal considering it's not something that libvirt supports on its own
(unless I've missed something). What would you all reccomend?
man logind.conf

Locate all settings / actions related to S3 suspend, and disable them in
your logind.conf (possible pathnames are listed in the manual page).

Personally I hate when my laptop suspends as soon as I close the lid (->
another sign of the desktop mentality: "if I'm not looking, nothing can
be happening!"). I disabled it with the following setting in
"/etc/systemd/logind.conf":

HandleLidSwitch=ignore

I trust if you set some more actions to "ignore", they'll do what you want.

HTH
Laszlo


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]