End-to-end network for Arm/virtio#47
Merged
Merged
Conversation
The kernel documentation was reorganized and previous URL now returns 404. Point the reference to the current location under arch/x86/.
Building the in-tree Linux guest pulls in the kernel's build dependencies (flex, bison, libelf headers), which are easy to miss on a fresh setup. Mention them with a Debian/Ubuntu install line as an example so users can map the package names onto their distribution. Split the "Usage" section into "Start Emulator" and "Exit Emulator" subsections. The exit instruction was previously buried below the command line and is easier to find with its own heading; "Exit" matches the actual semantics, since Ctrl-A x leaves the KVM_RUN loop rather than pausing the guest. Co-authored-by: Otis Chung <p76124605@gs.ncku.edu.tw>
VIRTIO_NET_IRQ was added to desc.h in 80b2677, which silenced the arm64 link error but left the FDT generator describing a single PCI device. With virtio-blk the only entry in interrupt-map, the guest kernel cannot resolve INTA# for the virtio-net function and skips the device when vm_enable_net brings it up. Add a second interrupt-map entry pointing virtio-net at VIRTIO_NET_IRQ. The IRQ value is a SPI offset programmed by the host; the GIC adds the SPI base of 32, so this becomes global interrupt 34. The number is arbitrary, only uniqueness against other emulated devices matters. Gate each entry on pci_dev_is_registered() so the FDT only describes devices whose PCI bar/config space was actually set up. This preserves the best-effort contract of vm_enable_net (failure logged, boot continues): without the gate, a missing -d disk image or a TUN/TAP open failure would leave the matching virtio_*_dev struct in its default state and we would publish a zero pci_hi entry for a device the guest cannot find. The check uses config_dev.len, which is set inside pci_dev_register() to PCI_CFG_SPACE_SIZE. For the gate to be reliable on arm64, also call virtio_blk_init() in vm_arch_init_platform_device(); x86 already does. Without that memset the struct is left as stack garbage on boots without -d, and config_dev.len could match PCI_CFG_SPACE_SIZE by chance. Co-authored-by: Otis Chung <p76124605@gs.ncku.edu.tw>
Turn on the bits the guest kernel needs to bring up the host-supplied virtio-net device: CONFIG_NET, CONFIG_INET core IPv4 stack CONFIG_IP_MULTICAST NDP/IGMP frames seen during ifup CONFIG_IP_PNP, CONFIG_IP_PNP_DHCP configure-on-boot if requested CONFIG_NETDEVICES netdev infrastructure CONFIG_VIRTIO virtio transport CONFIG_VIRTIO_NET the virtio-net driver itself CONFIG_POSIX_TIMERS is enabled in the same patch because the only networking smoke test we document is ping(8), which calls timer_create()/timer_settime() to drive its retransmit interval. Without POSIX timers ping aborts before sending the first echo request, so connectivity verification has to live with this config flip. Co-authored-by: Otis Chung <p76124605@gs.ncku.edu.tw>
Provide two helpers under scripts/ plus a README walkthrough that exercises the guest virtio-net interface end to end. set-host-bridge.sh creates a dedicated `kvmbr0` (not `br0`) with 10.0.0.1/24, enslaves the kvm-host TAP, and brings both interfaces up. Earlier drafts unconditionally `ip link delete br0` before recreating it -- that would silently destroy a libvirt/Docker/etc. bridge sharing the name. The script now refuses to touch a non-bridge interface holding its target name, reuses an existing bridge instead of recreating, and never installs a default route via 10.0.0.1 (doing so would replace the host's real default gateway and cut off external connectivity). Both the TAP and bridge names are positional arguments because kvm-host's TUNSETIFF "tap%d" picks the first free tapN, which is not always tap0 if the host already runs other TAPs. set-guest-route.sh now uses `ip addr replace` for idempotency and deliberately does not install a default route. The host bridge does not forward traffic, so a default via 10.0.0.1 would silently black-hole everything outside 10.0.0.0/24; users who want internet egress have to add NAT and forwarding on the host themselves. The README "Test the Guest virtio-net Interface" section walks through the new bridge name, explains the TAP-naming caveat, and points out the NAT/forwarding requirement for off-bridge traffic. Co-authored-by: Otis Chung <p76124605@gs.ncku.edu.tw>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary by cubic
Enable end-to-end virtio-net on arm64: proper FDT IRQ wiring, guest kernel config, and simple host/guest helpers so the guest can ping the host over a dedicated
kvmbr0link. Also updates docs and adds build prerequisites.New Features
configs/linux-arm64.config(CONFIG_NET,CONFIG_VIRTIO_NET, etc.) andCONFIG_POSIX_TIMERSsopingworks.scripts/set-host-bridge.shandscripts/set-guest-route.shto bring up a host-only bridge (kvmbr0) and guest IP for quick testing.flex,bison,libelf-devprerequisites and a step-by-step virtio-net test, plus corrected Linux x86 boot protocol link.Bug Fixes
interrupt-mapentries on registered PCI devices to avoid phantom devices if-dor TAP setup is missing.virtio_blk_init()on arm64 startup to ensure clean state for the registration gate.Written for commit 430867a. Summary will update on new commits. Review in cubic