Skip to content
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-device I2C support #1

Merged
merged 9 commits into from
Aug 19, 2021
Merged

Conversation

vireshk
Copy link
Collaborator

@vireshk vireshk commented May 26, 2021

Hi @andreeaflorescu

Earlier discussion: rust-vmm/community#106

I have tried to migrate my existing i2c work over to this repository and did whatever made sense to me (in respect to the workspace thing). There are high chances that I might have made some mistakes here.

I know there would be a lot of things that would require improvement in the i2c code as well as I am really a newbie to the rust world, apologies in advance for reviewing not so great code.

Thanks

i2c/Cargo.toml Outdated
authors = ["Viresh Kumar <viresh.kumar@linaro.org>"]
description = "vhost i2c backend device"
repository = "https://github.com/rust-vmm/vhost-device"
edition = "2018"
Copy link
Member

Choose a reason for hiding this comment

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

Can you add all the fields that were in the root Cargo.toml?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

i2c/Cargo.toml Outdated
@@ -9,3 +9,11 @@ edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
clap = { version = "2.33.3", features = ["yaml"] }
epoll = "4.3"
Copy link
Member

Choose a reason for hiding this comment

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

Can you use vmm-sys-util instead? We have an epoll wrapper there that is relatively safer than the epoll as it checks the results of unsafe functions.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Can you use vmm-sys-util instead? We have an epoll wrapper there that is relatively safer than the epoll as it checks the results of unsafe functions.

I used epoll instead as https://github.com/rust-vmm/vhost-user-backend uses the same and my repo depends on a function prototype from there.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Is that fine @andreeaflorescu ?

Copy link
Member

Choose a reason for hiding this comment

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

Oh, I see. Okay.

@andreeaflorescu
Copy link
Member

We have to setup the repo & the CI as well.

@andreeaflorescu
Copy link
Member

We have to setup the repo & the CI as well.

I've setup the Buildkite CI. On the next push we should be able to see the results of running the pipeline.

README.md Outdated Show resolved Hide resolved
- What are the main components of the crate? How do they interact which each
other?
This repository hosts various 'vhost-user' device backends in their own crates.
See their individual README.md files for specific information about those
Copy link
Member

Choose a reason for hiding this comment

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

How about also mentioning all these devices (which right now is just one 😆) here as well, and have a link that takes you to their readme?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

i2c/README.md Outdated
work with any virtual machine monitor (VMM) that supports vhost-user. See the
Examples section below.

##Synopsis
Copy link
Member

Choose a reason for hiding this comment

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

nit: need space after ##.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

thx, done

@andreeaflorescu
Copy link
Member

@vireshk this is the first time we run the tests for a workspace, so there might be problems that we discover along the way and that we might need to address.

It looks like one potential problem is that the coverage seems to be 0%. This means that it is not correctly computed by test_coverage. We should look into that as well, and maybe open separate issues in rust-vmm-ci for the problems we discover along the way.

@vireshk
Copy link
Collaborator Author

vireshk commented May 27, 2021

@vireshk this is the first time we run the tests for a workspace, so there might be problems that we discover along the way and that we might need to address.

It looks like one potential problem is that the coverage seems to be 0%. This means that it is not correctly computed by test_coverage. We should look into that as well, and maybe open separate issues in rust-vmm-ci for the problems we discover along the way.

Okay, meanwhile I am trying to fix all the problems reported by the bot and commented on by you.

Few doubts though:

  • Are frequent pushes to my master branch fine ? I see that the pull requests mentions them and so thought..
  • What should I do once I have worked up on the stuff and want them to get reviewed again ? The same pull request will work or a new one needs to be created ?

@andreeaflorescu
Copy link
Member

  • Are frequent pushes to my master branch fine ? I see that the pull requests mentions them and so thought..

Yes, that's okay. That's the development method that we are following.

  • What should I do once I have worked up on the stuff and want them to get reviewed again ? The same pull request will work or a new one needs to be created ?

You can just ping people when you want to look at your code again. Some folks are automatically following all repositories created in rust-vmm, but you can also ask on Slack or ping people here on GitHub. We do not have a predefined process for this.

@vireshk vireshk force-pushed the master branch 8 times, most recently from ef87941 to e349285 Compare May 27, 2021 11:01
@vireshk
Copy link
Collaborator Author

vireshk commented May 27, 2021

It looks like one potential problem is that the coverage seems to be 0%. This means that it is not correctly computed by test_coverage. We should look into that as well, and maybe open separate issues in rust-vmm-ci for the problems we discover along the way.

@andreeaflorescu I was able to get rid of all other errors and warnings, and only two are leftL coverage-x86 and cargo-audit and I do not understand how to fix them. If there is something wrong in my repo or it is because of the workspace thing you mentioned. will it be possible for you to look at it?

@vireshk
Copy link
Collaborator Author

vireshk commented May 27, 2021

I have tried to migrate my existing i2c work over to this repository and did whatever made sense to me (in respect to the workspace thing). There are high chances that I might have made some mistakes here.

@andreeaflorescu I have updated the code based on your feedback and all the errors generated by the CI. Please give it another glance once you get a chance. Thanks.

@andreeaflorescu
Copy link
Member

It looks like you're pulling a dependency on a vulnerable crate: https://buildkite.com/rust-vmm/vhost-device-ci/builds/12#ede8f33d-722f-4da2-a7ff-57b9e2d218f7. Can you update that?

Can you try some configurations with the workspace such that the coverage is correctly computed? To do that, you'll need to follow the instructions from here: https://github.com/rust-vmm/rust-vmm-ci#adaptive-coverage to run the coverage test. The latest container version is 11. To check the coverage result, you'll need to run the command with --no-cleanup:

pytest  rust-vmm-ci/integration_tests/test_coverage.py --no-cleanup

You will find the aggregated coverage results in kcov_output/index.html.

@andreeaflorescu
Copy link
Member

Can you try some configurations with the workspace such that the coverage is correctly computed? To do that, you'll need to follow the instructions from here: https://github.com/rust-vmm/rust-vmm-ci#adaptive-coverage to run the coverage test. The latest container version is 11. To check the coverage result, you'll need to run the command with --no-cleanup:

pytest  rust-vmm-ci/integration_tests/test_coverage.py --no-cleanup

You will find the aggregated coverage results in kcov_output/index.html.

LE: it looks like this PR adds no unit tests. Can you add some? Since this crate exports a binary, it might make sense to also have an integration test.

Cargo.toml Outdated

[dependencies]
members = [
"i2c",
Copy link
Member

Choose a reason for hiding this comment

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

Can you move this under the src/ directory? Otherwise we are going to have lots of things in the root of the repository as we add more devices.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Can you move this under the src/ directory? Otherwise we are going to have lots of things in the root of the repository as we add more devices.

done

@vireshk
Copy link
Collaborator Author

vireshk commented May 27, 2021

It looks like you're pulling a dependency on a vulnerable crate: https://buildkite.com/rust-vmm/vhost-device-ci/builds/12#ede8f33d-722f-4da2-a7ff-57b9e2d218f7. Can you update that?

I have this in my dependencies:

clap = { version = "2.33.3", features = ["yaml"] }

This clap crate is fetching yaml-rust (I am not doing that directly) and in there somehow the versioning thing is getting screwed up.

Here is clap's dependency, which looks just fine:
https://github.com/clap-rs/clap/blob/master/Cargo.toml#L70

yaml-rust = { version = "0.4.1", optional = true }

What should I be doing here to fix this ?

@vireshk vireshk force-pushed the master branch 3 times, most recently from 9f5a8e5 to b5d906d Compare May 28, 2021 07:49
@vireshk
Copy link
Collaborator Author

vireshk commented May 28, 2021

What should I be doing here to fix this ?

I have raised an issue for this with clap, something is wrong.

clap-rs/clap#2506

@vireshk
Copy link
Collaborator Author

vireshk commented Aug 3, 2021

@andreeaflorescu is there anything else you would like me to fix here ?

@andreeaflorescu gentle reminder!

@vireshk
Copy link
Collaborator Author

vireshk commented Aug 17, 2021

@jiangliu I have lost your review by mistake. Ideally I should have just added a patch on top, but instead did force-push by mistake. By the time I realized I made the mistake, I coulnd't do anything to get your review back.

Here is what changed since the time you reviewed this: https://pastebin.com/PDQqvS4G

@vireshk
Copy link
Collaborator Author

vireshk commented Aug 17, 2021

@andreeaflorescu Clap requires rustc >= 1.54, how do I fix that to make the build work ?

@andreeaflorescu
Copy link
Member

Do you need the latest version of clap? Can you fix the dependency to a version that doesn't need the latest version?

@andreeaflorescu
Copy link
Member

@vireshk I am not following this repository. If you need my help, can you ping me on Slack/email?

This adds the boilerplate code and its dependencies to get the basic
structure for the i2c crate.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
This patch implements the low level I2C helpers responsible for
transferring data and parsing the adapters and their clients.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
This patch implements process_queue() to process incoming requests.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
This updates the main README and adds a specific one for i2c crate.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
This adds unit tests for the i2c workspace.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
@vireshk
Copy link
Collaborator Author

vireshk commented Aug 17, 2021

Do you need the latest version of clap? Can you fix the dependency to a version that doesn't need the latest version?

Done.

@vireshk
Copy link
Collaborator Author

vireshk commented Aug 17, 2021

@vireshk I am not following this repository. If you need my help, can you ping me on Slack/email?

Sure.

Though this stuff is ready to be merged. @jiangliu has already given his review-approval for this. Can you give yours too if everything looks okay ?

Reduce the test coverage score as the files apart from i2c.rs are
mostly boilerplate code and it is difficult to test them as well as it
may not be worth it.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
@andreeaflorescu
Copy link
Member

I will not be able to review the code as we are unlikely to use it in the near future, and I currently have other priorities. I can give a formal approve so you can merge the code. It would be good to find another crate owner that can help with reviewing subsequent PRs. We require 2 approvals for PRs to be merged.

I think @sboeuf had some concerns related to publishing this crate before the driver changes are merged in upstream Linux. Are those now merged?

Before publishing this crate to crates.io, can you please check the requirements for publishing? I am mostly concerned about the coverage which is still very low compared to the other rust-vmm crates. We can merge this initial PR first, and work on incremental changes to make sure we keep the same quality bar as for existing components. Does that make sense?

@vireshk
Copy link
Collaborator Author

vireshk commented Aug 17, 2021

I will not be able to review the code as we are unlikely to use it in the near future, and I currently have other priorities. I can give a formal approve so you can merge the code. It would be good to find another crate owner that can help with reviewing subsequent PRs. We require 2 approvals for PRs to be merged.

Sure.

I think @sboeuf had some concerns related to publishing this crate before the driver changes are merged in upstream Linux. Are those now merged?

It is already accepted by the I2C maintainer, and is waiting for a dependency patch to land in first.
https://lore.kernel.org/linux-i2c/YQEkWL3ZQzbiMVl6@kunai/

Before publishing this crate to crates.io, can you please check the requirements for publishing? I am mostly concerned about the coverage which is still very low compared to the other rust-vmm crates.

The part which is missing the testing is vhu_i2c.rs, which is mostly the implementation of vhost-user-backend device and I am not sure how to add testing code for it, since the same is missing here: https://github.com/rust-vmm/vhost-user-backend

We can merge this initial PR first, and work on incremental changes to make sure we keep the same quality bar as for existing components. Does that make sense?

Sure.

@vireshk
Copy link
Collaborator Author

vireshk commented Aug 18, 2021

I think @sboeuf had some concerns related to publishing this crate before the driver changes are merged in upstream Linux. Are those now merged?

And it is merged finally.

https://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git/commit/?h=i2c/for-next&id=8fb12751ac78d0a4ba3c604496ffc8dcd1bd6c31

@sboeuf
Copy link

sboeuf commented Aug 18, 2021

And it is merged finally.

Cool! Let's proceed with this PR then :)

@andreeaflorescu andreeaflorescu merged commit 019e755 into rust-vmm:master Aug 19, 2021
@vireshk vireshk deleted the master branch August 25, 2021 07:11
stsquad pushed a commit to stsquad/vhost-device that referenced this pull request Jul 20, 2023
virtio_sound.rs: Added device configuration and common definitions
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.

5 participants