Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
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:

    /etc/libvirt/hooks/daemon

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

    /etc/libvirt/hooks/qemu

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

    /etc/libvirt/hooks/lxc

    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

 
discard

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.