Use regular file for VM DTBO
Bug: 287379025
Test: adb shell /apex/com.android.virt/bin/vm run-microdroid \
--protected --mem 512 --devices \
/sys/bus/platform/devices/16d00000.eh
Change-Id: Iad237c86ff2d1eca89c03d1b399f52877f24fa9a
diff --git a/virtualizationmanager/src/aidl.rs b/virtualizationmanager/src/aidl.rs
index 15e5407..91bd60b 100644
--- a/virtualizationmanager/src/aidl.rs
+++ b/virtualizationmanager/src/aidl.rs
@@ -474,7 +474,27 @@
));
}
}
- Some(clone_file(&GLOBAL_SERVICE.bindDevicesToVfioDriver(&config.devices)?)?)
+ let dtbo_path = temporary_directory.join("dtbo");
+ // open a writable file descriptor for vfio_handler
+ let dtbo = File::create(&dtbo_path).map_err(|e| {
+ error!("Failed to create VM DTBO file {dtbo_path:?}: {e:?}");
+ Status::new_service_specific_error_str(
+ -1,
+ Some(format!("Failed to create VM DTBO file {dtbo_path:?}: {e:?}")),
+ )
+ })?;
+ GLOBAL_SERVICE
+ .bindDevicesToVfioDriver(&config.devices, &ParcelFileDescriptor::new(dtbo))?;
+
+ // open (again) a readable file descriptor for crosvm
+ let dtbo = File::open(&dtbo_path).map_err(|e| {
+ error!("Failed to open VM DTBO file {dtbo_path:?}: {e:?}");
+ Status::new_service_specific_error_str(
+ -1,
+ Some(format!("Failed to open VM DTBO file {dtbo_path:?}: {e:?}")),
+ )
+ })?;
+ Some(dtbo)
} else {
None
};