I am currently trying to pass a device for ethernet access through qemu to the vm. However there seems to be some issue since the device is not passed through correctly.
I have looked at some resources for guidance on how to solve it: https://github.com/seL4/sel4webserver (webserver example) https://email@example.com/message/X34TX7... (old devel thread)
And the important parts for this to work seems to be untyped_mmios for the vm (in devices.camkes for qemu-arm-virt):
vm0.untyped_mmios = [ "0x8040000:12", // Interrupt Controller Virtual CPU interface (Virtual Machine view) /* TODO: QEMU PCI addresses could change - ideally need to decode from pcie node */ "0x10040000:17", // QEMU PCI MMIO "0x3eff0000:16", // QEMU PCI IO ports "0x40000000:29", // Linux kernel memory regions ];
And passing the device to QEMU in the simulation script: $ sudo ./simulate --extra-qemu-args="-netdev tap,id=mynet0,ifname=tap0,script=no,downscript=no -device virtio-net,netdev=mynet0,mac=52:55:00:d1:55:01"
However when listing the devices with "ip a" on the VM it does not show an eth0 device:
# ip a 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue qlen 1 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: tunl0@NONE: <NOARP> mtu 1480 qdisc noop qlen 1 link/ipip 0.0.0.0 brd 0.0.0.0 3: ip6tnl0@NONE: <NOARP> mtu 1452 qdisc noop qlen 1 link/tunnel6 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00 brd 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00
But on the host the device that is passed to qemu can be seen: $ ip link show tap0 6: tap0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000 link/ether 62:43:43:54:2d:e6 brd ff:ff:ff:ff:ff:ff
I am not sure if I missed something or if it is the QEMU addresses for the pci region that are not correct. Is there any output during boot or build that could give insight in what went wrong when it tries to passthrough the device? Also are there are any resources or guidelines on how to decode the pcie node? (Since I assume this has to be done inside the vm with the limited selection of commands available).
Best regards, Olof
Since I managed to figure it out I thought I should post my solution to the problem in case there are others with the same question (at least for the qemu-arm-virt device).
Start qemu with the following command: sudo ./simulate --extra-qemu-args="-netdev tap,id=mynet0,ifname=tap0,script=no,downscript=no -device virtio-net,netdev=mynet0,mac=52:55:00:d1:55:01,disable-modern=on,disable-legacy=off"
This thread that suggested adding ",disable-modern=on,disable-legacy=off" might be of interest when figuring out what previously went wrong: https://qemu-devel.nongnu.narkive.com/otcGnLuw/bug-virtio-net-linux-driver-f...
When the VM has booted, add an ip to the "eth0" device that should now be visible. Do this by editing the /etc/network/interfaces file and adding:
auto eth0 iface eth0 inet static address XXX.XXX.XXX.XXX (replace with the IP of your choice, this will be the guest IP) netmask 255.255.255.0
Then save the changes and run:
Then add an ip to the device that was added to the host when running the simulate script:
sudo ip addr add YYY.YYY.YYY.YYY/24 dev tap0 (replace with the IP of your choice, this will be the host IP) sudo ip link set dev tap0 up
It should now be possible to reach the VM from the host with IP XXX.XXX.XXX.XXX and reach the host from the VM with IP YYY.YYY.YYY.YYY. At least ping from host to vm and from vm to host worked for me.