-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for VHOST_USER_GPU_SET_SOCKET #239
Conversation
561f4c2
to
0a77153
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left some comments, but the code is almost fine with me.
Please fix the commit messages, some of them doesn't have any description (please also just a line describing the type of message you're adding is enough, but avoid empty), others doesn't have new lines before S-o-b.
Also check copyright and SPDX of new files.
8ec2ff7
to
e1b1ab4
Compare
Apart from changes you requested I also changed the signature of cursor_update, to accept the array outside of the struct as I realized this is more practical to the user. This also meant I removed a test for sending such a big message body. |
I am not sure about the changes in regards to sending big message. I added a constant to the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did a quick review and I think we are in a good shape :-)
I just suggest that you fix the description a bit in the commits. Take a look here: https://docs.kernel.org/process/submitting-patches.html
Describe your changes in imperative mood, e.g. “make xyzzy do frotz” instead of “[This patch] makes xyzzy do frotz” or “[I] changed xyzzy to do frotz”, as if you are giving orders to the codebase to change its behaviour.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general LGTM, but the PR is really long, not sure if it would be better to split some of the initial commits that have fewer dependencies.
I left a few comments, and I will give it another pass for the next round.
VIRTIO GPU device emulation as specified in the VIRTIO Spec v.1.2 https://docs.oasis-open.org/virtio/virtio/v1.2/csd01/virtio-v1.2-csd01.html This crate utilizes the rutabaga crate Imported from crosvm This crate depends on this PR[rust-vmm/vhost#239] that implements support for QEMU's vhost-user-gpu protocol. This device can be tested following the instructions explained in the README.md file under staging/vhost-device-gpu/. Co-authored-by: Dorinda Bassey <[email protected]> Co-authored-by: Matej Hrica <[email protected]> Signed-off-by: Dorinda Bassey <[email protected]> Signed-off-by: Matej Hrica <[email protected]>
This program is a vhost-user backend daemon that provides VIRTIO GPU device emulation as specified in the VIRTIO Spec v.1.2 https://docs.oasis-open.org/virtio/virtio/v1.2/csd01/virtio-v1.2-csd01.html This crate utilizes the rutabaga crate Imported from crosvm This crate depends on this PR[rust-vmm/vhost#239] that implements support for QEMU's vhost-user-gpu protocol. This device can be tested following the instructions explained in the README.md file under staging/vhost-device-gpu/. Co-authored-by: Dorinda Bassey <[email protected]> Co-authored-by: Matej Hrica <[email protected]> Signed-off-by: Dorinda Bassey <[email protected]> Signed-off-by: Matej Hrica <[email protected]>
This program is a vhost-user backend daemon that provides VIRTIO GPU device emulation as specified in the VIRTIO Spec v.1.2 https://docs.oasis-open.org/virtio/virtio/v1.2/csd01/virtio-v1.2-csd01.html This crate utilizes the rutabaga crate Imported from crosvm This crate depends on this PR[rust-vmm/vhost#239] that implements support for QEMU's vhost-user-gpu protocol. This crate also includes some modifications from libkrun virtio-gpu device https://github.com/containers/libkrun/tree/main/src/devices/src/virtio/gpu This device can be tested following the instructions explained in the README.md file under staging/vhost-device-gpu/. Co-authored-by: Dorinda Bassey <[email protected]> Co-authored-by: Matej Hrica <[email protected]> Signed-off-by: Dorinda Bassey <[email protected]> Signed-off-by: Matej Hrica <[email protected]>
0d5f48b
to
f05e322
Compare
I changed the internal API used here like discussed here with @stefano-garzarella, this makes each message method explicitly call pub fn get_display_info(&self) -> io::Result<VirtioGpuRespDisplayInfo> {
self.send_header(GpuBackendReq::GET_DISPLAY_INFO, None)
} the public methods now do: pub fn get_display_info(&self) -> io::Result<VirtioGpuRespDisplayInfo> {
let node = self.node(); // locks the mutex and returns a reference
let hdr = node.send_header(GpuBackendReq::GET_DISPLAY_INFO, None)?;
node.recv_reply(&hdr)
} Note that some messeges aren't supposed to wait for a reply so this removes the need for overly specific utility methods like |
@mtjhrc great! Thanks, I'll review in the next days (I'm going to DevConf at Brno, so maybe it will take a while, sorry in advance). Since you are here, can you also rebase on the latest main? |
I have fixed this and rebased the PR. |
The Endpoint was previusly generic only over the Request. This commit allows Endpoint to be used with a protocol with a slightly different header such as the QEMU GPU protocol on the socket from VHOST_USER_GPU_SET_SOCKET. https://www.qemu.org/docs/master/interop/vhost-user-gpu.html Signed-off-by: Matej Hrica <[email protected]>
Move the enum_value macro into vhost_user module and make it public within this module. This will be used in the next commit for defining gpu message enum. Signed-off-by: Matej Hrica <[email protected]>
This commit adds the basic definitions of GPU commands on the socket obtained from VHOST_USER_GPU_SET_SOCKET. This also introduces a new feature flag `gpu-socket` in the vhost crate. Signed-off-by: Matej Hrica <[email protected]>
The VHOST_USER_GPU_SET_SOCKET is only handled when the feature gpu-socket is enabled. This also introduces a GpuBackend for handling comunication over the socket. Signed-off-by: Matej Hrica <[email protected]>
Introduce another constant MAX_MSG_SIZE that is part of the MsgHeader trait. For now this is only used for sending messages. Consider using the more specific trait constant everywhere. The VHOST_USER_GPU_UPDATE and VHOST_USER_GPU_CURSOR_UPDATE contain image data and are larger than the existing MAX_MSG_SIZE. The existing MAX_MSG_SIZE wasn't really a limitation of the protocol, just an implementation detail limitation in this crate. Signed-off-by: Matej Hrica <[email protected]>
Add a get_display_info() method and the related reply structs to send VHOST_USER_GPU_GET_DISPLAY_INFO and receive the reply. Signed-off-by: Dorinda Bassey <[email protected]> Signed-off-by: Matej Hrica <[email protected]>
Add a method and related structs to send VHOST_USER_GPU_GET_EDID and receive the reply. Signed-off-by: Dorinda Bassey <[email protected]>
Add a method set_scanout() that sends VHOST_USER_GPU_SCANOUT and doesn't wait for a reply. Signed-off-by: Dorinda Bassey <[email protected]>
Add a method and related struct to send VHOST_USER_GPU_UPDATE. The data part of the message is not part of the struct like sugested by the spec but a separate argument to update_scanout. This is necessary because of limitations of having an unsized array inside of struct in Rust. But this aproach seems preferable anyway, because it allows the consumer of the crate to store the array in a diferent location than the struct. Signed-off-by: Dorinda Bassey <[email protected]> Signed-off-by: Matej Hrica <[email protected]>
Add methods and related structs to send the VHOST_USER_GPU_DMABUF_SCANOUT and VHOST_USER_GPU_DMABUF_UPDATE update messages. Signed-off-by: Matej Hrica <[email protected]>
Add get_protocol_features method to send VHOST_USER_GPU_GET_PROTOCOL_FEATURES and receive the reply. Also add a method to send SET_PROTOCOL_FEATURES. Introduce VhostUserGpuProtocolFeatures bitmap that defines possible feature flags. Signed-off-by: Dorinda Bassey <[email protected]>
Add methods to send cursor related messages: VHOST_USER_GPU_CURSOR_POS, VHOST_USER_GPU_CURSOR_POS_HIDE and VHOST_USER_GPU_CURSOR_UPDATE. VhostUserGpuCursorUpdate's `data` field is passed as a separate argument into cursor_update method. The type is also an u8 array instead of u32 array like in the spec. Having the type be u8 array makes it easier to work with the data without unsafe code for the consumer of this crate. Having it be a separate argument is useful, because the user of the method doesn't have to copy the array into a struct. Signed-off-by: Dorinda Bassey <[email protected]>
Add a method and related struct to send the VHOST_USER_GPU_DMABUF_SCANOUT2 message. Signed-off-by: Matej Hrica <[email protected]>
Adds links to PR in CHANGELOG.md for both vhost and vhost-user-backend. Signed-off-by: Matej Hrica <[email protected]>
Compile and test with `gpu-socket` feature enabled. Signed-off-by: Matej Hrica <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, great work here.
This program is a vhost-user backend daemon that provides VIRTIO GPU device emulation as specified in the VIRTIO Spec v.1.2 https://docs.oasis-open.org/virtio/virtio/v1.2/csd01/virtio-v1.2-csd01.html This crate utilizes the rutabaga crate Imported from crosvm This crate depends on this PR[rust-vmm/vhost#239] that implements support for QEMU's vhost-user-gpu protocol. This crate supports both gfxstream and virglrenderer library either of these libraries can be used by simply changing the `renderer` command line option. This crate also includes some modifications from libkrun virtio-gpu device https://github.com/containers/libkrun/tree/main/src/devices/src/virtio/gpu This device can be tested following the instructions explained in the README.md file under staging/vhost-device-gpu/. Fixes: rust-vmm#598 Co-authored-by: Dorinda Bassey <[email protected]> Co-authored-by: Matej Hrica <[email protected]> Signed-off-by: Dorinda Bassey <[email protected]> Signed-off-by: Matej Hrica <[email protected]>
This program is a vhost-user backend daemon that provides VIRTIO GPU device emulation as specified in the VIRTIO Spec v.1.2 https://docs.oasis-open.org/virtio/virtio/v1.2/csd01/virtio-v1.2-csd01.html This crate utilizes the rutabaga crate Imported from crosvm This crate depends on this PR[rust-vmm/vhost#239] that implements support for QEMU's vhost-user-gpu protocol. This crate supports both gfxstream and virglrenderer library either of these libraries can be used by simply changing the `renderer` command line option. This crate also includes some modifications from libkrun virtio-gpu device https://github.com/containers/libkrun/tree/main/src/devices/src/virtio/gpu This device can be tested following the instructions explained in the README.md file under staging/vhost-device-gpu/. Fixes: rust-vmm#598 Co-authored-by: Dorinda Bassey <[email protected]> Co-authored-by: Matej Hrica <[email protected]> Signed-off-by: Dorinda Bassey <[email protected]> Signed-off-by: Matej Hrica <[email protected]>
This program is a vhost-user backend daemon that provides VIRTIO GPU device emulation as specified in the VIRTIO Spec v.1.2 https://docs.oasis-open.org/virtio/virtio/v1.2/csd01/virtio-v1.2-csd01.html This crate utilizes the rutabaga crate Imported from crosvm This crate depends on this PR[rust-vmm/vhost#239] that implements support for QEMU's vhost-user-gpu protocol. This crate supports both gfxstream and virglrenderer library either of these libraries can be used by simply changing the `renderer` command line option. This crate also includes some modifications from libkrun virtio-gpu device https://github.com/containers/libkrun/tree/main/src/devices/src/virtio/gpu This device can be tested following the instructions explained in the README.md file under staging/vhost-device-gpu/. Fixes: rust-vmm#598 Co-authored-by: Dorinda Bassey <[email protected]> Co-authored-by: Matej Hrica <[email protected]> Signed-off-by: Dorinda Bassey <[email protected]> Signed-off-by: Matej Hrica <[email protected]>
This program is a vhost-user backend daemon that provides VIRTIO GPU device emulation as specified in the VIRTIO Spec v.1.2 https://docs.oasis-open.org/virtio/virtio/v1.2/csd01/virtio-v1.2-csd01.html This crate utilizes the rutabaga crate Imported from crosvm This crate depends on this PR[rust-vmm/vhost#239] that implements support for QEMU's vhost-user-gpu protocol. This crate supports both gfxstream and virglrenderer library either of these libraries can be used by simply changing the `renderer` command line option. This crate also includes some modifications from libkrun virtio-gpu device https://github.com/containers/libkrun/tree/main/src/devices/src/virtio/gpu This device can be tested following the instructions explained in the README.md file under staging/vhost-device-gpu/. Fixes: rust-vmm#598 Co-authored-by: Dorinda Bassey <[email protected]> Co-authored-by: Matej Hrica <[email protected]> Signed-off-by: Dorinda Bassey <[email protected]> Signed-off-by: Matej Hrica <[email protected]>
This program is a vhost-user backend daemon that provides VIRTIO GPU device emulation as specified in the VIRTIO Spec v.1.2 https://docs.oasis-open.org/virtio/virtio/v1.2/csd01/virtio-v1.2-csd01.html This crate utilizes the rutabaga crate Imported from crosvm This crate depends on this PR[rust-vmm/vhost#239] that implements support for QEMU's vhost-user-gpu protocol. This crate supports both gfxstream and virglrenderer library either of these libraries can be used by simply changing the `renderer` command line option. This crate also includes some modifications from libkrun virtio-gpu device https://github.com/containers/libkrun/tree/main/src/devices/src/virtio/gpu This device can be tested following the instructions explained in the README.md file under staging/vhost-device-gpu/. Fixes: rust-vmm#598 Co-authored-by: Dorinda Bassey <[email protected]> Co-authored-by: Matej Hrica <[email protected]> Signed-off-by: Dorinda Bassey <[email protected]> Signed-off-by: Matej Hrica <[email protected]>
This program is a vhost-user backend daemon that provides VIRTIO GPU device emulation as specified in the VIRTIO Spec v.1.2 https://docs.oasis-open.org/virtio/virtio/v1.2/csd01/virtio-v1.2-csd01.html This crate utilizes the rutabaga crate from crosvm with some minor modification to rutabaga crate to fix compilation. This crate depends on this PR[rust-vmm/vhost#239] that implements support for QEMU's vhost-user-gpu protocol. This crate supports both gfxstream and virglrenderer library either of these libraries can be used by simply changing the `renderer` command line option. This crate also includes some modifications from libkrun virtio-gpu device https://github.com/containers/libkrun/tree/main/src/devices/src/virtio/gpu This device can be tested following the instructions explained in the README.md file under staging/vhost-device-gpu/. Fixes: rust-vmm#598 Co-authored-by: Dorinda Bassey <[email protected]> Co-authored-by: Matej Hrica <[email protected]> Signed-off-by: Dorinda Bassey <[email protected]> Signed-off-by: Matej Hrica <[email protected]>
This program is a vhost-user backend daemon that provides VIRTIO GPU device emulation as specified in the VIRTIO Spec v.1.2 https://docs.oasis-open.org/virtio/virtio/v1.2/csd01/virtio-v1.2-csd01.html This crate utilizes the rutabaga crate from crosvm with some minor modification to rutabaga crate to fix compilation. This crate depends on this PR[rust-vmm/vhost#239] that implements support for QEMU's vhost-user-gpu protocol. This crate supports both gfxstream and virglrenderer library either of these libraries can be used by simply changing the `renderer` command line option. This crate also includes some modifications from libkrun virtio-gpu device https://github.com/containers/libkrun/tree/main/src/devices/src/virtio/gpu This device can be tested following the instructions explained in the README.md file under staging/vhost-device-gpu/. Fixes: rust-vmm#598 Co-authored-by: Dorinda Bassey <[email protected]> Co-authored-by: Matej Hrica <[email protected]> Signed-off-by: Dorinda Bassey <[email protected]> Signed-off-by: Matej Hrica <[email protected]>
This program is a vhost-user backend daemon that provides VIRTIO GPU device emulation as specified in the VIRTIO Spec v.1.2 https://docs.oasis-open.org/virtio/virtio/v1.2/csd01/virtio-v1.2-csd01.html This crate utilizes the rutabaga crate from crosvm with some minor modification to rutabaga crate to fix compilation. This crate depends on this PR[rust-vmm/vhost#239] that implements support for QEMU's vhost-user-gpu protocol. This crate supports both gfxstream and virglrenderer library either of these libraries can be used by simply changing the `renderer` command line option. This crate also includes some modifications from libkrun virtio-gpu device https://github.com/containers/libkrun/tree/main/src/devices/src/virtio/gpu This device can be tested following the instructions explained in the README.md file under staging/vhost-device-gpu/. Fixes: rust-vmm#598 Co-authored-by: Dorinda Bassey <[email protected]> Co-authored-by: Matej Hrica <[email protected]> Signed-off-by: Dorinda Bassey <[email protected]> Signed-off-by: Matej Hrica <[email protected]>
This program is a vhost-user backend daemon that provides VIRTIO GPU device emulation as specified in the VIRTIO Spec v.1.2 https://docs.oasis-open.org/virtio/virtio/v1.2/csd01/virtio-v1.2-csd01.html This crate utilizes the rutabaga crate from crosvm with some minor modification to rutabaga crate to fix compilation. This crate depends on this PR[rust-vmm/vhost#239] that implements support for QEMU's vhost-user-gpu protocol. This crate supports both gfxstream and virglrenderer library either of these libraries can be used by simply changing the `renderer` command line option. This crate also includes some modifications from libkrun virtio-gpu device https://github.com/containers/libkrun/tree/main/src/devices/src/virtio/gpu This device can be tested following the instructions explained in the README.md file under staging/vhost-device-gpu/. Fixes: rust-vmm#598 Co-authored-by: Dorinda Bassey <[email protected]> Co-authored-by: Matej Hrica <[email protected]> Signed-off-by: Dorinda Bassey <[email protected]> Signed-off-by: Matej Hrica <[email protected]>
Summary of the PR
Me and @dorindabassey have been working on this PR, which adds support for the QEMU's vhost-user-gpu protocol.
This is a protocol for sending messeges from backend to the fronted, it is needed to implement display output in QEMU to implement a vhost-user-gpu device.
See issue #236
This feature is very similar to the
SET_BACKEND_REQ_FD
, so it is implemented in a similar way.Support is only added for sending these vhost messages from backend to frontend. Support for handling this protocol on frontend is not implemented.
The protocol is very similar to the normal vhost protocol, but the valid header flags of the
VhostUserMsgHeader
and the newly introducedVhostUserGpuMsgHeader
are different. (There is no version bit, only reply bit is specified). So theEndpoint
utility was made generic over the header type, not just the request. Unfortunately there is another issue, that the messagesVHOST_USER_GPU_SCANOUT
andVHOST_USER_GPU_CURSOR_UPDATE
are bigger than theMAX_MSG_SIZE
. So we added methods for sending bigger messages toEndpoint
.vhost/vhost/src/vhost_user/message.rs
Lines 26 to 33 in bd6bf13
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 thesummary and max 75 characters for each description line.
test.
Release" section of CHANGELOG.md (if no such section exists, please create one).
unsafe
code is properly documented.