Daniel P. Berrange wrote:
On Mon, Mar 28, 2016 at 10:27:18AM +0300, Roman Bogorodskiy wrote:
> Bhyve supports ACPI shutdown by issuing SIGTERM signal to the bhyve
> process. Add the bhyveDomainShutdown() function and
> virBhyveProcessShutdown() helper function that just sends SIGTERM to
> VM's bhyve process. If a guest supports ACPI shutdown then process
> will be terminated and this event will be noticed by the bhyve monitor
> code that will handle setting proper status and clean up VM's resources.
>
> Also, remove a warning in domainDestroy in case if
> virProcessKillPainfully() returns 1, meaning that it killed process
> using SIGKILL. This behavior should be expected when using 'destroy'.
Hmm, so destroy is supposed to be equivalent to physically removing
the power plug. The existing code is calling virProcessShutdownPainfully
which starts by sending SIGTERM and then switches to SIGKILL. So this
means that your virDomainDestroy implementation is mistakenly trying todo
a graceful shutdown initially and then switching to hard shutdown after a
bit of a delay.
Indeed, you're right. Probably doesn't make practical difference due to
timeout being quite low, but makes no sense to wait. Will fix.
Has bhyve always used SIGTERM to trigger ACPI shutdown, or is this a
recent addition ? I would tend to suggest we need to go straight to
SIGKILL for virDomainDestroy to avoid doing ACPI shutdown when we don't
want it.
It was actually added back in the end of 2013, so it was in -CURRENT for
quite some time already. It's also available in 10.1, the earliest
supported version [1] of the 10.x branch. It's not in 10.0 though.
It is kind of a shame they used SIGTERM for triggering ACPI imho but
oh well.
Agreed, it doesn't seem very flexible. At least I don't see a way how to
probe if this feature is supported by the given bhyve binary and how to
check if the command was successful or not (except relying on the
libvirt's bhyve/bhyve_monitor.c code to detect process termination).
1:
https://www.freebsd.org/security/security.html#sup
Roman Bogorodskiy