• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

NVIDIA / nvrc / 19144475043

06 Nov 2025 05:35PM UTC coverage: 36.62% (-1.5%) from 38.153%
19144475043

push

github

web-flow
Merge pull request #75 from zvonkok/address-soon-issues

refactor: address 'soon' issues from code analysis

0 of 42 new or added lines in 5 files covered. (0.0%)

2 existing lines in 2 files now uncovered.

286 of 781 relevant lines covered (36.62%)

0.6 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/attach.rs
1
// SPDX-License-Identifier: Apache-2.0
2
// Copyright (c) NVIDIA CORPORATION
3

4
use crate::daemon::Action;
5
use crate::kata_agent;
6
use crate::kmsg;
7
use crate::ndev;
8
use crate::nvrc::NVRC;
9
use log::{debug, error};
10
use nix::unistd::{fork, ForkResult};
11
use std::sync::mpsc;
12
use std::thread::sleep;
13
use std::time::Duration;
14

15
use anyhow::{Context, Result};
16

17
impl NVRC {
18
    pub fn cold_plug(&mut self) -> Result<()> {
×
19
        debug!("cold-plug mode");
×
20
        self.setup_gpu();
×
21
        match unsafe { fork() }.expect("fork cold-plug") {
×
22
            ForkResult::Parent { .. } => {
23
                kata_agent().context("kata-agent cold-plug parent")?;
×
24
            }
25
            ForkResult::Child => loop {
26
                sleep(Duration::from_secs(1));
×
27
                if let Err(e) = self.poll_syslog() {
×
28
                    error!("poll syslog: {e}");
×
29
                    break;
30
                }
31
            },
32
        }
33
        Ok(())
×
34
    }
35

36
    pub fn manage_daemons(&mut self, action: Action) -> Result<()> {
×
37
        for f in [
×
38
            NVRC::nvidia_persistenced,
39
            NVRC::nv_hostengine,
40
            NVRC::dcgm_exporter,
41
            NVRC::nv_fabricmanager,
42
        ] {
43
            f(self, action.clone())?;
×
44
        }
45
        Ok(())
×
46
    }
47

48
    pub fn hot_plug(&mut self) -> Result<()> {
×
49
        debug!("hot-plug mode");
×
50
        match unsafe { fork() }.expect("fork hot-plug") {
×
51
            ForkResult::Parent { .. } => {
52
                kata_agent().context("kata-agent hot-plug parent")?;
×
53
            }
54
            ForkResult::Child => {
55
                self.handle_hot_plug_events().context("hot-plug events")?;
×
56
            }
57
        }
58
        Ok(())
×
59
    }
60

61
    fn handle_hot_plug_events(&mut self) -> Result<()> {
×
62
        // Use bounded channel to prevent unbounded memory growth
63
        // Capacity of 100 should be sufficient for bursty hotplug events
NEW
64
        let (tx, rx) = mpsc::sync_channel::<&str>(100);
×
65

66
        ndev::udev(tx.clone());
×
67
        kmsg::watch_for_pattern("NVRM: Attempting to remove device", tx.clone());
×
68

69
        if let Err(e) = self.watch_poll_syslog() {
×
70
            error!("poll syslog: {e}");
×
71
        }
72

73
        for ev in rx {
×
74
            debug!("event: {ev}");
×
75
            match ev {
76
                "hot-plug" => {
×
77
                    self.get_nvidia_devices(None)?;
×
78
                    self.setup_gpu();
×
79
                }
80
                "hot-unplug" => {
×
81
                    self.manage_daemons(Action::Stop)?;
×
82
                    sleep(Duration::from_millis(3000));
×
83
                    self.get_nvidia_devices(None)?;
×
84
                    if !self.nvidia_devices.is_empty() {
×
85
                        self.manage_daemons(Action::Start)?;
×
86
                    }
87
                }
88
                _ => {}
89
            }
90
        }
91
        Ok(())
×
92
    }
93
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc