On 08/21/2014 06:11 AM, Michal Witanowski wrote:
Hi all,
Is there any possibility (using libvirt C API or whatever else) to
"propagate" shutdown events (reboot, halt, power off) to a host? The API
seems to lack this functionality - there exists function
virConnectDomainEventRegisterAny, but the virDomainEventStoppedDetailType
enum does not distinguish between these 3 different situations.
In the host, it's possible to register a domain lifecycle callback with
virConnectDomainEventRegisterAny(), and then if that callback is
triggered because the guest shut down, the host can take action such as
requesting a host shutdown. You'd have to supply the callback that does
this (it would be a security issue if a guest action could shut down the
host by default, without the use of a callback installed specifically
for this reason).
Moreover, while rebooting a machine, an additional argument can be passed to
reboot() syscall, which will be used by bootloader during the startup.
Ideally, when calling e.g. "reboot recovery" inside an lxc container I'd
like to be informed (inside host) that "reboot" was called with
"recovery"
as additional argument, so I can take appropriate actions.
Right now, this level of detail is not wired up. However, the callback
signature does support a reason field, so you are welcome to write a
libvirt patch that adds a new reason field and figures how to wire a
guest recovery reboot into reporting a different reason than the default.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library
http://libvirt.org