Skip to content

Commit c0eba05

Browse files
committed
teepod: Release GPU for exited instances
1 parent f9ade19 commit c0eba05

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

teepod/src/app.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,10 @@ impl App {
485485
}
486486

487487
let pci_devices = self.config.cvm.gpu.list_devices()?;
488+
let used_slots = pci_devices
489+
.iter()
490+
.map(|d| d.slot.clone())
491+
.collect::<HashSet<_>>();
488492
let mut state = self.lock();
489493
state.gpu_pool.iter_mut().for_each(|gpu| {
490494
gpu.pci_in_use = false;
@@ -505,7 +509,13 @@ impl App {
505509
if vm.config.manifest.gpus.is_empty() {
506510
continue;
507511
}
508-
allocated_devices.extend(vm.state.devices.iter().cloned());
512+
allocated_devices.extend(
513+
vm.state
514+
.devices
515+
.iter()
516+
.filter(|slot| used_slots.contains(*slot))
517+
.cloned(),
518+
);
509519
}
510520
for gpu in state.gpu_pool.iter_mut() {
511521
if allocated_devices.contains(&gpu.slot) {

0 commit comments

Comments
 (0)