Set primary kernel in manifest and allow preloading.

The primary kernel was previously hard-coded as `vmlinuz` but the
manifest allows more flexibility. If the kernel file for any VM is not
specified, it is assumed that the image has been preloaded into memory.

The loading of the primary and secondaries are becoming increasingly
similar and will continue to do so.

Change-Id: I34f134d8a4d32e8ac92e142d3636902d52ad86ec
diff --git a/build/image/generate_initrd.py b/build/image/generate_initrd.py
index 38ce19c..4d8f281 100644
--- a/build/image/generate_initrd.py
+++ b/build/image/generate_initrd.py
@@ -29,6 +29,7 @@
 
 def Main():
     parser = argparse.ArgumentParser()
+    parser.add_argument("--primary_name", required=True)
     parser.add_argument("--primary_vm", required=True)
     parser.add_argument("--primary_vm_initrd")
     parser.add_argument(
@@ -39,17 +40,19 @@
     parser.add_argument("--staging", required=True)
     parser.add_argument("--output", required=True)
     args = parser.parse_args()
-    staged_files = ["vmlinuz", "initrd.img"]
+    staged_files = [args.primary_name, "initrd.img"]
 
     # Create staging folder if needed.
     if not os.path.isdir(args.staging):
         os.makedirs(args.staging)
 
     # Prepare the primary VM image.
-    shutil.copyfile(args.primary_vm, os.path.join(args.staging, "vmlinuz"))
+    shutil.copyfile(args.primary_vm,
+                    os.path.join(args.staging, args.primary_name))
     # Prepare the primary VM's initrd.
     if args.primary_vm_initrd:
-        shutil.copyfile(args.primary_vm_initrd, os.path.join(args.staging, "initrd.img"))
+        shutil.copyfile(args.primary_vm_initrd,
+                        os.path.join(args.staging, "initrd.img"))
     else:
         open(os.path.join(args.staging, "initrd.img"), "w").close()
     # Prepare the secondary VMs.
diff --git a/build/image/image.gni b/build/image/image.gni
index 6865f87..2c29f4a 100644
--- a/build/image/image.gni
+++ b/build/image/image.gni
@@ -173,6 +173,8 @@
 
 # Build the initial RAM disk for the hypervisor.
 template("initrd") {
+  assert(defined(invoker.primary_name),
+         "initrd() must specify a \"primary_name\" value")
   assert(defined(invoker.primary_vm),
          "initrd() must specify a \"primary_vm\" value")
 
@@ -203,6 +205,8 @@
       invoker.primary_vm,
     ]
     args = [
+      "--primary_name",
+      invoker.primary_name,
       "--primary_vm",
       rebase_path(primary_vm_image),
       "--staging",