Add --enable-earlycon option to vm tool

This should make it easier to debug issues that occur before
virtio_console is available.

The code is guarded by the new RELEASE_AVF_IMPROVE_DEBUGGABLE_VMS
trunk-stable flag. This patch also guards the corresponding change in
pvmfw with the same flag just for the sake of consistency.

This is effectively a relanding of
ec68eaf6e8ba07cf400cdc33501cdd1a85dfe665 with a minor fix to avoid build
breakage.

Test: vm run-microdroid --protected --enable-earlycon --debug full
Test: vm run-microdroid --protected --enable-earlycon --debug none
Test: atest MicrodroidTests
Change-Id: Ic01b35a633456d2fc202374c10da1e22a83ee23d
diff --git a/android/virtmgr/src/aidl.rs b/android/virtmgr/src/aidl.rs
index 7a357f3..5355c19 100644
--- a/android/virtmgr/src/aidl.rs
+++ b/android/virtmgr/src/aidl.rs
@@ -989,6 +989,10 @@
 
         vm_config.devices.clone_from(&custom_config.devices);
         vm_config.networkSupported = custom_config.networkSupported;
+
+        for param in custom_config.extraKernelCmdlineParams.iter() {
+            append_kernel_param(param, &mut vm_config);
+        }
     }
 
     if config.memoryMib > 0 {
@@ -1541,6 +1545,17 @@
     Ok(())
 }
 
+fn check_no_extra_kernel_cmdline_params(config: &VirtualMachineConfig) -> binder::Result<()> {
+    let VirtualMachineConfig::AppConfig(config) = config else { return Ok(()) };
+    if let Some(custom_config) = &config.customConfig {
+        if !custom_config.extraKernelCmdlineParams.is_empty() {
+            return Err(anyhow!("debuggable_vms_improvements feature is disabled"))
+                .or_binder_exception(ExceptionCode::UNSUPPORTED_OPERATION);
+        }
+    }
+    Ok(())
+}
+
 fn check_protected_vm_is_supported() -> binder::Result<()> {
     let is_pvm_supported =
         hypervisor_props::is_protected_vm_supported().or_service_specific_exception(-1)?;
@@ -1562,6 +1577,9 @@
     if !cfg!(multi_tenant) {
         check_no_extra_apks(config)?;
     }
+    if !cfg!(debuggable_vms_improvements) {
+        check_no_extra_kernel_cmdline_params(config)?;
+    }
     Ok(())
 }