mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-12-22 21:55:20 +00:00
vm-virtio: vhost-user-net: Expect an identifier upon device creation
This identifier is chosen from the DeviceManager so that it will manage all identifiers across the VM, which will ensure uniqueness. Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
parent
46e0b3ff75
commit
354c2a4b3d
@ -37,6 +37,7 @@ struct SlaveReqHandler {}
|
||||
impl VhostUserMasterReqHandler for SlaveReqHandler {}
|
||||
|
||||
pub struct Net {
|
||||
id: String,
|
||||
vhost_user_net: Master,
|
||||
kill_evt: Option<EventFd>,
|
||||
pause_evt: Option<EventFd>,
|
||||
@ -55,7 +56,7 @@ pub struct Net {
|
||||
impl Net {
|
||||
/// Create a new vhost-user-net device
|
||||
/// Create a new vhost-user-net device
|
||||
pub fn new(mac_addr: MacAddr, vu_cfg: VhostUserConfig) -> Result<Net> {
|
||||
pub fn new(id: String, 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)?;
|
||||
|
||||
@ -141,6 +142,7 @@ impl Net {
|
||||
}
|
||||
|
||||
Ok(Net {
|
||||
id,
|
||||
vhost_user_net,
|
||||
kill_evt: None,
|
||||
pause_evt: None,
|
||||
@ -365,6 +367,10 @@ impl VirtioDevice for Net {
|
||||
}
|
||||
|
||||
virtio_ctrl_q_pausable!(Net);
|
||||
impl Snapshottable for Net {}
|
||||
impl Snapshottable for Net {
|
||||
fn id(&self) -> String {
|
||||
self.id.clone()
|
||||
}
|
||||
}
|
||||
impl Transportable for Net {}
|
||||
impl Migratable for Net {}
|
||||
|
@ -1360,7 +1360,7 @@ impl DeviceManager {
|
||||
queue_size: net_cfg.queue_size,
|
||||
};
|
||||
let vhost_user_net_device = Arc::new(Mutex::new(
|
||||
vm_virtio::vhost_user::Net::new(net_cfg.mac, vu_cfg)
|
||||
vm_virtio::vhost_user::Net::new(id, net_cfg.mac, vu_cfg)
|
||||
.map_err(DeviceManagerError::CreateVhostUserNet)?,
|
||||
));
|
||||
self.add_migratable_device(
|
||||
|
Loading…
Reference in New Issue
Block a user