Created attachment 208881 [details]
modification on pci_virtio_net.c
If a tap interface is created with a name, it is not possible to start a VM with bhyve using this name. We must use the device name.
For example, I create this interface (sysctl is correctly configured to use tap):
ifconfig tap create name port1
when I launch the VM (after loaded it for sure)
bhyve -c 1 -m 256 -A -H -P -s 0:0,hostbridge -s 1,virtio-net,port1 -s 2:0 virtio-blk,/root/rFreeBSD.img -s 31,lpc -l com1,/dev/nmdm0A rFreeBSD
The network will not work because the command is only develop to check device in /dev/.
I add some code to check if the name matches with a interface and replace it to create the virtual interface
I hope I was enough clear and my code not too ugly
(In reply to Fabien Costard from comment #0)
Hmm... unfortunately, this should work fine in -CURRENT and stable/12, but the patch will not go to stable/11 and did not make it into 12.1. The merged tuntap(4) will create a dev alias for the different name:
root@viper:/usr/src# ifconfig tap create name port1
root@viper:/usr/src# ls -l /dev | grep tap
lrwxr-xr-x 1 root wheel 4 Nov 7 07:52 port1 -> tap0
crw------- 1 uucp dialer 0x60 Nov 7 07:52 tap0
I do not have any insight into how -virtualization would prefer to proceed, but this is news from the tun/tap side. =-)
(In reply to Kyle Evans from comment #1)
That is a good with the link. As advice me a friend, I am also trying to find another way (to myself, this is a good way to learn) to find the source device file instead of checking the /dev folder. I hope it will be more generic
Created attachment 209488 [details]
update_code on pci_virtio_net.c
My code was very ugly and bad.. It does not work well. I find I have an issue when I used more that 8 tap interfaces.
After I worked on memory allocation & co... I send you for memories an upgrade of the code.
I know about the previous comments, but I do not want to let a wrong code :-)