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

_______________________________________________
libvirt-users mailing list
libvirt-users@redhat.com
https://www.redhat.com/mailman/listinfo/libvirt-users

Reply via email to