Construct default instance dir with libvirt profile_name
Bug: 73266892
Test: Build and boot locally
Change-Id: I26a2bc93ce3cb96f82a37ed458e0c4026716e698
(cherry picked from commit 5c4d84158a757ae7c9d86ea78bb6ca008e4c1f20)
diff --git a/host/commands/launch/main.cc b/host/commands/launch/main.cc
index d1a0443..a2930e3 100644
--- a/host/commands/launch/main.cc
+++ b/host/commands/launch/main.cc
@@ -104,10 +104,6 @@
"Location of the system partition images.");
DEFINE_string(vendor_image, "", "Location of the vendor partition image.");
-std::string g_default_uuid{
- GetPerInstanceDefault("699acfc4-c8c4-11e7-882b-5065f31dc1")};
-DEFINE_string(uuid, g_default_uuid.c_str(),
- "UUID to use for the device. Random if not specified");
DEFINE_bool(deprecated_boot_completed, false, "Log boot completed message to"
" host kernel. This is only used during transition of our clients."
" Will be deprecated soon.");
@@ -127,6 +123,8 @@
DEFINE_int32(socket_forward_proxy_port, 5555, "port on which to run the "
"socket_forward_proxy server");
+DECLARE_string(uuid);
+
namespace {
const std::string kDataPolicyUseExisting = "use_existing";
const std::string kDataPolicyCreateIfMissing = "create_if_missing";
diff --git a/host/libs/config/host_config.cpp b/host/libs/config/host_config.cpp
index 9acd663..cc0218d 100644
--- a/host/libs/config/host_config.cpp
+++ b/host/libs/config/host_config.cpp
@@ -24,12 +24,13 @@
#include <gflags/gflags.h>
-const char vsoc_user_prefix[] = "vsoc-";
+const char kVsocUserPrefix[] = "vsoc-";
+const char kDefaultUuidPrefix[] = "699acfc4-c8c4-11e7-882b-5065f31dc1";
int GetDefaultInstance() {
char* user = getenv("USER");
- if (user && !memcmp(user, vsoc_user_prefix, sizeof(vsoc_user_prefix) - 1)) {
- int temp = atoi(user + sizeof(vsoc_user_prefix) - 1);
+ if (user && !memcmp(user, kVsocUserPrefix, sizeof(kVsocUserPrefix) - 1)) {
+ int temp = atoi(user + sizeof(kVsocUserPrefix) - 1);
if (temp > 0) {
return temp;
}
@@ -41,6 +42,8 @@
"Path to the ivshmem client socket");
DEFINE_int32(instance, GetDefaultInstance(),
"Instance number. Must be unique.");
+DEFINE_string(uuid, vsoc::GetPerInstanceDefault(kDefaultUuidPrefix).c_str(),
+ "UUID to use for the device. Random if not specified");
std::string vsoc::GetPerInstanceDefault(const char* prefix) {
std::ostringstream stream;
@@ -54,7 +57,9 @@
}
std::string vsoc::GetDefaultPerInstanceDir() {
- return vsoc::GetPerInstanceDefault("/var/run/cvd-");
+ std::ostringstream stream;
+ stream << "/var/run/libvirt-" << kDefaultUuidPrefix;
+ return vsoc::GetPerInstanceDefault(stream.str().c_str());
}
std::string vsoc::GetDefaultPerInstancePath(const std::string& basename) {