Create full VM DTBO only once under /data/misc/virtualizationservice
Bug: 297103622
Test: adb shell /apex/com.android.virt/bin/vm run-microdroid --devices /sys/bus/platform/devices/16d00000.eh --protected
Change-Id: I4a6e7b7928edb93b6707202a9cc205fcf3994444
diff --git a/virtualizationmanager/src/aidl.rs b/virtualizationmanager/src/aidl.rs
index f5f2718..fa99c63 100644
--- a/virtualizationmanager/src/aidl.rs
+++ b/virtualizationmanager/src/aidl.rs
@@ -435,7 +435,7 @@
}
};
- let devices_dtbo = if !config.devices.is_empty() {
+ if !config.devices.is_empty() {
let mut set = HashSet::new();
for device in config.devices.iter() {
let path = canonicalize(device)
@@ -446,30 +446,8 @@
.or_binder_exception(ExceptionCode::ILLEGAL_ARGUMENT);
}
}
- 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
- };
+ GLOBAL_SERVICE.bindDevicesToVfioDriver(&config.devices)?;
+ }
// Actually start the VM.
let crosvm_config = CrosvmConfig {
@@ -495,7 +473,6 @@
detect_hangup: is_app_config,
gdb_port,
vfio_devices: config.devices.iter().map(PathBuf::from).collect(),
- devices_dtbo,
};
let instance = Arc::new(
VmInstance::new(
diff --git a/virtualizationmanager/src/crosvm.rs b/virtualizationmanager/src/crosvm.rs
index 6372fa8..77dd76f 100644
--- a/virtualizationmanager/src/crosvm.rs
+++ b/virtualizationmanager/src/crosvm.rs
@@ -116,7 +116,6 @@
pub detect_hangup: bool,
pub gdb_port: Option<NonZeroU16>,
pub vfio_devices: Vec<PathBuf>,
- pub devices_dtbo: Option<File>,
}
/// A disk image to pass to crosvm for a VM.
@@ -719,9 +718,7 @@
for device in &config.vfio_devices {
command.arg(vfio_argument_for_platform_device(device)?);
}
- if let Some(_dtbo) = &config.devices_dtbo {
- // TODO(b/291192693): add dtbo to command line
- }
+ // TODO(b/291192693): add dtbo to command line when assigned device is not empty.
Ok(())
}