Flag guard the code related to the vendor modules feature
The feature is guarded by the RELEASE_AVF_ENABLE_VENDOR_MODULES flag. On
the virtmgr side the flag-guard check is done in the create_vm_internal
function. On the vm binary side the related flags (--vendor, --kernel)
are only enabled if the RELEASE_AVF_ENABLE_VENDOR_MODULES flag is
enabled.
Additionally the vendor modules related tests in MicrodroidTests now run
conditionally depending on the result of the
`isFeatureEnabled(FEATURE_VENDOR_MODULES)` call.
Bug: 298007909
Test: atest MicrodroidTests
Change-Id: I1467194c802720601a10d0a760a8f1d7ce134037
diff --git a/vm/src/main.rs b/vm/src/main.rs
index 4c44496..e133b8b 100644
--- a/vm/src/main.rs
+++ b/vm/src/main.rs
@@ -98,10 +98,12 @@
storage_size: Option<u64>,
/// Path to custom kernel image to use when booting Microdroid.
+ #[cfg(vendor_modules)]
#[arg(long)]
kernel: Option<PathBuf>,
/// Path to disk image containing vendor-specific modules.
+ #[cfg(vendor_modules)]
#[arg(long)]
vendor: Option<PathBuf>,
@@ -110,6 +112,29 @@
devices: Vec<PathBuf>,
}
+impl MicrodroidConfig {
+ #[cfg(vendor_modules)]
+ fn kernel(&self) -> &Option<PathBuf> {
+ &self.kernel
+ }
+
+ #[cfg(not(vendor_modules))]
+ fn kernel(&self) -> Option<PathBuf> {
+ None
+ }
+
+ #[cfg(vendor_modules)]
+ fn vendor(&self) -> &Option<PathBuf> {
+ &self.vendor
+ }
+
+ #[cfg(not(vendor_modules))]
+ #[inline(always)]
+ fn vendor(&self) -> Option<PathBuf> {
+ None
+ }
+}
+
#[derive(Args)]
/// Flags for the run_app subcommand
pub struct RunAppConfig {