vmm: Switch MemoryManager::send() to url_to_path()

This continues the work in cc78a597cd

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
Rob Bradford 2021-03-12 13:13:33 +00:00 committed by Sebastien Boeuf
parent cc78a597cd
commit ab4b30edd3

View File

@ -28,7 +28,6 @@ use std::os::unix::io::{AsRawFd, FromRawFd, RawFd};
use std::path::PathBuf; use std::path::PathBuf;
use std::result; use std::result;
use std::sync::{Arc, Barrier, Mutex}; use std::sync::{Arc, Barrier, Mutex};
use url::Url;
#[cfg(target_arch = "x86_64")] #[cfg(target_arch = "x86_64")]
use vm_allocator::GsiApic; use vm_allocator::GsiApic;
use vm_allocator::SystemAllocator; use vm_allocator::SystemAllocator;
@ -2042,28 +2041,7 @@ impl Transportable for MemoryManager {
_snapshot: &Snapshot, _snapshot: &Snapshot,
destination_url: &str, destination_url: &str,
) -> result::Result<(), MigratableError> { ) -> result::Result<(), MigratableError> {
let url = Url::parse(destination_url).map_err(|e| { let vm_memory_snapshot_path = url_to_path(destination_url)?;
MigratableError::MigrateSend(anyhow!("Could not parse destination URL: {}", e))
})?;
match url.scheme() {
"file" => {
let vm_memory_snapshot_path = url
.to_file_path()
.map_err(|_| {
MigratableError::MigrateSend(anyhow!(
"Could not convert file URL to a file path: {}",
destination_url
))
})
.and_then(|path| {
if !path.is_dir() {
return Err(MigratableError::MigrateSend(anyhow!(
"Destination is not a directory"
)));
}
Ok(path)
})?;
if let Some(guest_memory) = &*self.snapshot.lock().unwrap() { if let Some(guest_memory) = &*self.snapshot.lock().unwrap() {
for region in self.snapshot_memory_regions.iter() { for region in self.snapshot_memory_regions.iter() {
@ -2089,14 +2067,6 @@ impl Transportable for MemoryManager {
} }
} }
} }
}
_ => {
return Err(MigratableError::MigrateSend(anyhow!(
"Unsupported VM transport URL scheme: {}",
url.scheme()
)))
}
}
Ok(()) Ok(())
} }
} }