Fix trivial device assignment bugs
1) unbind only when possible (if device is already unbound, we can't
unbind)
2) return eh device only when existing
Test: manual
Change-Id: I40b436ed74eca48688f9cd0d7fff3fa192b2eb05
diff --git a/virtualizationservice/src/aidl.rs b/virtualizationservice/src/aidl.rs
index 2e667d4..dab5e86 100644
--- a/virtualizationservice/src/aidl.rs
+++ b/virtualizationservice/src/aidl.rs
@@ -42,7 +42,7 @@
use std::io::{Read, Write};
use std::os::unix::fs::PermissionsExt;
use std::os::unix::raw::{pid_t, uid_t};
-use std::path::PathBuf;
+use std::path::{Path, PathBuf};
use std::sync::{Arc, Mutex, Weak};
use tombstoned_client::{DebuggerdDumpType, TombstonedConnection};
use vsock::{VsockListener, VsockStream};
@@ -177,10 +177,12 @@
check_use_custom_virtual_machine()?;
// TODO(b/291191362): read VM DTBO to find assignable devices.
- Ok(vec![AssignableDevice {
- kind: "eh".to_owned(),
- node: "/sys/bus/platform/devices/16d00000.eh".to_owned(),
- }])
+ let mut devices = Vec::new();
+ let eh_path = "/sys/bus/platform/devices/16d00000.eh";
+ if Path::new(eh_path).exists() {
+ devices.push(AssignableDevice { kind: "eh".to_owned(), node: eh_path.to_owned() });
+ }
+ Ok(devices)
}
fn bindDevicesToVfioDriver(