Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I am running KVM as virtualization engine.

Is there a way to make QEMU/libvirt run a script on the host when a guest is shutdown from within (shutdown -h now)?

I want to be able to run some custom clean-up tasks when a guest is stopped.

share|improve this question

1 Answer 1

up vote 3 down vote accepted

libvirt provides the possibility to use hooks for specific system management:

At present, there are three hook scripts that can be called:


    Executed when the libvirt daemon is started, stopped, or reloads its configuration


    Executed when a QEMU guest is started, stopped, or migrated


    Executed when an LXC guest is started or stopped
share|improve this answer
Thank you! This is what I was looking for. – Daniele Testa Jul 15 '13 at 10:54

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.