Is it possible through some hook or callback mechanism for my script or executable running on the host to learn that libvirt is about to or very recently has sent a command for a guest to shut itself down?

I'm not trying to catch the case that the guest has decided to shut down on its own--I'm trying to catch the case that libvirt has decided to ask a guest to shut itself down.

I'm trying to do this so that my script or executable can automatically send a shutdown command "on the side" via SSH to a couple macOS guests that don't respond to ACPI commands and can't run the libvirt guest agent.

I've found script hook and API callback mechanisms that will inform me after guests have shut down, but can't figure out a trick to be informed of an attempt to shut a guest down.

I'm running libvirt under Slackware, but an answer regarding any host platform might be of value. Thanks!

  • 1
    You have already found the only hooks that exist! Jun 15, 2019 at 3:13
  • I am not a lawyer, but if Slackware is the hypervisor a macOS guest is probably against Apple's software license agreement. Jun 15, 2019 at 14:13

1 Answer 1


There's no hook for the graceful shutdown from libvirt's POV. The only real "hook" is is the QEMU guest agent. If that does not work for macOS, then the QEMU community would certainly welcome any patches to improve it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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