vmm: Make vhost-user configuration owned

Convert Path to PathBuf, &str to String and remove the associated lifetime.

Fixes #298

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
This commit is contained in:
Samuel Ortiz 2019-09-23 19:42:52 +02:00 committed by Rob Bradford
parent 5f8a62f3d0
commit 3dc7aff00e
5 changed files with 23 additions and 23 deletions

View File

@ -46,10 +46,10 @@ pub struct Blk {
interrupt_cb: Option<Arc<VirtioInterrupt>>,
}
impl<'a> Blk {
impl Blk {
/// Create a new vhost-user-blk device
pub fn new(wce: bool, vu_cfg: VhostUserConfig<'a>) -> Result<Blk> {
let mut vhost_user_blk = Master::connect(vu_cfg.sock, vu_cfg.num_queues as u64)
pub fn new(wce: bool, vu_cfg: VhostUserConfig) -> Result<Blk> {
let mut vhost_user_blk = Master::connect(&vu_cfg.sock, vu_cfg.num_queues as u64)
.map_err(Error::VhostUserCreateMaster)?;
// Filling device and vring features VMM supports.

View File

@ -38,10 +38,10 @@ pub struct Net {
queue_sizes: Vec<u16>,
}
impl<'a> Net {
impl Net {
/// Create a new vhost-user-net device
pub fn new(mac_addr: MacAddr, vu_cfg: VhostUserConfig<'a>) -> Result<Net> {
let mut vhost_user_net = Master::connect(vu_cfg.sock, vu_cfg.num_queues as u64)
pub fn new(mac_addr: MacAddr, vu_cfg: VhostUserConfig) -> Result<Net> {
let mut vhost_user_net = Master::connect(&vu_cfg.sock, vu_cfg.num_queues as u64)
.map_err(Error::VhostUserCreateMaster)?;
let kill_evt = EventFd::new(EFD_NONBLOCK).map_err(Error::CreateKillEventFd)?;

View File

@ -14,9 +14,9 @@ use super::{Error, Result};
use vhost_rs::vhost_user::{Master, VhostUserMaster};
use vhost_rs::{VhostBackend, VhostUserMemoryRegionInfo, VringConfigData};
#[derive(Debug, Copy, Clone)]
pub struct VhostUserConfig<'a> {
pub sock: &'a str,
#[derive(Debug, Clone)]
pub struct VhostUserConfig {
pub sock: String,
pub num_queues: usize,
pub queue_size: u16,
}

View File

@ -463,13 +463,13 @@ impl DeviceConfig {
}
}
pub struct VhostUserNetConfig<'a> {
pub struct VhostUserNetConfig {
pub mac: MacAddr,
pub vu_cfg: VhostUserConfig<'a>,
pub vu_cfg: VhostUserConfig,
}
impl<'a> VhostUserNetConfig<'a> {
pub fn parse(vhost_user_net: &'a str) -> Result<Self> {
impl VhostUserNetConfig {
pub fn parse(vhost_user_net: &str) -> Result<Self> {
// Split the parameters based on the comma delimiter
let params_list: Vec<&str> = vhost_user_net.split(',').collect();
@ -512,7 +512,7 @@ impl<'a> VhostUserNetConfig<'a> {
}
let vu_cfg = VhostUserConfig {
sock,
sock: sock.to_string(),
num_queues,
queue_size,
};
@ -553,13 +553,13 @@ impl<'a> VsockConfig<'a> {
}
}
pub struct VhostUserBlkConfig<'a> {
pub struct VhostUserBlkConfig {
pub wce: bool,
pub vu_cfg: VhostUserConfig<'a>,
pub vu_cfg: VhostUserConfig,
}
impl<'a> VhostUserBlkConfig<'a> {
pub fn parse(vhost_user_blk: &'a str) -> Result<Self> {
impl VhostUserBlkConfig {
pub fn parse(vhost_user_blk: &str) -> Result<Self> {
// Split the parameters based on the comma delimiter
let params_list: Vec<&str> = vhost_user_blk.split(',').collect();
@ -599,7 +599,7 @@ impl<'a> VhostUserBlkConfig<'a> {
}
let vu_cfg = VhostUserConfig {
sock,
sock: sock.to_string(),
num_queues,
queue_size,
};
@ -621,8 +621,8 @@ pub struct VmConfig<'a> {
pub serial: ConsoleConfig,
pub console: ConsoleConfig,
pub devices: Option<Vec<DeviceConfig>>,
pub vhost_user_net: Option<Vec<VhostUserNetConfig<'a>>>,
pub vhost_user_blk: Option<Vec<VhostUserBlkConfig<'a>>>,
pub vhost_user_net: Option<Vec<VhostUserNetConfig>>,
pub vhost_user_blk: Option<Vec<VhostUserBlkConfig>>,
pub vsock: Option<Vec<VsockConfig<'a>>>,
}

View File

@ -773,7 +773,7 @@ impl DeviceManager {
for vhost_user_net_cfg in vhost_user_net_list_cfg.iter() {
let vhost_user_net_device = vm_virtio::vhost_user::Net::new(
vhost_user_net_cfg.mac,
vhost_user_net_cfg.vu_cfg,
vhost_user_net_cfg.vu_cfg.clone(),
)
.map_err(DeviceManagerError::CreateVhostUserNet)?;
@ -793,7 +793,7 @@ impl DeviceManager {
for vhost_user_blk_cfg in vhost_user_blk_list_cfg.iter() {
let vhost_user_blk_device = vm_virtio::vhost_user::Blk::new(
vhost_user_blk_cfg.wce,
vhost_user_blk_cfg.vu_cfg,
vhost_user_blk_cfg.vu_cfg.clone(),
)
.map_err(DeviceManagerError::CreateVhostUserBlk)?;