mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
vm-virtio: 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:
committed by
Rob Bradford
parent
be946caf4b
commit
9eb7413fab
@@ -1340,9 +1340,13 @@ impl DeviceManager {
|
||||
&mut self,
|
||||
net_cfg: &mut NetConfig,
|
||||
) -> DeviceManagerResult<(VirtioDeviceArc, bool, Option<String>)> {
|
||||
if net_cfg.id.is_none() {
|
||||
net_cfg.id = Some(self.next_device_name(NET_DEVICE_NAME_PREFIX)?);
|
||||
}
|
||||
let id = if let Some(id) = &net_cfg.id {
|
||||
id.clone()
|
||||
} else {
|
||||
let id = self.next_device_name(NET_DEVICE_NAME_PREFIX)?;
|
||||
net_cfg.id = Some(id.clone());
|
||||
id
|
||||
};
|
||||
|
||||
if net_cfg.vhost_user {
|
||||
let sock = if let Some(sock) = net_cfg.vhost_socket.clone() {
|
||||
@@ -1371,6 +1375,7 @@ impl DeviceManager {
|
||||
let virtio_net_device = if let Some(ref tap_if_name) = net_cfg.tap {
|
||||
Arc::new(Mutex::new(
|
||||
vm_virtio::Net::new(
|
||||
id,
|
||||
Some(tap_if_name),
|
||||
None,
|
||||
None,
|
||||
@@ -1384,6 +1389,7 @@ impl DeviceManager {
|
||||
} else {
|
||||
Arc::new(Mutex::new(
|
||||
vm_virtio::Net::new(
|
||||
id,
|
||||
None,
|
||||
Some(net_cfg.ip),
|
||||
Some(net_cfg.mask),
|
||||
|
||||
Reference in New Issue
Block a user