Add a flag to allow the kernel path to be specified

Test: Local build and boot
Change-Id: Ic87acf1692b6122b7c1d1360394297d6cebadd7d
Merged-In: Ic87acf1692b6122b7c1d1360394297d6cebadd7d
(cherry picked from commit b8f4e0611e34decba238fe144b950bb873c9d207)
diff --git a/host/commands/launch/main.cc b/host/commands/launch/main.cc
index 30b890d..6ef18bb 100644
--- a/host/commands/launch/main.cc
+++ b/host/commands/launch/main.cc
@@ -77,6 +77,8 @@
             "Disable AppArmor security in libvirt. For debug only.");
 DEFINE_bool(disable_dac_security, false,
             "Disable DAC security in libvirt. For debug only.");
+DEFINE_string(kernel_path, "",
+	      "Path to the kernel. Overrides the one from the boot image");
 DEFINE_string(extra_kernel_command_line, "",
               "Additional flags to put on the kernel command line");
 DEFINE_string(boot_image, "", "Location of cuttlefish boot image.");
@@ -471,14 +473,16 @@
       return false;
     }
   }
-  if (boot_image_unpacker.HasKernelImage()) {
-    if (!boot_image_unpacker.ExtractKernelImage(config->kernel_image_path())) {
-      LOG(FATAL) << "Error extracting kernel from boot image";
+  if (!FLAGS_kernel_path.size()) {
+    if (boot_image_unpacker.HasKernelImage()) {
+      if (!boot_image_unpacker.ExtractKernelImage(config->kernel_image_path())) {
+        LOG(ERROR) << "Error extracting kernel from boot image";
+        return false;
+      }
+    } else {
+      LOG(ERROR) << "No kernel found on boot image";
       return false;
     }
-  } else {
-    LOG(FATAL) << "No kernel found on boot image";
-    return false;
   }
   return true;
 }
@@ -503,7 +507,11 @@
   config->set_y_res(FLAGS_y_res);
   config->set_refresh_rate_hz(FLAGS_refresh_rate_hz);
 
-  config->set_kernel_image_path(config->PerInstancePath("kernel"));
+  if (FLAGS_kernel_path.size()) {
+    config->set_kernel_image_path(FLAGS_kernel_path);
+  } else {
+    config->set_kernel_image_path(config->PerInstancePath("kernel"));
+  }
 
   auto ramdisk_path = config->PerInstancePath("ramdisk.img");
   bool use_ramdisk = boot_image_unpacker.HasRamdiskImage();