-
Notifications
You must be signed in to change notification settings - Fork 47
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 vhost-user-vsock device emulation #216
Conversation
v2:
TODO:
|
v3:
TODO:
|
v4:
I hope the coverage is not that bad, and we can merge this. In the future we can try to increase it, adding more moks. |
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've tested the daemon on my setup and everything looks pretty good to me. I have added a few comments about removing commented out code and cleaning up the println -> info!,warn! and debug! macros. I think the remaining TODOs and further increasing the coverage can be done once this is merged.
v5:
|
@stsquad thanks for testing and reviews! I just addressed all your comments and pushed the new version |
I will start looking into this pull request in the coming days. Given its sheer size I expect the review process to take several days. I will clearly let you know when I am done. |
@mathieupoirier thank you very much! Yep, take your time. I have taken up Harsha's work, so some part may be unknown to me too ;-) |
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.
About code coverage, I looked at kcov_output/ to see what all is missed and there are things we can easily cover I think. For example main.rs::start_backend_server() and a lot of other code in vhu_vsock_thread.rs which is not covered as of now in tests.
@@ -0,0 +1,111 @@ | |||
// SPDX-License-Identifier: Apache-2.0 or BSD-3-Clause |
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.
During the reviews of I2C crate, a lot of feedback was received, mostly from Andreea. I am mostly going to pass that on here. I (and maybe @mathieupoirier too) would like to keep the same kind of formatting / parsing / layout for all crates in here, which makes going through them much easier when they look alike.
For example for the current crates, we only mentioned Apache-2.0. If we want to add BSD too, then maybe add it to all of them ?
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'm not the original author of this code, so I just added the SPDX-License-Identifier following what Harsha specified in his Cargo.toml.
I'm open to change on Apache-2.0 only, but we need an approval from @harshanavkis.
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.
Fine by me.
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.
@harshanavkis thanks for your ACK, I'll prepare a PR to re-license vhost-user-vsock as Apache-2.0 only.
use vhost::{vhost_user, vhost_user::Listener}; | ||
use vhost_user_backend::VhostUserDaemon; | ||
use vhu_vsock::{VhostUserVsockBackend, VsockArgs, VsockConfig}; | ||
use vm_memory::{GuestMemoryAtomic, GuestMemoryMmap}; |
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.
We have separated the headers intro three groups in existing crates, first one for standard headers, second one for external ones (like vhost), and last one for vsock local ones. All groups separated by blank lines.
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.
Ack
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 i2c and gpio I see use log...
in the first group. IIUC log
is an external crate. Should it be in the second group?
I agree, but can we postpone? |
It is always better / easier to fix things at review time as they are lost otherwise. But I do get what you are saying here. Please do whatever changes you can to the current patches, based on current comments, and we will get it merged. I can also try to spend some cycles on this then and raise issues too. |
I totally agree with you, but since I'm not the author, it's like doing a review every time to see if what I'm testing or changing makes sense :-)
Thank you for understanding, I will do my best. |
This commit introduces a vhost-user-vsock device that enables communicaton between an application running in the guest i.e inside a VM and an application running on the host i.e outside the VM. The device exposes unix sockets to which the VMM and host-side applications connect to. Applications in the guest communicate over VM sockets. Applicaitons on the host connect to the unix socket i.e communicate over AF_UNIX sockets. Signed-off-by: Harshavardhan Unnibhavi <harshanavkis@gmail.com> [sgarzare: rebased, updated Cargo.lock, updated clap version to avoid build issues, and fixed clap issues with the new version] Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
clippy complains of some minor issues, probably because the new version has been improved. Let's fix them. Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
Update the dependencies aligning with the other crates in this workspace. Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
clap::App::from_yaml() is deprecated since clap-3.0.0, let's switch to clap::Parser. Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
Replace our VsockPacket with the new one implemented in the virtio-vsock crate. Based on Alex Bennée and Laura Loghin commit: stsquad@6752266608dd To achieve this the following changes where made: - deleted the internal packet.rs - convert the send_pkt/recv_pkt helpers to be BitmapSlice aware - update push from LocalTxBuf - tweak a few API calls due to minor diffs Fixed tests and moved some helpers from the removed vsock/src/packet.rs file. Co-developed-by: Laura Loghin <lauralg@amazon.com> Co-developed-by: Alex Bennée <alex.bennee@linaro.org> Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
Harsha specified `license = "Apache-2.0 OR BSD-3-Clause"` in vsock/Cargo.toml, so let's add a properly SPDX tag in the vsock files. Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
Remove old comments, useless code, and code commented. Avoid println!() to print messages and replaced with dbg!(), info!(), or error!(). Also init `env_logger` like other daemons in the main(). Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
Instead of panic if the local peer doesn't send "connect PORT\n" correctly, let's print an error, ignoring the command. Print an error message also when allocating local port fails. Reported-by: Alex Bennée <alex.bennee@linaro.org> Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
If we don't remove any bytes from the buffer, it's useless to send a credit update since the credit hasn't changed. Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
Instead of panic, let's propagate errors or print warnings where we can't. Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
VIRTIO spec defines `guest_cid` in LE byte order. Let's introduce VirtioVsockConfig based on the virtio-spec 1.2. For now it contains only `guest_cid`, but in the future it could contain other fields. Let's also handle correctly `offset` and `size`, returning an empty Vec if they are not valid. Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
Add several tests to get good coverage. Unfortunately, it's a lot of new code and not easy to test everything. We may add more mocks and tests in the future. Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
This is a binary crate and most of the types shouldn't be visible out of this crate. Change also documentation with ///. If we would like to export some types as part of a library in the future, we will adjust the visibility accordingly. Suggested-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
VsockArgs is used only by main.rs, so we can move its definition there. Let's also move the test. Suggested-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
In several places the "vsock_" prefix doesn't add much and makes names longer, let's remove it where it's not needed. Suggested-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
Following the other crates, reorder the use declaration in 3 groups: 1. standard library 2. external crates 3. local crates Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
v6:
TODO:
|
@vireshk @stsquad @mathieupoirier I just pressed the button to request Alex's review and GH messed up other requests. Sorry about that ;-) |
I see that Viresh has beaten me to the punch on reviewing this pull request. There is no need to do things twice, especially with a patchset this big, and as such will not continue with this work. |
You can approve it for now, I have already done so and we will continue to modify it to make it similar to other crates and fix any more issues we find later. |
This PR is based on #7.
@harshanavkis implemented a vhost-user-vsock device for a GSoC 2021 project mentored by me and @fidencio.
His PR was in a great state, I just rebased and completed the following items to be able to merge this project that could be very useful:
App::from_yaml()
clippy
CONNECT 1234
is wrong, use virtio-vsock 0.1.0 crate from @lauralt )SPDX-License-Identifier
in each vsock file