Skip to content

Commit 257529a

Browse files
committed
fix(hypervisor): don't log a killed-orphan warning for a just-stopped VM
DeleteAll takes one /proc snapshot up front, then per VM force-stops the process and scans that snapshot for leftover VMMs. A force-rm of a running VM therefore re-found the pid it had just terminated (stale snapshot) and logged 'killed orphan VMM' on every delete, even though TerminateProcess was a no-op on the already-dead pid. Gate the terminate+warn on a live IsProcessAlive check so only a genuinely surviving VMM is reported.
1 parent bfe361e commit 257529a

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

hypervisor/stop.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@ func (b *Backend) DeleteAll(ctx context.Context, refs []string, force bool, stop
9797
return fmt.Errorf("refuse delete: api socket %s still responsive (suspected orphan vmm; kill the vmm process then retry)", sockPath)
9898
}
9999
for _, pid := range procScan.Find(sockPath) {
100+
// procScan is a pre-stopOne snapshot: a just-force-stopped VM is already gone.
101+
// Only a still-live match is a real orphan worth killing and logging.
102+
if !utils.IsProcessAlive(pid) {
103+
continue
104+
}
100105
if termErr := utils.TerminateProcess(ctx, pid, b.Conf.BinaryName(), sockPath, b.Conf.TerminateGracePeriod()); termErr != nil {
101106
return fmt.Errorf("terminate orphan VMM pid=%d for VM %s: %w", pid, id, termErr)
102107
}

0 commit comments

Comments
 (0)