Merge "Use Android.mk->Android.bp for setup_wifi,rename_netiface" into cuttlefish-testing
diff --git a/host/commands/launch/data_image.cc b/host/commands/launch/data_image.cc
index 47ee06e..415a71e 100644
--- a/host/commands/launch/data_image.cc
+++ b/host/commands/launch/data_image.cc
@@ -11,17 +11,6 @@
const std::string kDataPolicyAlwaysCreate = "always_create";
const std::string kDataPolicyResizeUpTo= "resize_up_to";
-void CreateBlankImage(
- const std::string& image, int image_mb, const std::string& image_fmt) {
- LOG(INFO) << "Creating " << image;
- std::string of = "of=";
- of += image;
- std::string count = "count=";
- count += std::to_string(image_mb);
- cvd::execute({"/bin/dd", "if=/dev/zero", of, "bs=1M", count});
- cvd::execute({"/sbin/mkfs", "-t", image_fmt, image}, {"PATH=/sbin"});
-}
-
void RemoveFile(const std::string& file) {
LOG(INFO) << "Removing " << file;
remove(file.c_str());
@@ -77,6 +66,19 @@
}
} // namespace
+void CreateBlankImage(
+ const std::string& image, int image_mb, const std::string& image_fmt) {
+ LOG(INFO) << "Creating " << image;
+ std::string of = "of=";
+ of += image;
+ std::string count = "count=";
+ count += std::to_string(image_mb);
+ cvd::execute({"/bin/dd", "if=/dev/zero", of, "bs=1M", count});
+ if (image_fmt != "none") {
+ cvd::execute({"/sbin/mkfs", "-t", image_fmt, image}, {"PATH=/sbin"});
+ }
+}
+
bool ApplyDataImagePolicy(const vsoc::CuttlefishConfig& config) {
std::string data_image = config.data_image_path();
bool data_exists = cvd::FileHasContent(data_image.c_str());
diff --git a/host/commands/launch/data_image.h b/host/commands/launch/data_image.h
index bc09ce9..1cf9ca2 100644
--- a/host/commands/launch/data_image.h
+++ b/host/commands/launch/data_image.h
@@ -5,3 +5,5 @@
#include "host/libs/config/cuttlefish_config.h"
bool ApplyDataImagePolicy(const vsoc::CuttlefishConfig& config);
+void CreateBlankImage(
+ const std::string& image, int image_mb, const std::string& image_fmt);
diff --git a/host/commands/launch/flags.cc b/host/commands/launch/flags.cc
index 94149f8..49d34b3 100644
--- a/host/commands/launch/flags.cc
+++ b/host/commands/launch/flags.cc
@@ -25,6 +25,10 @@
"Path to the system image, if empty it is assumed to be a file named "
"system.img in the directory specified by -system_image_dir");
DEFINE_string(cache_image, "", "Location of the cache partition image.");
+DEFINE_string(metadata_image, "", "Location of the metadata partition image "
+ "to be generated.");
+DEFINE_int32(blank_metadata_image_mb, 16,
+ "The size of the blank metadata image to generate, MB.");
DEFINE_int32(cpus, 2, "Virtual CPU count.");
DEFINE_string(data_image, "", "Location of the data partition image.");
DEFINE_string(data_policy, "use_existing", "How to handle userdata partition."
@@ -213,6 +217,9 @@
std::string default_vendor_image = FLAGS_system_image_dir + "/vendor.img";
SetCommandLineOptionWithMode("vendor_image", default_vendor_image.c_str(),
google::FlagSettingMode::SET_FLAGS_DEFAULT);
+ std::string default_metadata_image = FLAGS_system_image_dir + "/metadata.img";
+ SetCommandLineOptionWithMode("metadata_image", default_metadata_image.c_str(),
+ google::FlagSettingMode::SET_FLAGS_DEFAULT);
return true;
}
@@ -336,6 +343,7 @@
tmp_config_obj.set_cache_image_path(FLAGS_cache_image);
tmp_config_obj.set_data_image_path(FLAGS_data_image);
tmp_config_obj.set_vendor_image_path(FLAGS_vendor_image);
+ tmp_config_obj.set_metadata_image_path(FLAGS_metadata_image);
tmp_config_obj.set_dtb_path(FLAGS_dtb);
tmp_config_obj.set_gsi_fstab_path(FLAGS_gsi_fstab);
@@ -621,10 +629,13 @@
exit(cvd::kCuttlefishConfigurationInitError);
}
+ CreateBlankImage(FLAGS_metadata_image, FLAGS_blank_metadata_image_mb, "none");
+
// Check that the files exist
for (const auto& file :
{config->system_image_path(), config->vendor_image_path(),
- config->cache_image_path(), config->data_image_path()}) {
+ config->cache_image_path(), config->data_image_path(),
+ config->metadata_image_path()}) {
if (!cvd::FileHasContent(file.c_str())) {
LOG(ERROR) << "File not found: " << file;
exit(cvd::kCuttlefishConfigurationInitError);
diff --git a/host/libs/config/cuttlefish_config.cpp b/host/libs/config/cuttlefish_config.cpp
index 56fc40b..1d18f56 100644
--- a/host/libs/config/cuttlefish_config.cpp
+++ b/host/libs/config/cuttlefish_config.cpp
@@ -92,6 +92,7 @@
const char* kCacheImagePath = "cache_image_path";
const char* kDataImagePath = "data_image_path";
const char* kVendorImagePath = "vendor_image_path";
+const char* kMetadataImagePath = "metadata_image_path";
const char* kUsbV1SocketName = "usb_v1_socket_name";
const char* kVhciPort = "vhci_port";
const char* kUsbIpSocketName = "usb_ip_socket_name";
@@ -349,6 +350,14 @@
SetPath(kVendorImagePath, vendor_image_path);
}
+std::string CuttlefishConfig::metadata_image_path() const {
+ return (*dictionary_)[kMetadataImagePath].asString();
+}
+void CuttlefishConfig::set_metadata_image_path(
+ const std::string& metadata_image_path) {
+ SetPath(kMetadataImagePath, metadata_image_path);
+}
+
std::string CuttlefishConfig::dtb_path() const {
return (*dictionary_)[kDtbPath].asString();
}
diff --git a/host/libs/config/cuttlefish_config.h b/host/libs/config/cuttlefish_config.h
index 9ce528e..f13a433 100644
--- a/host/libs/config/cuttlefish_config.h
+++ b/host/libs/config/cuttlefish_config.h
@@ -132,6 +132,9 @@
std::string vendor_image_path() const;
void set_vendor_image_path(const std::string& vendor_image_path);
+ std::string metadata_image_path() const;
+ void set_metadata_image_path(const std::string& metadata_image_path);
+
std::string dtb_path() const;
void set_dtb_path(const std::string& dtb_path);
diff --git a/host/libs/vm_manager/cf_qemu.sh b/host/libs/vm_manager/cf_qemu.sh
index 0f53bb6..ac63bbe 100755
--- a/host/libs/vm_manager/cf_qemu.sh
+++ b/host/libs/vm_manager/cf_qemu.sh
@@ -107,6 +107,8 @@
-device "virtio-blk-pci,scsi=off,drive=drive-virtio-disk2,id=virtio-disk2"
-drive "file=${vendor_image_path:-${HOME}/vendor.img},format=raw,if=none,id=drive-virtio-disk3,aio=threads"
-device "virtio-blk-pci,scsi=off,drive=drive-virtio-disk3,id=virtio-disk3"
+ -drive "file=${metadata_image_path:-${HOME}/metadata.img},format=raw,if=none,id=drive-virtio-disk4,aio=threads"
+ -device "virtio-blk-pci,scsi=off,drive=drive-virtio-disk4,id=virtio-disk4"
-netdev "tap,id=hostnet0,ifname=${wifi_tap_name:-${default_wifi_tap_name}},script=no,downscript=no"
-device "virtio-net-pci,netdev=hostnet0,id=net0"
-netdev "tap,id=hostnet1,ifname=${mobile_tap_name:-${default_mobile_tap_name}},script=no,downscript=no"
@@ -215,4 +217,5 @@
args+=(-device "vhost-vsock-pci,guest-cid=${vsock_guest_cid}")
fi
+export QEMU_AUDIO_DRV=none
exec_run "${qemu_binary}" "${args[@]}"
diff --git a/host/libs/vm_manager/crosvm_manager.cpp b/host/libs/vm_manager/crosvm_manager.cpp
index e88ca07..b623157 100644
--- a/host/libs/vm_manager/crosvm_manager.cpp
+++ b/host/libs/vm_manager/crosvm_manager.cpp
@@ -82,6 +82,7 @@
command.AddParameter("--rwdisk=", config_->data_image_path());
command.AddParameter("--rwdisk=", config_->cache_image_path());
command.AddParameter("--rwdisk=", config_->vendor_image_path());
+ command.AddParameter("--rwdisk=", config_->metadata_image_path());
command.AddParameter("--socket=", GetControlSocketPath(config_));
command.AddParameter("--android-fstab=", config_->gsi_fstab_path());
diff --git a/host/libs/vm_manager/qemu_manager.cpp b/host/libs/vm_manager/qemu_manager.cpp
index 33d9d44..d986833 100644
--- a/host/libs/vm_manager/qemu_manager.cpp
+++ b/host/libs/vm_manager/qemu_manager.cpp
@@ -75,6 +75,7 @@
LogAndSetEnv("data_image_path", config_->data_image_path());
LogAndSetEnv("cache_image_path", config_->cache_image_path());
LogAndSetEnv("vendor_image_path", config_->vendor_image_path());
+ LogAndSetEnv("metadata_image_path", config_->metadata_image_path());
LogAndSetEnv("wifi_tap_name", config_->wifi_tap_name());
LogAndSetEnv("mobile_tap_name", config_->mobile_tap_name());
LogAndSetEnv("kernel_log_socket_name",