Consistent naming for kernel command line

Bug: 113128331
Test: run local
Change-Id: I3972b2f735cc1eda27e230bacfb7713956a937fd
diff --git a/host/commands/launch/boot_image_unpacker.cc b/host/commands/launch/boot_image_unpacker.cc
index adc6c5b..5558029 100644
--- a/host/commands/launch/boot_image_unpacker.cc
+++ b/host/commands/launch/boot_image_unpacker.cc
@@ -85,8 +85,8 @@
   return ret;
 }
 
-std::string BootImageUnpacker::kernel_command_line() const {
-  return kernel_command_line_;
+std::string BootImageUnpacker::kernel_cmdline() const {
+  return kernel_cmdline_;
 }
 
 bool BootImageUnpacker::ExtractKernelImage(const std::string& path) const {
diff --git a/host/commands/launch/boot_image_unpacker.h b/host/commands/launch/boot_image_unpacker.h
index 856c1bc..69fc7bd 100644
--- a/host/commands/launch/boot_image_unpacker.h
+++ b/host/commands/launch/boot_image_unpacker.h
@@ -33,7 +33,7 @@
 
   ~BootImageUnpacker() = default;
 
-  std::string kernel_command_line() const;
+  std::string kernel_cmdline() const;
 
   bool HasKernelImage() const { return kernel_image_size_ > 0; }
   bool HasRamdiskImage() const { return ramdisk_image_size_ > 0; }
@@ -50,7 +50,7 @@
                     uint32_t kernel_image_size, uint32_t kernel_image_offset,
                     uint32_t ramdisk_image_size, uint32_t ramdisk_image_offset)
       : boot_image_(boot_image),
-        kernel_command_line_(cmdline),
+        kernel_cmdline_(cmdline),
         kernel_image_size_(kernel_image_size),
         kernel_image_offset_(kernel_image_offset),
         ramdisk_image_size_(ramdisk_image_size),
@@ -58,7 +58,7 @@
 
   // Mutable because we only read from the fd, but do not modify its contents
   mutable SharedFD boot_image_;
-  std::string kernel_command_line_;
+  std::string kernel_cmdline_;
   // When buidling the boot image a particular page size is assumed, which may
   // not match the actual page size of the system.
   uint32_t kernel_image_size_;
diff --git a/host/commands/launch/main.cc b/host/commands/launch/main.cc
index 9f25caa..0ab494e 100644
--- a/host/commands/launch/main.cc
+++ b/host/commands/launch/main.cc
@@ -88,7 +88,7 @@
             "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, "",
+DEFINE_string(extra_kernel_cmdline, "",
               "Additional flags to put on the kernel command line");
 DEFINE_string(boot_image, "", "Location of cuttlefish boot image.");
 DEFINE_int32(memory_mb, 2048,
@@ -518,14 +518,15 @@
     }
   }
 
-  config->add_kernel_args(boot_image_unpacker.kernel_command_line());
+  config->add_kernel_cmdline(boot_image_unpacker.kernel_cmdline());
   if (!use_ramdisk) {
-    config->add_kernel_args("root=/dev/vda init=/init");
+    config->add_kernel_cmdline("root=/dev/vda init=/init");
   }
-  config->add_kernel_args(concat("androidboot.serialno=", FLAGS_serial_number));
-  config->add_kernel_args(concat("androidboot.lcd_density=", FLAGS_dpi));
-  if (FLAGS_extra_kernel_command_line.size()) {
-    config->add_kernel_args(FLAGS_extra_kernel_command_line);
+  config->add_kernel_cmdline(
+      concat("androidboot.serialno=", FLAGS_serial_number));
+  config->add_kernel_cmdline(concat("androidboot.lcd_density=", FLAGS_dpi));
+  if (FLAGS_extra_kernel_cmdline.size()) {
+    config->add_kernel_cmdline(FLAGS_extra_kernel_cmdline);
   }
 
   config->set_ramdisk_image_path(ramdisk_path);
diff --git a/host/libs/config/cuttlefish_config.cpp b/host/libs/config/cuttlefish_config.cpp
index 4721053..ffc9410 100644
--- a/host/libs/config/cuttlefish_config.cpp
+++ b/host/libs/config/cuttlefish_config.cpp
@@ -81,7 +81,7 @@
 
 const char* kKernelImagePath = "kernel_image_path";
 const char* kGdbFlag = "gdb_flag";
-const char* kKernelArgs = "kernel_args";
+const char* kKernelCmdline = "kernel_cmdline";
 const char* kRamdiskImagePath = "ramdisk_image_path";
 
 const char* kSystemImagePath = "system_image_path";
@@ -193,41 +193,43 @@
   SetPath(kGdbFlag, device);
 }
 
-std::set<std::string> CuttlefishConfig::kernel_args() const {
+std::set<std::string> CuttlefishConfig::kernel_cmdline() const {
   std::set<std::string> args_set;
-  auto args_json_obj = (*dictionary_)[kKernelArgs];
+  auto args_json_obj = (*dictionary_)[kKernelCmdline];
   std::transform(args_json_obj.begin(), args_json_obj.end(),
                  std::inserter(args_set, args_set.begin()),
                  [](const Json::Value& it) { return it.asString(); });
   return args_set;
 }
-void CuttlefishConfig::set_kernel_args(const std::set<std::string>& kernel_args) {
+void CuttlefishConfig::set_kernel_cmdline(
+    const std::set<std::string>& kernel_cmdline) {
   Json::Value args_json_obj(Json::arrayValue);
-  for (auto kernel_arg : kernel_args) {
-    args_json_obj.append(kernel_arg);
+  for (auto arg : kernel_cmdline) {
+    args_json_obj.append(arg);
   }
-  (*dictionary_)[kKernelArgs] = args_json_obj;
+  (*dictionary_)[kKernelCmdline] = args_json_obj;
 }
-void CuttlefishConfig::add_kernel_args(const std::set<std::string>& args) {
-  std::set<std::string> current_args = kernel_args();
-  for (auto arg : args) {
-    if (current_args.count(arg)) {
+void CuttlefishConfig::add_kernel_cmdline(
+    const std::set<std::string>& extra_args) {
+  std::set<std::string> cmdline = kernel_cmdline();
+  for (auto arg : extra_args) {
+    if (cmdline.count(arg)) {
       LOG(ERROR) << "Kernel argument " << arg << " is duplicated";
     }
-    current_args.insert(arg);
+    cmdline.insert(arg);
   }
-  set_kernel_args(current_args);
+  set_kernel_cmdline(cmdline);
 }
-void CuttlefishConfig::add_kernel_args(const std::string& kernel_args) {
-  std::stringstream args_stream(kernel_args);
-  std::set<std::string> kernel_args_set;
+void CuttlefishConfig::add_kernel_cmdline(const std::string& kernel_cmdline) {
+  std::stringstream args_stream(kernel_cmdline);
+  std::set<std::string> kernel_cmdline_set;
   using is_iter = std::istream_iterator<std::string>;
   std::copy(is_iter(args_stream), is_iter(),
-            std::inserter(kernel_args_set, kernel_args_set.begin()));
-  add_kernel_args(kernel_args_set);
+            std::inserter(kernel_cmdline_set, kernel_cmdline_set.begin()));
+  add_kernel_cmdline(kernel_cmdline_set);
 }
-std::string CuttlefishConfig::kernel_args_as_string() const {
-  auto args_set = kernel_args();
+std::string CuttlefishConfig::kernel_cmdline_as_string() const {
+  auto args_set = kernel_cmdline();
   std::stringstream output;
   std::copy(args_set.begin(), args_set.end(),
             std::ostream_iterator<std::string>(output, " "));
diff --git a/host/libs/config/cuttlefish_config.h b/host/libs/config/cuttlefish_config.h
index 21005a3..ed0a0a3 100644
--- a/host/libs/config/cuttlefish_config.h
+++ b/host/libs/config/cuttlefish_config.h
@@ -79,11 +79,11 @@
   std::string kernel_image_path() const;
   void set_kernel_image_path(const std::string& kernel_image_path);
 
-  std::set<std::string> kernel_args() const;
-  void set_kernel_args(const std::set<std::string>& kernel_args);
-  void add_kernel_args(const std::string& arg);
-  void add_kernel_args(const std::set<std::string>& kernel_args);
-  std::string kernel_args_as_string() const;
+  std::set<std::string> kernel_cmdline() const;
+  void set_kernel_cmdline(const std::set<std::string>& kernel_cmdline);
+  void add_kernel_cmdline(const std::string& arg);
+  void add_kernel_cmdline(const std::set<std::string>& kernel_cmdline);
+  std::string kernel_cmdline_as_string() const;
 
   std::string gdb_flag() const;
   void set_gdb_flag(const std::string& gdb);
diff --git a/host/libs/vm_manager/cf_qemu.sh b/host/libs/vm_manager/cf_qemu.sh
index 7316643..ee46ef2 100755
--- a/host/libs/vm_manager/cf_qemu.sh
+++ b/host/libs/vm_manager/cf_qemu.sh
@@ -52,7 +52,7 @@
     -no-shutdown
     -boot "strict=on"
     -kernel "${kernel_image_path:-${HOME}/kernel}"
-    -append "${kernel_args:-"loop.max_part=7 console=ttyS0 androidboot.console=ttyS1 androidboot.hardware=vsoc enforcing=0 audit=1 androidboot.selinux=permissive mac80211_hwsim.radios=0 security=selinux buildvariant=userdebug  androidboot.serialno=CUTTLEFISHCVD01 androidboot.lcd_density=160"}"
+    -append "${kernel_cmdline:-"loop.max_part=7 console=ttyS0 androidboot.console=ttyS1 androidboot.hardware=vsoc enforcing=0 audit=1 androidboot.selinux=permissive mac80211_hwsim.radios=0 security=selinux buildvariant=userdebug  androidboot.serialno=CUTTLEFISHCVD01 androidboot.lcd_density=160"}"
     -dtb "${dtb_path:-${HOME}/config/cuttlefish.dtb}"
     -device "piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2"
     -device "virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x4"
diff --git a/host/libs/vm_manager/libvirt_manager.cpp b/host/libs/vm_manager/libvirt_manager.cpp
index d6f545c..a331dc2 100644
--- a/host/libs/vm_manager/libvirt_manager.cpp
+++ b/host/libs/vm_manager/libvirt_manager.cpp
@@ -283,7 +283,8 @@
   ConfigureVMFeatures(root, {"acpi", "apic", "hap"});
   ConfigureOperatingSystem(root, config->kernel_image_path(),
                            config->ramdisk_image_path(),
-                           config->kernel_args_as_string(), config->dtb_path());
+                           config->kernel_cmdline_as_string(),
+                           config->dtb_path());
   auto qemu_options = ConfigureQEmuSpecificOptions(
       root, {"-chardev",
              concat("socket,path=", config->ivshmem_qemu_socket_path(),
diff --git a/host/libs/vm_manager/qemu_manager.cpp b/host/libs/vm_manager/qemu_manager.cpp
index 79dafdd..7d7d92b 100644
--- a/host/libs/vm_manager/qemu_manager.cpp
+++ b/host/libs/vm_manager/qemu_manager.cpp
@@ -67,7 +67,7 @@
   LogAndSetEnv("kernel_image_path", config->kernel_image_path());
   LogAndSetEnv("gdb_flag", config->gdb_flag());
   LogAndSetEnv("ramdisk_image_path", config->ramdisk_image_path());
-  LogAndSetEnv("kernel_args", config->kernel_args_as_string());
+  LogAndSetEnv("kernel_cmdline", config->kernel_cmdline_as_string());
   LogAndSetEnv("dtb_path", config->dtb_path());
   LogAndSetEnv("system_image_path", config->system_image_path());
   LogAndSetEnv("data_image_path", config->data_image_path());