Revert "Boot VM without bootloader - using init ramdisk"

This reverts commit c700b84bbe41dae84583e64c142167b74ec54d17.

Test: N/A
Bug; 249462836

Change-Id: I26c96723fe5dc46c60bbb40738d5ca082726b45b
diff --git a/apex/Android.bp b/apex/Android.bp
index 52f4384..fade6c5 100644
--- a/apex/Android.bp
+++ b/apex/Android.bp
@@ -69,7 +69,6 @@
         "microdroid.json",
         "microdroid_bootloader",
         "microdroid_bootloader.avbpubkey",
-        "microdroid_kernel",
     ],
     file_contexts: ":com.android.virt-file_contexts",
     canned_fs_config: "canned_fs_config",
diff --git a/microdroid/Android.bp b/microdroid/Android.bp
index 1a9a217..7b28ad2 100644
--- a/microdroid/Android.bp
+++ b/microdroid/Android.bp
@@ -573,32 +573,3 @@
     name: "microdroid_bootconfig_normal_src",
     srcs: ["bootconfig.normal"],
 }
-
-prebuilt_etc {
-    name: "microdroid_kernel_unsigned",
-    src: "empty_kernel",
-    filename: "microdroid_kernel_unsigned",
-    arch: {
-        arm64: {
-            src: ":microdroid_kernel_prebuilts-5.15-arm64",
-        },
-        x86_64: {
-            src: ":microdroid_kernel_prebuilts-5.15-x86_64",
-        },
-    },
-}
-
-avb_add_hash_footer {
-    name: "microdroid_kernel_signed",
-    src: ":microdroid_kernel_unsigned",
-    filename: "microdroid_kernel",
-    partition_name: "bootloader",
-    private_key: ":microdroid_sign_key",
-    salt: bootloader_salt,
-}
-
-prebuilt_etc {
-    name: "microdroid_kernel",
-    src: ":microdroid_kernel_signed",
-    relative_install_path: "fs",
-}
diff --git a/microdroid/microdroid.json b/microdroid/microdroid.json
index 00cedc8..f02dcbf 100644
--- a/microdroid/microdroid.json
+++ b/microdroid/microdroid.json
@@ -1,9 +1,21 @@
 {
-  "kernel": "/apex/com.android.virt/etc/fs/microdroid_kernel",
+  "bootloader": "/apex/com.android.virt/etc/fs/microdroid_bootloader",
   "disks": [
     {
       "partitions": [
         {
+          "label": "boot_a",
+          "path": "/apex/com.android.virt/etc/fs/microdroid_boot.img"
+        },
+        {
+          "label": "init_boot_a",
+          "path": "/apex/com.android.virt/etc/fs/microdroid_init_boot.img"
+        },
+        {
+          "label": "vendor_boot_a",
+          "path": "/apex/com.android.virt/etc/fs/microdroid_vendor_boot.img"
+        },
+        {
           "label": "vbmeta_a",
           "path": "/apex/com.android.virt/etc/fs/microdroid_vbmeta.img"
         },
@@ -13,6 +25,16 @@
         }
       ],
       "writable": false
+    },
+    {
+      "partitions": [
+        {
+          "label": "uboot_env",
+          "path": "/apex/com.android.virt/etc/fs/uboot_env.img",
+          "writable": false
+        }
+      ],
+      "writable": true
     }
   ],
   "memory_mib": 256,
diff --git a/virtualizationservice/src/aidl.rs b/virtualizationservice/src/aidl.rs
index 15e798a..1eca9fe 100644
--- a/virtualizationservice/src/aidl.rs
+++ b/virtualizationservice/src/aidl.rs
@@ -632,7 +632,7 @@
     vm_config.numCpus = config.numCpus;
     vm_config.taskProfiles = config.taskProfiles.clone();
 
-    // Microdroid requires an additional init ramdisk & payload disk image
+    // Microdroid requires an additional payload disk image and the bootconfig partition.
     if os_name == "microdroid" {
         add_microdroid_images(
             config,
diff --git a/virtualizationservice/src/payload.rs b/virtualizationservice/src/payload.rs
index 06b9716..675ca50 100644
--- a/virtualizationservice/src/payload.rs
+++ b/virtualizationservice/src/payload.rs
@@ -360,21 +360,6 @@
     vm_payload_config: &VmPayloadConfig,
     vm_config: &mut VirtualMachineRawConfig,
 ) -> Result<()> {
-    let debug_suffix = match config.debugLevel {
-        DebugLevel::NONE => "normal",
-        DebugLevel::APP_ONLY => "app_debuggable",
-        DebugLevel::FULL => "full_debuggable",
-        _ => return Err(anyhow!("unsupported debug level: {:?}", config.debugLevel)),
-    };
-    let initrd = format!("/apex/com.android.virt/etc/microdroid_initrd_{}.img", debug_suffix);
-    vm_config.initrd = Some(open_parcel_file(Path::new(&initrd), false)?);
-
-    let instance_img = Partition {
-        label: "vm-instance".to_owned(),
-        image: Some(ParcelFileDescriptor::new(instance_file)),
-        writable: true,
-    };
-    vm_config.disks.push(DiskImage { image: None, partitions: vec![instance_img], writable: true });
     vm_config.disks.push(make_payload_disk(
         config,
         apk_file,
@@ -383,6 +368,34 @@
         temporary_directory,
     )?);
 
+    vm_config.disks[1].partitions.push(Partition {
+        label: "vbmeta".to_owned(),
+        image: Some(open_parcel_file(
+            Path::new("/apex/com.android.virt/etc/fs/microdroid_vbmeta_bootconfig.img"),
+            false,
+        )?),
+        writable: false,
+    });
+    let bootconfig_image = "/apex/com.android.virt/etc/fs/microdroid_bootconfig.".to_owned()
+        + match config.debugLevel {
+            DebugLevel::NONE => "normal",
+            DebugLevel::APP_ONLY => "app_debuggable",
+            DebugLevel::FULL => "full_debuggable",
+            _ => return Err(anyhow!("unsupported debug level: {:?}", config.debugLevel)),
+        };
+    vm_config.disks[1].partitions.push(Partition {
+        label: "bootconfig".to_owned(),
+        image: Some(open_parcel_file(Path::new(&bootconfig_image), false)?),
+        writable: false,
+    });
+
+    // instance image is at the second partition in the second disk.
+    vm_config.disks[1].partitions.push(Partition {
+        label: "vm-instance".to_owned(),
+        image: Some(ParcelFileDescriptor::new(instance_file)),
+        writable: true,
+    });
+
     Ok(())
 }