| 89 | } |
| 90 | |
| 91 | bool VmStore::Load(std::string* error) { |
| 92 | std::lock_guard<std::mutex> lock(mutex_); |
| 93 | vms_.clear(); |
| 94 | |
| 95 | std::error_code ec; |
| 96 | fs::create_directories(VmRoot(), ec); |
| 97 | if (ec) { |
| 98 | if (error) *error = "failed to create VM root: " + ec.message(); |
| 99 | return false; |
| 100 | } |
| 101 | |
| 102 | for (const auto& entry : fs::directory_iterator(VmRoot(), ec)) { |
| 103 | if (ec) break; |
| 104 | if (!entry.is_directory()) continue; |
| 105 | (void)LoadVmDir(entry.path(), error); |
| 106 | } |
| 107 | return true; |
| 108 | } |
| 109 | |
| 110 | bool VmStore::LoadVmDir(const fs::path& vm_dir, std::string* error) { |
| 111 | const auto manifest = vm_dir / "vm.json"; |