Skip to content

Commit 28a6bc3

Browse files
author
Rafael Garcia
committed
fix(devices): prevent false positive warnings for instances without GPU devices
detectSuspiciousVMMProcesses was using ListAllInstanceDevices to build the set of known running instances, but that method only returns instances with devices attached. This caused legitimate cloud-hypervisor processes for instances without GPU passthrough to be incorrectly flagged as 'untracked' with misleading advice to run gpu-reset.sh. Fix: Call IsInstanceRunning directly for each discovered process instead of pre-building a map from ListAllInstanceDevices. This correctly identifies all running instances regardless of device attachment.
1 parent 712e328 commit 28a6bc3

File tree

1 file changed

+6
-15
lines changed

1 file changed

+6
-15
lines changed

lib/devices/manager.go

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -669,18 +669,6 @@ func (m *manager) detectSuspiciousVMMProcesses(ctx context.Context, stats *recon
669669
return
670670
}
671671

672-
// Get list of running instance sockets if we have liveness checker
673-
var runningInstances map[string]bool
674-
if m.livenessChecker != nil {
675-
instanceDevices := m.livenessChecker.ListAllInstanceDevices(ctx)
676-
runningInstances = make(map[string]bool)
677-
for instanceID := range instanceDevices {
678-
if m.livenessChecker.IsInstanceRunning(ctx, instanceID) {
679-
runningInstances[instanceID] = true
680-
}
681-
}
682-
}
683-
684672
for _, line := range lines {
685673
if line == "" {
686674
continue
@@ -697,17 +685,20 @@ func (m *manager) detectSuspiciousVMMProcesses(ctx context.Context, stats *recon
697685
}
698686
}
699687

700-
// Check if this socket path matches any instance directory
688+
// Check if this socket path matches any running instance
689+
// We use IsInstanceRunning directly rather than ListAllInstanceDevices because
690+
// the latter only returns instances with devices attached, which would cause
691+
// false positives for instances without GPU passthrough.
701692
matched := false
702-
if socketPath != "" {
693+
if socketPath != "" && m.livenessChecker != nil {
703694
// Socket path is typically like /var/lib/hypeman/guests/<id>/ch.sock
704695
// Try to extract instance ID
705696
if strings.Contains(socketPath, "/guests/") {
706697
pathParts := strings.Split(socketPath, "/guests/")
707698
if len(pathParts) > 1 {
708699
instancePath := pathParts[1]
709700
instanceID := strings.Split(instancePath, "/")[0]
710-
if runningInstances != nil && runningInstances[instanceID] {
701+
if m.livenessChecker.IsInstanceRunning(ctx, instanceID) {
711702
matched = true
712703
}
713704
}

0 commit comments

Comments
 (0)