mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-09-09 04:39:17 +00:00
runtime-rs: don't treat NetworkConfig::index as unique in qemu-rs
NetworkConfig::index has been used to generate an id for a network device backend. However, it turns out that it's not unique (it's always zero as confirmed by a comment at its definition) so it's not suitable to generate an id that needs to be unique. Use the host device name instead. Signed-off-by: Pavel Mores <pmores@redhat.com>
This commit is contained in:
@@ -1717,14 +1717,9 @@ impl<'a> QemuCmdLine<'a> {
|
||||
));
|
||||
}
|
||||
|
||||
pub fn add_network_device(
|
||||
&mut self,
|
||||
dev_index: u64,
|
||||
host_dev_name: &str,
|
||||
guest_mac: Address,
|
||||
) -> Result<()> {
|
||||
pub fn add_network_device(&mut self, host_dev_name: &str, guest_mac: Address) -> Result<()> {
|
||||
let (netdev, virtio_net_device) =
|
||||
get_network_device(self.config, dev_index, host_dev_name, guest_mac)?;
|
||||
get_network_device(self.config, host_dev_name, guest_mac)?;
|
||||
|
||||
self.devices.push(Box::new(netdev));
|
||||
self.devices.push(Box::new(virtio_net_device));
|
||||
@@ -1779,12 +1774,11 @@ impl<'a> QemuCmdLine<'a> {
|
||||
|
||||
pub fn get_network_device(
|
||||
config: &HypervisorConfig,
|
||||
dev_index: u64,
|
||||
host_dev_name: &str,
|
||||
guest_mac: Address,
|
||||
) -> Result<(Netdev, DeviceVirtioNet)> {
|
||||
let mut netdev = Netdev::new(
|
||||
&format!("network-{}", dev_index),
|
||||
&format!("network-{}", host_dev_name),
|
||||
host_dev_name,
|
||||
config.network_info.network_queues,
|
||||
)?;
|
||||
|
@@ -120,7 +120,6 @@ impl QemuInner {
|
||||
let _netns_guard = NetnsGuard::new(&netns).context("new netns guard")?;
|
||||
|
||||
cmdline.add_network_device(
|
||||
network.config.index,
|
||||
&network.config.host_dev_name,
|
||||
network.config.guest_mac.clone().unwrap(),
|
||||
)?;
|
||||
|
Reference in New Issue
Block a user