Read ro.boot.hypervisor.vm_dtbo_idx while writing dtbo am: a0d553b55a
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Virtualization/+/2719235
Change-Id: I5101971e2fcf3e4f6e8f7a6b6767c6c24c3ed61c
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/virtualizationservice/vfio_handler/src/aidl.rs b/virtualizationservice/vfio_handler/src/aidl.rs
index 15acfb8..bb9faf1 100644
--- a/virtualizationservice/vfio_handler/src/aidl.rs
+++ b/virtualizationservice/vfio_handler/src/aidl.rs
@@ -288,8 +288,15 @@
.or_service_specific_exception(-1)?;
let dt_table_header = get_dt_table_header(&mut dtbo_img)?;
- // TODO(b/296799016): Use vm_dtbo_idx from bootconfig.
- let vm_dtbo_idx = 20;
+ let vm_dtbo_idx = system_properties::read("ro.boot.hypervisor.vm_dtbo_idx")
+ .context("Failed to read vm_dtbo_idx")
+ .or_service_specific_exception(-1)?
+ .ok_or_else(|| anyhow!("vm_dtbo_idx is none"))
+ .or_service_specific_exception(-1)?;
+ let vm_dtbo_idx = vm_dtbo_idx
+ .parse()
+ .context("vm_dtbo_idx is not an integer")
+ .or_service_specific_exception(-1)?;
let dt_table_entry = get_dt_table_entry(&mut dtbo_img, &dt_table_header, vm_dtbo_idx)?;
filter_dtbo_from_img(&mut dtbo_img, &dt_table_entry, dtbo_fd)?;
Ok(())