Network
Host TAP configuration
The most convenient way to provide a network device to a guest is to setup a persistent TAP interface on the host. This section will explain how to do this for basic IPv4 connectivity.
These commands create a TAP interface named crosvm_tap that is accessible to the current user, configure the host to use the IP address 192.168.10.1, and bring the interface up.
The next step is to make sure that traffic from/to this interface is properly routed:
Start crosvm with network
The interface is now configured and can be used by crosvm:
Configure network in host
Provided the guest kernel had support for VIRTIO_NET, the network device should be visible and configurable from the guest.
These commands assign IP address 192.168.10.2 to the guest, activate the interface, and route all network traffic to the host. The last line also ensures DNS will work.
Please refer to your distribution's documentation for instructions on how to make these settings persistent for the host and guest if desired.
Device hotplug (experimental)
On a hotplug-enabled VM, a TAP device can be hotplugged using the virtio-net command:
Upon success, crosvm virtio_net will report the PCI bus number the device is plugged into:
The hotplugged device can then be configured inside the guest OS similar to a statically configured device. (Replace ${GUEST_DEV} with the hotplugged device, e.g.: enp3s0.)
Due to sandboxing, crosvm do not have CAP_NET_ADMIN even if crosvm is started using sudo. Therefore, hotplug only accepts a persistent TAP device owned by the user running crosvm, unless sandboxing is disabled.
The device can be removed from the guest using the PCI bus number: