Managing QEMU/Libvirt hook scripts

Hooks are useful tools for managing your QEMU/Libvirt VMs. Details can be found at its website.

After you setting up hooks script for the QEMU guest in the file /etc/libvirt/hoos/qemu, you have to restart the livbvertd.service to make it take effect, via sudo systemctl restart libvirtd.service. This can be painful when you have multiple VMs to manage and configure. Therefore the libvirt-hooks management tool come to rescure.

Managing QEMU/Libvirt hook scirpts

The management script can be found at its github repo. After downloading it, you should place it at /et/libvrit/hooks/ and create the qemu.d folder at the same location.

From now on, you can have as many scripts as you want to different stage of different VMs. You just to make user the scripts are placed in the following folder structure

/etc/libvirt/hooks
├── qemu
└── qemu.d
    └── <vm_name>
        ├── prepare
        │   └── begin
        ├── release
        │   └── end
        └── stopped
            └── end

In each begin or end folder, there can be multiple scripts. Just to make sure the start with #!/bin/bash or #!/bin/python. Also, remember to add EXECUTABLE attribute to your scripts.

Chao Cheng
Chao Cheng
Statistician

My research interests include applied statistics and machine learning.

Related