Read ro.boot.hypervisor.vm_dtbo_idx while writing dtbo
Bug: 296799016
Test: adb shell /apex/com.android.virt/bin/vm run-microdroid --devices /sys/bus/platform/devices/16d00000.eh --protected
Change-Id: I76c754d8f39e198fd9a967497305d2e0cf532167
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(())