Virtio documentation, like here, describes many feature bits that can be set or "negotiated" for a virtio-device. For instance, there is the VIRTIO_RING_F_EVENT_IDX
feature that can be turned on or off.
I have not come across any documentation that describes how to actually turn features on or off. Is there any way to turn features on or off at runtime (like through a /proc/
variable)? Are features something to be configured using make menuconfig
when compiling a kernel? Or is the only way to modify the source code of a virtio device file and add/remove features there (like modifying this enum in vhost/vhost.h)?
As mentioned in other comments and the other answer, there is no way to add/remove features for a virtio-device at runtime.
To change a virtio feature, you must modify the corresponding driver and device source code.
As an example, the enum in vhost/vhost.h you linked to is inside a driver file (the full path is actually drivers/vhost/vhost.h
). So for turning off a feature, you could set features to false from this enum and reload the driver. For adding a feature, though, modifying the driver alone is not sufficient.
To add a feature for a virtio driver/device, you need to make sure that the feature bit is turned on in both the virtio driver (guest-level) and the device (host-level). You already know how to modify the driver code, so the only piece is how to modify the device level feature.
As explained here, device level features can be turned on/off by modifying the emulator code, typically Qemu. The VIRTIO_RING_F_EVENT_IDX
feature you mentioned can be found in Qemu on this line, set to true by default (as of version 8.1.2).