[libvirt-users] Guest startup process blocks if a hook's child process is still running (i.e : after forking)

Nicolas Roy-Renaud nicolas.roy-renaud.1 at ens.etsmtl.ca
Tue Nov 8 13:06:21 UTC 2016


I'm still having this issue and I'd really like to know if there's 
something about hooks I'm missing. I've seen a number of people with the 
same issue on vfio-users before and it'f something I'd really like to 
find a fix for.

- Nicolas


On 10/23/16 17:24, Nicolas Roy-Renaud wrote:
> I've been having issues with KVM lately where I sometimes put my host 
> into sleep while a guest is still running, which prevents it from 
> waking up properly. This is somewhat expected due to my setup, but I 
> have mistakenly done this more than once and could use a workaround to 
> stop this from happening.
>
> So I've been trying to setup a libvirt hook to fork an instance of 
> systemd-inhibit when the start hook is called and keep it running 
> until the shutdown hook is called. This seems to work well when I run 
> the hook script in a normal bash shell, but running it through libvirt 
> simply blocks the starting process until systemd-inhibit quits.
>
> Here's the script :
>
> LOCK_FILE="/tmp/vfio-lock-$OBJECT"
>
> if [ "$OPERATION" == "start" ]; then
>     (
>         touch "$LOCK_FILE";
>         systemd-inhibit --what="sleep" \
>         --who="libvirt" \
>         --mode="block" \
>         inotifywait -qq -e delete "$LOCK_FILE"
>     ) & disown $!
>     exit
> fi
>
> if [ "$OPERATION" == "shutdown" ]; then
>         rm "$LOCK_FILE"
> fi
>
> Is there some way to make it so libvirt sees the hook script exiting 
> and carries on with the rest of its guest startup process even after a 
> process fork or would that require changes in the internal hook 
> handling functions?
>
> - Nicolas




More information about the libvirt-users mailing list