drivers/vhost: Improvements and fixes for vhost framework#18289
Merged
xiaoxiang781216 merged 7 commits intoapache:masterfrom Feb 3, 2026
Merged
drivers/vhost: Improvements and fixes for vhost framework#18289xiaoxiang781216 merged 7 commits intoapache:masterfrom
xiaoxiang781216 merged 7 commits intoapache:masterfrom
Conversation
xiaoxiang781216
previously approved these changes
Jan 30, 2026
Contributor
|
@CV-Bowen please double check if vhost Documentation is complete or if it is broken after recent modifications: https://nuttx.apache.org/docs/latest/components/drivers/special/rptun/architecture.html#virtio-vhost-communication-flow |
Contributor
|
Hi @CV-Bowen, please note this error. |
Add vhost wrapper macros that map to the corresponding virtio helper functions: - vhost_has_feature: check if a feature is supported - vhost_read_config_member: read a config structure member - vhost_write_config_member: write a config structure member Also include virtio-config.h header to support these macros. Signed-off-by: Yongrong Wang <wangyongrong@xiaomi.com>
…uffers Add vhost_get_vq_buffers() API to retrieve all chained buffers from a virtqueue in one call. This simplifies handling of scatter-gather I/O where data spans multiple descriptors. The function populates an array of virtqueue_buf structures with buffer pointers and lengths, returning the descriptor head index on success. Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com> Signed-off-by: hongfengchen <hongfengchen@xiaomi.com>
Change DRIVERS_VIRTIO and DRIVERS_VHOST from menuconfig to hidden config options. Each virtio/vhost sub-driver now automatically selects its parent config, eliminating the need to manually enable DRIVERS_VIRTIO or DRIVERS_VHOST in defconfig files. This simplifies board configuration by removing redundant CONFIG_DRIVERS_VIRTIO entries from affected defconfig files. Signed-off-by: Yongrong Wang <wangyongrong@xiaomi.com> Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
Convert VHOST_DEFERED_PROBE_PERIOD from a raw value to use MSEC2TICK() macro, ensuring the delay is correctly converted from milliseconds to system ticks regardless of the configured tick rate. Signed-off-by: Yongrong Wang <wangyongrong@xiaomi.com>
The vhost driver uses work_queue() for deferred probe but was missing the SCHED_WORKQUEUE Kconfig dependency, causing link errors on boards that don't enable workqueue by default. Signed-off-by: wangzhi16 <wangzhi16@xiaomi.com>
Move common virtio inline functions (virtqueue_kick_lock, virtio_malloc_buf, virtio_zalloc_buf, etc.) from CONFIG_DRIVERS_VIRTIO guard to CONFIG_OPENAMP guard. This allows vhost drivers to reuse these helper functions without requiring the full virtio driver framework. The virtio_driver structure and driver registration APIs remain under CONFIG_DRIVERS_VIRTIO as they are specific to virtio device drivers. Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
Add comprehensive documentation for the Vhost framework, which serves as the VirtIO backend implementation in NuttX for cross-core communication. The documentation includes: - Overview and comparison with Linux Vhost and QEMU VirtIO Device - Three-layer architecture (Service, Framework, Transport) - Driver/Device registration and matching workflow - Source code directory structure - Complete API reference (data structures, core APIs, macro APIs) Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
Contributor
Author
acassis
approved these changes
Feb 3, 2026
jerpelea
approved these changes
Feb 3, 2026
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
This PR contains a series of improvements and fixes for the vhost (Virtual Host) driver framework in NuttX. The changes enhance the vhost API, fix build issues, and simplify Kconfig configuration.
1. drivers/vhost: add vhost helper macros for feature and config access
Add vhost wrapper macros that map to the corresponding virtio helper functions:
vhost_has_feature: check if a feature is supportedvhost_read_config_member: read a config structure membervhost_write_config_member: write a config structure memberAlso include
virtio-config.hheader to support these macros.2. drivers/vhost: add vhost_get_vq_buffers() to collect scatter-gather buffers
Add
vhost_get_vq_buffers()API to retrieve all chained buffers from a virtqueue in one call. This simplifies handling of scatter-gather I/O where data spans multiple descriptors.The function populates an array of
virtqueue_bufstructures with buffer pointers and lengths, returning the descriptor head index on success.3. drivers/virtio and vhost: auto-select parent config from sub-drivers
Change
DRIVERS_VIRTIOandDRIVERS_VHOSTfrommenuconfigto hiddenconfigoptions. Each virtio/vhost sub-driver now automatically selects its parent config, eliminating the need to manually enableDRIVERS_VIRTIOorDRIVERS_VHOSTin defconfig files.This simplifies board configuration by removing redundant
CONFIG_DRIVERS_VIRTIOentries from affected defconfig files.4. drivers/vhost: use MSEC2TICK for deferred probe period
Convert
VHOST_DEFERED_PROBE_PERIODfrom a raw value to useMSEC2TICK()macro, ensuring the delay is correctly converted from milliseconds to system ticks regardless of the configured tick rate.5. drivers/vhost: add missing SCHED_WORKQUEUE dependency
The vhost driver uses
work_queue()for deferred probe but was missing theSCHED_WORKQUEUEKconfig dependency, causing link errors on boards that don't enable workqueue by default.6. include/nuttx/virtio: allow common virtio helpers to be used by vhost
Move common virtio inline functions (
virtqueue_kick_lock,virtio_malloc_buf,virtio_zalloc_buf, etc.) fromCONFIG_DRIVERS_VIRTIOguard toCONFIG_OPENAMPguard. This allows vhost drivers to reuse these helper functions without requiring the full virtio driver framework.The
virtio_driverstructure and driver registration APIs remain underCONFIG_DRIVERS_VIRTIOas they are specific to virtio device drivers.7. Add Vhost framework documentation
Add comprehensive documentation for the Vhost framework, which serves
as the VirtIO backend implementation in NuttX for cross-core communication.
Impact
Testing
qemu-armv8a rpproxy and rpserver
qemuv8a:netnsh