On Thu, Sep 10, 2026 at 04:51:38PM -0600, Jim Fehlig via Devel wrote:
> From: Jim Fehlig <[email protected]>
> 
> When a guest shuts down gracefully but its QEMU process takes a long
> time to cleanup and exit, virProcessKillPainfullyDelay() (used by
> qemuProcessKill()) times out and returns failure. This causes
> qemuProcessBeginStopJob() to fail in processMonitorEOFEvent(), which
> returns early without ever calling qemuProcessStop(), virDomainAuditStop()
> or queuing the VIR_DOMAIN_EVENT_STOPPED lifecycle event.
> 
> In this case, qemuProcessKill() falls back to asynchronously monitoring
> the QEMU process via a pidfd. Once the process is finally confirmed to
> have exited, QEMU_PROCESS_EVENT_SHUTDOWN_COMPLETED is submitted and
> handled by processShutdownCompletedEvent(). That function does complete
> the stop by calling qemuProcessStop() and qemuDomainRemoveInactive(),
> but it never generates the audit record or the lifecycle event, since that
> logic lived only in processMonitorEOFEvent(). Management apps relying on
> the VIR_DOMAIN_EVENT_STOPPED event, or on the audit log, never learn that
> the domain actually stopped.
> 
> Fix this by factoring the reason-detection, qemuProcessStop(), audit and
> lifecycle event logic out of processMonitorEOFEvent() into a new helper,
> qemuProcessFinishStop(), and call it from both processMonitorEOFEvent()
> and processShutdownCompletedEvent(). This ensures the audit record and
> lifecycle event are always generated once the QEMU process has exited,
> regardless of which path detected it.
> 
> Signed-off-by: Jim Fehlig <[email protected]>
> ---
>  src/qemu/qemu_driver.c | 61 +++++++++++++++++++++++++-----------------
>  1 file changed, 36 insertions(+), 25 deletions(-)

Reviewed-by: Daniel P. Berrangé <[email protected]>


With regards,
Daniel
-- 
|: https://berrange.com       ~~        https://hachyderm.io/@berrange :|
|: https://libvirt.org          ~~          https://entangle-photo.org :|
|: https://pixelfed.art/berrange   ~~    https://fstop138.berrange.com :|

Reply via email to