Skip to content

Commit dd5de0c

Browse files
authored
Merge pull request #137 from Dstack-TEE/gpu-include
teepod: Add gpu whitelist
2 parents ec4d1ff + b8b0310 commit dd5de0c

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

teepod/src/config.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,23 @@ pub struct GpuConfig {
111111
pub listing: Vec<String>,
112112
/// The PCI addresses to exclude from passthrough
113113
pub exclude: Vec<String>,
114+
/// The PCI addresses to include in passthrough
115+
pub include: Vec<String>,
114116
}
115117

116118
impl GpuConfig {
117119
pub(crate) fn list_devices(&self) -> Result<Vec<Device>> {
118120
let devices = lspci_filtered(|dev| {
119-
self.listing.contains(&dev.full_product_id()) && !self.exclude.contains(&dev.slot)
121+
if !self.listing.contains(&dev.full_product_id()) {
122+
return false;
123+
}
124+
if self.exclude.contains(&dev.slot) {
125+
return false;
126+
}
127+
if !self.include.is_empty() && !self.include.contains(&dev.slot) {
128+
return false;
129+
}
130+
true
120131
})
121132
.context("Failed to list GPU devices")?;
122133

teepod/teepod.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ enabled = false
4545
listing = ["10de:2335"]
4646
# The PCI addresses of the cards to exclude
4747
exclude = []
48+
# The PCI addresses of the cards to include
49+
include = []
4850

4951
[gateway]
5052
base_domain = "localhost"

0 commit comments

Comments
 (0)