Take the 2-minute tour ×
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:

    /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.