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
virtctl: improve usbredir as module #11643
base: main
Are you sure you want to change the base?
virtctl: improve usbredir as module #11643
Conversation
@victortoso you are changing the flag |
Ok, sorry, this is a local flag not for the command. Ignore my comment |
Looks great! |
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.
note for me: I need to review the last 3 commits again.
a303ec8
to
91b7f86
Compare
New changes are detected. LGTM label has been removed. |
91b7f86
to
4e65621
Compare
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
@xpivarc, i've updated with requested changes/suggestions. |
4e65621
to
409cbc3
Compare
/test pull-kubevirt-unit-test-arm64 |
Using bus-device is specially helpful when the user has multiple identical devices but want to pick which one goes to which VMI. Using "bus-device" format was always possible, just not properly documented. Also adds proper examples in the usage() method. Signed-off-by: Victor Toso <victortoso@redhat.com>
This should only be used in the read/write scope of that goroutine. Use a select to properly handle local or remote completion. Signed-off-by: Victor Toso <victortoso@redhat.com>
The expected end of USB redirection is only when the user to stop sharing the USB devices. If the connection is closed without expecting it, we should treat it as error. The follow up patch "virtctl: usbredir: Add Stop() to Client" will improve this logic to make it clear when we expected it to stop. Signed-off-by: Victor Toso <victortoso@redhat.com>
We don't have to hardcode 'localhost' and do extra code here. Signed-off-by: Victor Toso <victortoso@redhat.com>
We need interrupt channel for signal.Notify() and we can use it to replace sigStopChan. This also allows us to remove it the extra goroutine. Signed-off-by: Victor Toso <victortoso@redhat.com>
The main goal is to reuse this type for testing. Similar logic is being duplicated here and tests/usbredir_test.go making it harder to write bug reproducer as functional test. Some variables were renamed too when moved as part of Client struct. Signed-off-by: Victor Toso <victortoso@redhat.com>
Add context when running usbredirect binary so we can stop it based on request. This request is provided by a Stop() method of Client. This is to be used by tests in the follow-up patch. Signed-off-by: Victor Toso <victortoso@redhat.com>
This ensures that the same code used in virtctl to run and manage the data from usbredirect binary are also used in the tests. This also adds a test to expect failure when limit of v1.UsbClientPassthroughMaxNumberOf devices is reached. Signed-off-by: Victor Toso <victortoso@redhat.com>
409cbc3
to
b7dfa95
Compare
Rebased. Had conflict with c8d63db |
/test pull-kubevirt-conformance-arm64 @xpivarc let me know if you have further comments on this one |
What this PR does
Before this PR:
The
virctl usbredir
command was a big script that was hard to be re-used. The functional tests inusbredir_test.go
were not testing virtctl's code at all, instead it was re-implementing the client logic without callingusbredirect
binary.After this PR:
The
virtctl usbredir
is broken down with a Client type with init, run and stop functions. The functional test makes usage of this.Fixes #Why we need it and why it was done in this way
The following tradeoffs were made:The following alternatives were considered:Links to places where the discussion took place:Special notes for your reviewer
I'm interested in expanding a bit the virtctl/usbredir module to have a little bit more knowledge of usbredir protocol in a follow-up, in order to fetch details of devices being redirected by virtctl and expose that information to users. This PR is a somewhat 'cleaning the house' step before that.
Checklist
This checklist is not enforcing, but it's a reminder of items that could be relevant to every PR.
Approvers are expected to review this list.
Release note