mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-11-04 19:11:11 +00:00
vmm: Make VsockConfig owned
Convert Path to PathBuf and remove the associated lifetime. Now we can remove the VmConfig associated lifetime. Fixes #298 Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
This commit is contained in:
parent
3dc7aff00e
commit
acc60b0ad5
@ -10,7 +10,7 @@ use net_util::MacAddr;
|
||||
use std::convert::From;
|
||||
use std::net::AddrParseError;
|
||||
use std::net::Ipv4Addr;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::path::PathBuf;
|
||||
use std::result;
|
||||
use vm_memory::GuestAddress;
|
||||
use vm_virtio::vhost_user::VhostUserConfig;
|
||||
@ -521,13 +521,13 @@ impl VhostUserNetConfig {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct VsockConfig<'a> {
|
||||
pub struct VsockConfig {
|
||||
pub cid: u64,
|
||||
pub sock: &'a Path,
|
||||
pub sock: PathBuf,
|
||||
}
|
||||
|
||||
impl<'a> VsockConfig<'a> {
|
||||
pub fn parse(vsock: &'a str) -> Result<Self> {
|
||||
impl VsockConfig {
|
||||
pub fn parse(vsock: &str) -> Result<Self> {
|
||||
// Split the parameters based on the comma delimiter
|
||||
let params_list: Vec<&str> = vsock.split(',').collect();
|
||||
|
||||
@ -548,7 +548,7 @@ impl<'a> VsockConfig<'a> {
|
||||
|
||||
Ok(VsockConfig {
|
||||
cid: cid_str.parse::<u64>().map_err(Error::ParseVsockCidParam)?,
|
||||
sock: Path::new(sock_str),
|
||||
sock: PathBuf::from(sock_str),
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -608,7 +608,7 @@ impl VhostUserBlkConfig {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct VmConfig<'a> {
|
||||
pub struct VmConfig {
|
||||
pub cpus: CpusConfig,
|
||||
pub memory: MemoryConfig,
|
||||
pub kernel: KernelConfig,
|
||||
@ -623,11 +623,11 @@ pub struct VmConfig<'a> {
|
||||
pub devices: Option<Vec<DeviceConfig>>,
|
||||
pub vhost_user_net: Option<Vec<VhostUserNetConfig>>,
|
||||
pub vhost_user_blk: Option<Vec<VhostUserBlkConfig>>,
|
||||
pub vsock: Option<Vec<VsockConfig<'a>>>,
|
||||
pub vsock: Option<Vec<VsockConfig>>,
|
||||
}
|
||||
|
||||
impl<'a> VmConfig<'a> {
|
||||
pub fn parse(vm_params: VmParams<'a>) -> Result<Self> {
|
||||
impl VmConfig {
|
||||
pub fn parse(vm_params: VmParams) -> Result<Self> {
|
||||
let mut disks: Option<Vec<DiskConfig>> = None;
|
||||
if let Some(disk_list) = &vm_params.disks {
|
||||
let mut disk_config_list = Vec::new();
|
||||
|
@ -426,7 +426,7 @@ impl Vcpu {
|
||||
pub struct VmInfo<'a> {
|
||||
pub memory: &'a Arc<RwLock<GuestMemoryMmap>>,
|
||||
pub vm_fd: &'a Arc<VmFd>,
|
||||
pub vm_cfg: &'a VmConfig<'a>,
|
||||
pub vm_cfg: &'a VmConfig,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
@ -507,7 +507,7 @@ pub struct Vm<'a> {
|
||||
threads: Vec<thread::JoinHandle<()>>,
|
||||
devices: DeviceManager,
|
||||
cpuid: CpuId,
|
||||
config: &'a VmConfig<'a>,
|
||||
config: &'a VmConfig,
|
||||
epoll: EpollContext,
|
||||
on_tty: bool,
|
||||
creation_ts: std::time::Instant,
|
||||
@ -533,7 +533,7 @@ fn get_host_cpu_phys_bits() -> u8 {
|
||||
}
|
||||
|
||||
impl<'a> Vm<'a> {
|
||||
pub fn new(kvm: &Kvm, config: &'a VmConfig<'a>) -> Result<Self> {
|
||||
pub fn new(kvm: &Kvm, config: &'a VmConfig) -> Result<Self> {
|
||||
let kernel = File::open(&config.kernel.path).map_err(Error::KernelFile)?;
|
||||
let fd = kvm.create_vm().map_err(Error::VmCreate)?;
|
||||
let fd = Arc::new(fd);
|
||||
|
Loading…
Reference in New Issue
Block a user