Skip to content

vhost-device-gpu: Add blob resource support and Venus capset for virglrenderer backend - #988

Merged
aesteve-rh merged 8 commits into
rust-vmm:mainfrom
dorindabassey:blob-resources-v3
Sep 24, 2026
Merged

aesteve-rh merged 8 commits into
rust-vmm:mainfrom
dorindabassey:blob-resources-v3

Conversation

@dorindabassey

@dorindabassey dorindabassey commented Aug 3, 2026 •

Copy link
Copy Markdown
Collaborator

Summary of the PR

Implement blob resource creation, mapping, and unmapping for the
virglrenderer backend, using SHMEM_MAP/UNMAP via vhost-user-backend.

This also adds per-context fence support needed for Venus multi-timeline
signaling, dynamic capset index lookup, and Venus capset exposure.

Tested with vkcube in a QEMU guest. Testing with QEMU requires the
vhost-user-gpu SHMEM support patch:
https://lore.kernel.org/all/20260717134920.265128-4-dbassey@redhat.com/

Requirements

Before submitting your PR, please make sure you addressed the following
requirements:

  • All commits in this PR have Signed-Off-By trailers (with
    git commit -s), and the commit message has max 60 characters for the
    summary and max 75 characters for each description line.
  • All added/changed functionality has a corresponding unit/integration
    test.
  • All added/changed public-facing functionality has entries in the "Upcoming
    Release" section of CHANGELOG.md (if no such section exists, please create one).
  • Any newly added unsafe code is properly documented.

@dorindabassey dorindabassey changed the title gpu: Add blob resource support vhost-device-gpu: Add blob resource support Aug 4, 2026
@dorindabassey dorindabassey changed the title vhost-device-gpu: Add blob resource support vhost-device-gpu: Add blob resource support and Venus capset for virglrenderer backend Aug 4, 2026
@dorindabassey
dorindabassey force-pushed the blob-resources-v3 branch 2 times, most recently from c5cc017 to 015a08c Compare August 4, 2026 09:35
@dorindabassey

Copy link
Copy Markdown
Collaborator Author

CI failing, passing depends on - rust-vmm/rust-vmm-container#149

@dorindabassey
dorindabassey force-pushed the blob-resources-v3 branch 3 times, most recently from 7e7cd16 to da3259f Compare August 10, 2026 10:22
@dorindabassey
dorindabassey force-pushed the blob-resources-v3 branch 4 times, most recently from 15db044 to 9d25314 Compare August 19, 2026 09:32
@dorindabassey
dorindabassey force-pushed the blob-resources-v3 branch 6 times, most recently from 5592003 to 2fe0a59 Compare September 2, 2026 14:52
@dorindabassey

Copy link
Copy Markdown
Collaborator Author

Hi @stefano-garzarella and @epilys, this PR is ready for review now Thanks.

@aesteve-rh aesteve-rh left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work! Some comments here and there. I would reorganize the series a bit: split commit 4 into two commits (SHMEM/protocol vs blob commands), squash 5+7.

Comment thread vhost-device-gpu/src/device.rs
Comment thread vhost-device-gpu/src/device.rs
Comment thread vhost-device-gpu/src/lib.rs
Comment thread vhost-device-gpu/src/device.rs
Comment thread vhost-device-gpu/src/backend/common.rs
Comment thread vhost-device-gpu/src/backend/virgl.rs Outdated
Comment thread vhost-device-gpu/src/backend/virgl.rs
Dorinda Bassey and others added 3 commits September 21, 2026 11:56
Update virglrenderer-rs to pull in new API wrappers needed
for Venus support: context_create_fence, context_poll, and
export_resource_dmabuf.

Signed-off-by: Dorinda Bassey <dbassey@redhat.com>
Instead of hardcoding the capset indices, lookup the capset index dynamically
based on the configured capsets in the config.

Convert the capset bitmask to a capset ID using trailing_zeros() since
bits() returns a power-of-2 bitmask, not the capset index.

Signed-off-by: Matej Hrica <mhrica@redhat.com>
Signed-off-by: Dorinda Bassey <dbassey@redhat.com>
Dispatch to context_create_fence() when the guest sets
VIRTIO_GPU_FLAG_INFO_RING_IDX, and poll per-context fences
in event_poll(). This is required for Venus multi-timeline
fence signaling.

Signed-off-by: Dorinda Bassey <dbassey@redhat.com>
@dorindabassey
dorindabassey force-pushed the blob-resources-v3 branch 3 times, most recently from c11b250 to 7303896 Compare September 21, 2026 13:34
Comment thread vhost-device-gpu/src/protocol.rs Outdated
Comment thread vhost-device-gpu/src/device.rs Outdated
Comment thread vhost-device-gpu/README.md
mtjhrc and others added 5 commits September 21, 2026 16:39
Implement blob resource creation, mapping, and unmapping for the
virglrenderer backend. Blob resources enable zero-copy memory sharing
between guest and host, required for Venus (Vulkan) and hardware-
accelerated gfxstream rendering.

This is an atomic feature requiring both vhost-user protocol
infrastructure and virtio-gpu command handlers:

SHMEM/Protocol Infrastructure:
- Advertise SHMEM, BACKEND_REQ, and BACKEND_SEND_FD protocol features
- Implement get_shmem_config() returning 8GB HOST_VISIBLE region size
- Store backend_req_fd for SHMEM_MAP/UNMAP communication with frontend
- Add VIRTIO_GPU_SHM_ID_HOST_VISIBLE field
- Change attach_backing to take Arc<GuestMemoryMmap> to keep guest
memory alive while blob resource iovecs reference it

Blob Command Implementation:
- resource_create_blob: convert HOST3D to HOST3D_GUEST memory type,
create virglrenderer resource with guest-visible iovecs
- resource_map_blob: map blob into SHMEM region, send offset to
frontend via VHOST_USER_BACKEND_SHMEM_MAP
- resource_unmap_blob: unmap from SHMEM, notify frontend via
VHOST_USER_BACKEND_SHMEM_UNMAP
- set_scanout: re-export dmabuf on every scanout (fixes Venus
flickering with cached handles)
- Added UUID field initialization in virglrenderer for blob resources
- Added tests

Code coverage drops by ~0.5% because blob resource integration paths
(resource_create_blob with backing vecs, map/unmap SHMEM communication)
require virglrenderer GPU context not available in CI. However
manual testing in the guest with vkcube confirms functionality.

Signed-off-by: Matej Hrica <mhrica@redhat.com>
Co-authored-by: Dorinda Bassey <dbassey@redhat.com>
Expose Venus capability set support using the virglrenderer backend,
enabled by the new blob resource support. Configure virglrenderer
based on the user's capset selection. Enable virgl renderer if VIRGL
or VIRGL2 capsets are requested, and Enable Venus/render-server if
VENUS capset is requested.

Signed-off-by: Matej Hrica <mhrica@redhat.com>
Co-authored-by: Dorinda Bassey <dbassey@redhat.com>
Use String::from_utf8_lossy() instead of
CStr::from_bytes_with_nul() since the virtio-gpu
driver sends debug_name without null terminator.

Signed-off-by: Matej Hrica <mhrica@redhat.com>
Signed-off-by: Dorinda Bassey <dbassey@redhat.com>
Add the blob_alignment field to VirtioGpuConfig to match
the virtio-gpu spec, and set it to the system page size.
This is a new config introduced in the spec and QEMU.

Signed-off-by: Dorinda Bassey <dbassey@redhat.com>
Add test case for VIRTIO_GPU_CMD_SUBMIT_3D in test
display_output. This exercises the submit_cmd and
context_create_fence code paths that were previously
untested.

Signed-off-by: Dorinda Bassey <dbassey@redhat.com>

@aesteve-rh aesteve-rh left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commit 4 is still a bit long, which makes it harder to review (not saying it needs another split, as we discussed that already!).

Either way, nothing major stood out on this pass. If we catch anything later it can be a follow-up.

Looks good to me, thanks!

@aesteve-rh
aesteve-rh merged commit 057db3e into rust-vmm:main Sep 24, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants