Virtio-net device not receiving packets in VirtualBox
Posted: Sat Apr 27, 2019 11:24 pm
Hello OSDev forums!
Lately I've been trying to implement a driver for the virtio-net paravirtual device. I've gotten this working well in Qemu but I'm still having some trouble getting it to work in VirtualBox.
Thanks to this thread I was able to make VirtualBox actually transmit my packet (thanks SpyderTL!), but I'm still unable to receive any responses. I've tried sending a DHCP discover packet and an ARP request.
I've managed to get capture files of the traffic by following these instructions, and Wireshark does show that responses are going to the VM, but my driver never sees them. I've tried just about everything and I'm running out of ideas.
In VBox, I never receive an interrupt for received packets. Also, I've added a command to my shell that dumps out some info about the receive queue, so I know that the used index is never being incremented. It also inspects all of the 16 receive buffers I make available to the receive queue, and they all stay empty. I also notice that the device area (the used ring) of the receive queue has the VIRTQ_USED_F_NO_NOTIFY flag set by the device, so I think I'm setting up the virtqueues correctly in memory. Also, like I said, it works OK in Qemu and all the same memory addresses are being used in both environments.
This behavior is with the Windows build of VirtualBox. I also tried using VirtualBox in Linux (running in another VM) and had the same results.
I'm pretty much running out of things to try. The only other thing I can think is to build and debug Virtualbox myself but I have every indication that just building it is far from trivial.
I'd really appreciate it if anyone could share some ideas as to where I'm going wrong!
My code is here and the relevant parts are this header and source file. The driver starts with VirtIO_Net_Init().
Thanks in advance!
Lately I've been trying to implement a driver for the virtio-net paravirtual device. I've gotten this working well in Qemu but I'm still having some trouble getting it to work in VirtualBox.
Thanks to this thread I was able to make VirtualBox actually transmit my packet (thanks SpyderTL!), but I'm still unable to receive any responses. I've tried sending a DHCP discover packet and an ARP request.
I've managed to get capture files of the traffic by following these instructions, and Wireshark does show that responses are going to the VM, but my driver never sees them. I've tried just about everything and I'm running out of ideas.
In VBox, I never receive an interrupt for received packets. Also, I've added a command to my shell that dumps out some info about the receive queue, so I know that the used index is never being incremented. It also inspects all of the 16 receive buffers I make available to the receive queue, and they all stay empty. I also notice that the device area (the used ring) of the receive queue has the VIRTQ_USED_F_NO_NOTIFY flag set by the device, so I think I'm setting up the virtqueues correctly in memory. Also, like I said, it works OK in Qemu and all the same memory addresses are being used in both environments.
This behavior is with the Windows build of VirtualBox. I also tried using VirtualBox in Linux (running in another VM) and had the same results.
I'm pretty much running out of things to try. The only other thing I can think is to build and debug Virtualbox myself but I have every indication that just building it is far from trivial.
I'd really appreciate it if anyone could share some ideas as to where I'm going wrong!
My code is here and the relevant parts are this header and source file. The driver starts with VirtIO_Net_Init().
Thanks in advance!