Open joaopeixoto13 opened 5 months ago
Update: I already have a raw implementation that allows me to verify the PR to use the VirtioDeviceActions trait to accommodate not only VirtIO backends but also Vhost and Vhost-user backends. In this case, it was tested and proven to work for: VirtIO-Net and VirtIO-Block, Vhost-user-fs and Vhost-vsock.
Summary of the PR
This PR enhances the VirtioDeviceActions Trait to accommodate Vhost and Vhost-User devices. This way, this crate can be used not only to implement virtio abstractions for devices that are implemented inside the VMM, but it can also serve as a frontend virtio device abstraction for Vhost and Vhost-user type devices. This patch introduces four new methods to the VirtioDeviceActions:
read_config
andwrite_config
: These methods are invoked when the driver intends to read from or write to the device configuration space. Given that the device configuration space can be managed by various handlers outside of the VMM, such as vhost-user when the protocol feature CONFIG is negotiated, dedicated logic is necessary to handle these operations (e.g. GET_CONFIG/SET_CONFIG requests).negotiate_driver_features
: This method is called when the driver finishes the negotiation of the driver features with the frontend device (selecting page 0). This method is crucial when the device handler is implemented outside of the VMM since the frontend device needs to negotiate the features with the backend device. Otherwise, the device will not be prepared to support some driver features.interrupt_status
: When the driver requires reading the interrupt status from the device, this method is invoked. Since the responsibility for managing interrupt status lies with the frontend device, specialized logic is needed to update the interrupt status appropriately (Used Buffer Notification or Configuration Change Notification). If the device is implemented within the VMM, the interrupt status is directly managed and updated by the device.Requirements
Before submitting your PR, please make sure you addressed the following requirements:
git commit -s
), and the commit message has max 60 characters for the summary and max 75 characters for each description line.unsafe
code is properly documented.