Commit 85b5e827 authored by Timothy Loh's avatar Timothy Loh Committed by Commit Bot

Fix Plugin VM task manager integration

The crosvm args for Plugin VM were changed in http://crrev.com/i/3119886
so it no longer matches the code here.

A sample list of arguments can be seen at go/paste/6706238773526528.

Bug: 1106680
Change-Id: I98d90f2679673868e42f2911637f84626af48f8f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2302878
Auto-Submit: Timothy Loh <timloh@chromium.org>
Commit-Queue: Ahmed Fakhry <afakhry@chromium.org>
Reviewed-by: default avatarAhmed Fakhry <afakhry@chromium.org>
Cr-Commit-Position: refs/heads/master@{#789536}
parent e7f46de8
...@@ -103,38 +103,34 @@ bool CrostiniExtractVmNameAndOwnerId(const std::string& arg, ...@@ -103,38 +103,34 @@ bool CrostiniExtractVmNameAndOwnerId(const std::string& arg,
return true; return true;
} }
// We are looking for argument like this: // We are looking for an argument like this:
// --params=/run/pvm-images/<cryptohome id>/UHZtRGVmYXVsdA==.pvm/... // /home/root/<cryptohome id>/pvm/UHZtRGVmYXVsdA==.pvm:/pvm:true
bool PluginVmExtractVmNameAndOwnerId(const std::string& arg, bool PluginVmExtractVmNameAndOwnerId(const std::string& arg,
std::string* vm_name_out, std::string* vm_name_out,
std::string* owner_id_out) { std::string* owner_id_out) {
DCHECK(vm_name_out); DCHECK(vm_name_out);
DCHECK(owner_id_out); DCHECK(owner_id_out);
constexpr char kParamPrefix[] = "--params="; constexpr char kArgStart[] = "/home/root/";
if (!base::StartsWith(arg, kParamPrefix, base::CompareCase::SENSITIVE)) { constexpr char kArgEnd[] = ":/pvm:true";
return false;
}
base::StringPiece param(arg.begin() + strlen(kParamPrefix), arg.end());
// All VM disk images are mounted at this path. // Skip paths that don't start/end with the expected prefix/suffix.
constexpr char kVmDiskRoot[] = "/run/pvm-images/"; if (!base::StartsWith(arg, kArgStart, base::CompareCase::SENSITIVE))
return false;
// Skip paths that don't start with the correct prefix. if (!base::EndsWith(arg, kArgEnd, base::CompareCase::SENSITIVE))
if (!base::StartsWith(param, kVmDiskRoot, base::CompareCase::SENSITIVE)) {
return false; return false;
}
const base::FilePath vm_disk_path(param); const base::FilePath vm_disk_path(
base::StringPiece(arg.begin(), arg.end() - strlen(kArgEnd)));
std::vector<std::string> components; std::vector<std::string> components;
vm_disk_path.GetComponents(&components); vm_disk_path.GetComponents(&components);
// Expect /, root, pvm-images, <owner_id>, vm_name.pvm, ... // Expect /, home, root, <owner_id>, pvm, vm_name.pvm
if (components.size() < 5) if (components.size() != 6)
return false; return false;
base::FilePath vm_subdir(components[4]); base::FilePath vm_subdir(components[5]);
if (vm_subdir.Extension() != ".pvm") if (vm_subdir.Extension() != ".pvm")
return false; return false;
...@@ -142,9 +138,6 @@ bool PluginVmExtractVmNameAndOwnerId(const std::string& arg, ...@@ -142,9 +138,6 @@ bool PluginVmExtractVmNameAndOwnerId(const std::string& arg,
// file itself without the extension. // file itself without the extension.
base::Base64Decode(vm_subdir.RemoveExtension().value(), vm_name_out); base::Base64Decode(vm_subdir.RemoveExtension().value(), vm_name_out);
// The owner ID is the long hex string in there...which is 2 parents up.
// It's safe to call this even if there's not enough parents because the
// DirName of the root is still the root.
*owner_id_out = components[3]; *owner_id_out = components[3];
return true; return true;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment