mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2024-11-24 12:34:31 +00:00
hypervisor: kvm: avoid unnecessary PathBuf allocation
Create a Path directly in Kvm::new() rather than constructing a PathBuf and borrowing it. BUG=None TEST=tools/dev_container tools/presubmit Change-Id: Icf46c48dc2dde3548cc796fc0162d5b57d4ad9bd Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5671064 Commit-Queue: Daniel Verkamp <dverkamp@chromium.org> Reviewed-by: Frederick Mayle <fmayle@google.com>
This commit is contained in:
parent
8fef190b71
commit
e2d619d6f0
2 changed files with 4 additions and 6 deletions
|
@ -27,7 +27,6 @@ use std::os::raw::c_ulong;
|
|||
use std::os::raw::c_void;
|
||||
use std::os::unix::prelude::OsStrExt;
|
||||
use std::path::Path;
|
||||
use std::path::PathBuf;
|
||||
use std::ptr::copy_nonoverlapping;
|
||||
use std::sync::Arc;
|
||||
|
||||
|
@ -190,9 +189,9 @@ impl Kvm {
|
|||
})
|
||||
}
|
||||
|
||||
/// Opens `/dev/kvm/` and returns a Kvm object on success.
|
||||
/// Opens `/dev/kvm` and returns a Kvm object on success.
|
||||
pub fn new() -> Result<Kvm> {
|
||||
Kvm::new_with_path(&PathBuf::from("/dev/kvm"))
|
||||
Kvm::new_with_path(Path::new("/dev/kvm"))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,6 @@ use std::ops::DerefMut;
|
|||
use std::os::raw::*;
|
||||
use std::os::unix::prelude::OsStrExt;
|
||||
use std::path::Path;
|
||||
use std::path::PathBuf;
|
||||
use std::ptr::copy_nonoverlapping;
|
||||
use std::sync::Arc;
|
||||
|
||||
|
@ -141,9 +140,9 @@ pub struct Kvm {
|
|||
}
|
||||
|
||||
impl Kvm {
|
||||
/// Opens `/dev/kvm/` and returns a Kvm object on success.
|
||||
/// Opens `/dev/kvm` and returns a Kvm object on success.
|
||||
pub fn new() -> Result<Kvm> {
|
||||
Kvm::new_with_path(&PathBuf::from("/dev/kvm"))
|
||||
Kvm::new_with_path(Path::new("/dev/kvm"))
|
||||
}
|
||||
|
||||
/// Opens a KVM device at `device_path` and returns a Kvm object on success.
|
||||
|
|
Loading…
Reference in a new issue