Merge "execute_capture_output -> RunWithManagedStdio"
diff --git a/guest/hals/audio/legacy/vsoc_audio.cpp b/guest/hals/audio/legacy/vsoc_audio.cpp
index 8d6141e..040e1e7 100644
--- a/guest/hals/audio/legacy/vsoc_audio.cpp
+++ b/guest/hals/audio/legacy/vsoc_audio.cpp
@@ -180,7 +180,7 @@
int GceAudio::Dump(int fd) const {
LockGuard<Mutex> guard(lock_);
- VSOC_FDPRINTF(
+ dprintf(
fd,
"\nadev_dump:\n"
"\tmic_mute: %s\n"
diff --git a/guest/hals/audio/legacy/vsoc_audio_input_stream.cpp b/guest/hals/audio/legacy/vsoc_audio_input_stream.cpp
index 6dd61f7..bb9e196 100644
--- a/guest/hals/audio/legacy/vsoc_audio_input_stream.cpp
+++ b/guest/hals/audio/legacy/vsoc_audio_input_stream.cpp
@@ -18,6 +18,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <cstdint>
+#include <cinttypes>
extern "C"{
#include <cutils/str_parms.h>
@@ -120,7 +121,7 @@
int GceAudioInputStream::Dump(int fd) const {
D("GceAudioInputStream::%s", __FUNCTION__);
- VSOC_FDPRINTF(
+ dprintf(
fd,
"\tInputSteam Dump:\n"
"\t\tsample rate: %u\n"
diff --git a/guest/hals/audio/legacy/vsoc_audio_output_stream.cpp b/guest/hals/audio/legacy/vsoc_audio_output_stream.cpp
index b0c6037..571f95e 100644
--- a/guest/hals/audio/legacy/vsoc_audio_output_stream.cpp
+++ b/guest/hals/audio/legacy/vsoc_audio_output_stream.cpp
@@ -62,7 +62,7 @@
int GceAudioOutputStream::Dump(int fd) const {
D("GceAudioOutputStream::%s", __FUNCTION__);
- VSOC_FDPRINTF(
+ dprintf(
fd,
"\tout_dump:\n"
"\t\tsample rate: %u\n"
diff --git a/guest/hals/sensors/sensors.cpp b/guest/hals/sensors/sensors.cpp
index eb1dda6..951461d 100644
--- a/guest/hals/sensors/sensors.cpp
+++ b/guest/hals/sensors/sensors.cpp
@@ -23,12 +23,6 @@
namespace {
const cvd::time::Milliseconds kDefaultSamplingRate(200);
-#if !VSOC_SENSORS_DEVICE_API_VERSION_ATLEAST(1_3)
-namespace {
-const int SENSOR_FLAG_WAKE_UP = 0;
-}
-#endif
-
timespec infinity() {
timespec ts;
ts.tv_sec = std::numeric_limits<time_t>::max();
@@ -65,18 +59,12 @@
this->resolution = resolution;
this->power = power;
this->minDelay = min_delay;
-#if VSOC_SENSORS_DEVICE_API_VERSION_ATLEAST(1_1)
this->fifoReservedEventCount = fifo_reserved_event_count;
this->fifoMaxEventCount = fifo_max_event_count;
-#endif
-#if VSOC_SENSORS_DEVICE_API_VERSION_ATLEAST(1_2)
this->stringType = string_type;
this->requiredPermission = required_permission;
-#endif
-#if VSOC_SENSORS_DEVICE_API_VERSION_ATLEAST(1_3)
this->maxDelay = max_delay;
this->flags = reporting_mode;
-#endif
}
namespace sc = sensors_constants;
diff --git a/guest/hals/sensors/vsoc_sensors.h b/guest/hals/sensors/vsoc_sensors.h
index dec7102..c4e9718 100644
--- a/guest/hals/sensors/vsoc_sensors.h
+++ b/guest/hals/sensors/vsoc_sensors.h
@@ -35,7 +35,6 @@
uint8_t sensor_handle;
} SensorControlMessage;
-#if VSOC_SENSORS_DEVICE_API_VERSION_ATLEAST(1_0)
// Last updated to HAL 1.4
// Version history:
// Before jb, jb-mr1 SENSORS_DEVICE_API_VERSION_0_1 (no version in sensors.h)
@@ -43,10 +42,6 @@
// k: SENSORS_DEVICE_API_VERSION_1_1
// l, l-mr1: SENSORS_DEVICE_API_VERSION_1_3
// m, n, n-mr1: SENSORS_DEVICE_API_VERSION_1_4
-#else
-// Pre-1.0 sensors do not define the sensors_poll_device_1 type.
-typedef sensors_poll_device_t sensors_poll_device_1;
-#endif
class GceSensors : public sensors_poll_device_1 {
public:
@@ -112,7 +107,6 @@
// an error.
int Poll(sensors_event_t* data, int count);
-#if VSOC_SENSORS_DEVICE_API_VERSION_ATLEAST(1_0)
// Sets a sensor’s parameters, including sampling frequency and maximum
// report latency. This function can be called while the sensor is
// activated, in which case it must not cause any sensor measurements to
@@ -131,9 +125,7 @@
// TODO: Add support for maximum report latency with max_report_latency_ns.
return SetDelay(sensor_handle, sampling_period_ns);
}
-#endif
-#if VSOC_SENSORS_DEVICE_API_VERSION_ATLEAST(1_1)
// Adds a META_DATA_FLUSH_COMPLETE event (sensors_event_meta_data_t)
// to the end of the "batch mode" FIFO for the specified sensor and flushes
// the FIFO.
@@ -151,9 +143,7 @@
int Flush(int sensor_handle) {
return -EINVAL;
}
-#endif
-#if VSOC_SENSORS_DEVICE_API_VERSION_ATLEAST(1_4)
// Inject a single sensor sample to be to this device.
// data points to the sensor event to be injected
// @return 0 on success
@@ -162,7 +152,6 @@
int InjectSensorData(const sensors_event_t *data) {
return -EINVAL;
}
-#endif
private:
typedef std::vector<SensorState*> SensorStateVector;
diff --git a/host/commands/assemble_cvd/flags.cc b/host/commands/assemble_cvd/flags.cc
index edda7dd..afe76ee 100644
--- a/host/commands/assemble_cvd/flags.cc
+++ b/host/commands/assemble_cvd/flags.cc
@@ -100,7 +100,8 @@
DEFINE_string(misc_image, "",
"Location of the misc partition image. If the image does not "
"exist, a blank new misc partition image is created.");
-DEFINE_string(composite_disk, "", "Location of the composite disk image.");
+DEFINE_string(composite_disk, "", "Location of the composite disk image. "
+ "If empty, a composite disk is not used.");
DEFINE_bool(deprecated_boot_completed, false, "Log boot completed message to"
" host kernel. This is only used during transition of our clients."
@@ -206,6 +207,8 @@
namespace {
+std::string kRamdiskConcatExt = ".concat";
+
template<typename S, typename T>
static std::string concat(const S& s, const T& t) {
std::ostringstream os;
@@ -239,6 +242,9 @@
std::string default_misc_image = FLAGS_system_image_dir + "/misc.img";
SetCommandLineOptionWithMode("misc_image", default_misc_image.c_str(),
google::FlagSettingMode::SET_FLAGS_DEFAULT);
+ std::string default_composite_disk = FLAGS_system_image_dir + "/composite.img";
+ SetCommandLineOptionWithMode("composite_disk", default_composite_disk.c_str(),
+ google::FlagSettingMode::SET_FLAGS_DEFAULT);
return true;
}
@@ -337,14 +343,6 @@
}
}
- if (!FLAGS_super_image.empty()) {
- if (FLAGS_composite_disk.empty()) {
- tmp_config_obj.add_kernel_cmdline("androidboot.super_partition=vda");
- } else {
- tmp_config_obj.add_kernel_cmdline("androidboot.super_partition=super");
- }
- }
-
tmp_config_obj.add_kernel_cmdline("init=/init");
tmp_config_obj.add_kernel_cmdline(
concat("androidboot.serialno=", FLAGS_serial_number));
@@ -401,6 +399,12 @@
}
tmp_config_obj.set_ramdisk_image_path(ramdisk_path);
+ if(FLAGS_initramfs_path.size() > 0) {
+ tmp_config_obj.set_initramfs_path(FLAGS_initramfs_path);
+ tmp_config_obj.set_final_ramdisk_path(ramdisk_path + kRamdiskConcatExt);
+ } else {
+ tmp_config_obj.set_final_ramdisk_path(ramdisk_path);
+ }
tmp_config_obj.set_mempath(FLAGS_mempath);
tmp_config_obj.set_ivshmem_qemu_socket_path(
@@ -724,7 +728,7 @@
} // namespace
-vsoc::CuttlefishConfig* InitFilesystemAndCreateConfig(int* argc, char*** argv) {
+const vsoc::CuttlefishConfig* InitFilesystemAndCreateConfig(int* argc, char*** argv) {
if (!ParseCommandLineFlags(argc, argv)) {
LOG(ERROR) << "Failed to parse command arguments";
exit(LauncherExitCodes::kArgumentParsingError);
@@ -772,13 +776,12 @@
exit(LauncherExitCodes::kBootImageUnpackError);
}
- if(FLAGS_initramfs_path.size()) {
- auto concat_ramdisk_path = config->ramdisk_image_path() + ".concat";
- if(!ConcatRamdisks(concat_ramdisk_path, config->ramdisk_image_path(), FLAGS_initramfs_path)) {
+ if(config->initramfs_path().size() != 0) {
+ if(!ConcatRamdisks(config->final_ramdisk_path(), config->ramdisk_image_path(),
+ config->initramfs_path())) {
LOG(ERROR) << "Failed to concatenate ramdisk and initramfs";
exit(LauncherExitCodes::kInitRamFsConcatError);
}
- config->set_ramdisk_image_path(concat_ramdisk_path);
}
if (config->decompress_kernel()) {
diff --git a/host/commands/assemble_cvd/flags.h b/host/commands/assemble_cvd/flags.h
index 9ca6f58..e8c542f 100644
--- a/host/commands/assemble_cvd/flags.h
+++ b/host/commands/assemble_cvd/flags.h
@@ -2,5 +2,5 @@
#include "host/libs/config/cuttlefish_config.h"
-vsoc::CuttlefishConfig* InitFilesystemAndCreateConfig(int* argc, char*** argv);
+const vsoc::CuttlefishConfig* InitFilesystemAndCreateConfig(int* argc, char*** argv);
std::string GetConfigFilePath(const vsoc::CuttlefishConfig& config);
diff --git a/host/libs/config/cuttlefish_config.cpp b/host/libs/config/cuttlefish_config.cpp
index 2108b63..eb9e50e 100644
--- a/host/libs/config/cuttlefish_config.cpp
+++ b/host/libs/config/cuttlefish_config.cpp
@@ -90,6 +90,8 @@
const char* kGdbFlag = "gdb_flag";
const char* kKernelCmdline = "kernel_cmdline";
const char* kRamdiskImagePath = "ramdisk_image_path";
+const char* kInitramfsPath = "initramfs_path";
+const char* kFinalRamdiskPath = "final_ramdisk_path";
const char* kVirtualDiskPaths = "virtual_disk_paths";
const char* kUsbV1SocketName = "usb_v1_socket_name";
@@ -358,6 +360,21 @@
SetPath(kRamdiskImagePath, ramdisk_image_path);
}
+std::string CuttlefishConfig::initramfs_path() const {
+ return (*dictionary_)[kInitramfsPath].asString();
+}
+void CuttlefishConfig::set_initramfs_path(const std::string& initramfs_path) {
+ SetPath(kInitramfsPath, initramfs_path);
+}
+
+std::string CuttlefishConfig::final_ramdisk_path() const {
+ return (*dictionary_)[kFinalRamdiskPath].asString();
+}
+void CuttlefishConfig::set_final_ramdisk_path(
+ const std::string& final_ramdisk_path) {
+ SetPath(kFinalRamdiskPath, final_ramdisk_path);
+}
+
std::vector<std::string> CuttlefishConfig::virtual_disk_paths() const {
std::vector<std::string> virtual_disks;
auto virtual_disks_json_obj = (*dictionary_)[kVirtualDiskPaths];
@@ -916,7 +933,7 @@
return ret;
}
-/*static*/ CuttlefishConfig* CuttlefishConfig::Get() {
+/*static*/ const CuttlefishConfig* CuttlefishConfig::Get() {
static std::shared_ptr<CuttlefishConfig> config(BuildConfigImpl());
return config.get();
}
diff --git a/host/libs/config/cuttlefish_config.h b/host/libs/config/cuttlefish_config.h
index 4d99947..8b4ee2d 100644
--- a/host/libs/config/cuttlefish_config.h
+++ b/host/libs/config/cuttlefish_config.h
@@ -48,7 +48,7 @@
// Holds the configuration of the cuttlefish instances.
class CuttlefishConfig {
public:
- static CuttlefishConfig* Get();
+ static const CuttlefishConfig* Get();
CuttlefishConfig();
~CuttlefishConfig();
@@ -145,6 +145,12 @@
std::string ramdisk_image_path() const;
void set_ramdisk_image_path(const std::string& ramdisk_image_path);
+ std::string initramfs_path() const;
+ void set_initramfs_path(const std::string& initramfs_path);
+
+ std::string final_ramdisk_path() const;
+ void set_final_ramdisk_path(const std::string& final_ramdisk_path);
+
std::vector<std::string> virtual_disk_paths() const;
void set_virtual_disk_paths(const std::vector<std::string>& disk_paths);
diff --git a/host/libs/vm_manager/crosvm_manager.cpp b/host/libs/vm_manager/crosvm_manager.cpp
index 28f3667..a050f70 100644
--- a/host/libs/vm_manager/crosvm_manager.cpp
+++ b/host/libs/vm_manager/crosvm_manager.cpp
@@ -113,8 +113,8 @@
crosvm_cmd.AddParameter("--x-display=", config_->x_display());
}
}
- if (!config_->ramdisk_image_path().empty()) {
- crosvm_cmd.AddParameter("--initrd=", config_->ramdisk_image_path());
+ if (!config_->final_ramdisk_path().empty()) {
+ crosvm_cmd.AddParameter("--initrd=", config_->final_ramdisk_path());
}
crosvm_cmd.AddParameter("--null-audio");
crosvm_cmd.AddParameter("--mem=", config_->memory_mb());
diff --git a/host/libs/vm_manager/qemu_manager.cpp b/host/libs/vm_manager/qemu_manager.cpp
index 37ab815..51280a2 100644
--- a/host/libs/vm_manager/qemu_manager.cpp
+++ b/host/libs/vm_manager/qemu_manager.cpp
@@ -136,7 +136,7 @@
LogAndSetEnv("monitor_path", GetMonitorPath(config_));
LogAndSetEnv("kernel_image_path", config_->GetKernelImageToUse());
LogAndSetEnv("gdb_flag", config_->gdb_flag());
- LogAndSetEnv("ramdisk_image_path", config_->ramdisk_image_path());
+ LogAndSetEnv("ramdisk_image_path", config_->final_ramdisk_path());
LogAndSetEnv("kernel_cmdline", config_->kernel_cmdline_as_string());
LogAndSetEnv("virtual_disk_paths", JoinString(config_->virtual_disk_paths(),
";"));