vmm, vm-virtio: Stop always autogenerating a host MAC address

This removes the need to use CAP_NET_ADMIN privileges and instead the
host MAC addres is either provided by the user or alternatively it is
retrieved from the kernel.

TEST=Run cloud-hypervisor without CAP_NET_ADMIN permission and a
preconfigured tap device:

sudo ip tuntap add name tap0 mode tap
sudo ifconfig tap0 192.168.249.1 netmask 255.255.255.0 up
cargo clean
cargo build
target/debug/cloud-hypervisor --serial tty --console off --kernel ~/src/rust-hypervisor-firmware/target/target/release/hypervisor-fw --disk path=~/workloads/clear-33190-kvm.img --net tap=tap0

VM was also rebooted to check that works correctly.

Fixes: #1274

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
Rob Bradford
2020-06-05 12:00:34 +01:00
committed by Sebastien Boeuf
parent 1f8b6fa947
commit 9b71ba20ac
5 changed files with 25 additions and 20 deletions

View File

@@ -141,7 +141,7 @@ impl VhostUserNetBackend {
ifname,
Some(ip_addr),
Some(netmask),
Some(host_mac),
&mut Some(host_mac),
num_queues / 2,
)
.map_err(Error::OpenTap)?;