-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 26f2b74
Showing
26 changed files
with
40,304 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
|
||
[{*.go,.gitmodules,go.mod,go.sum}] | ||
indent_style = tab | ||
indent_size = 4 | ||
|
||
[*.{md,json}] | ||
indent_style = space | ||
indent_size = 2 | ||
trim_trailing_whitespace = false | ||
|
||
[*.{yml,yaml}] | ||
indent_style = space | ||
indent_size = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.go text eol=lf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: Release | ||
|
||
on: | ||
push: | ||
tags: | ||
- "v*.*.*" | ||
|
||
jobs: | ||
goreleaser: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: Set up Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: 1.23 | ||
- name: golangci-lint | ||
uses: golangci/golangci-lint-action@v6 | ||
with: | ||
version: v1.60 | ||
- name: Run GoReleaser | ||
uses: goreleaser/goreleaser-action@v6 | ||
with: | ||
version: latest | ||
args: release --clean | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
*.txt | ||
*.exe | ||
.vscode/launch.json | ||
auto-vfio |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
issues: | ||
# Set to 0 to disable. | ||
max-issues-per-linter: 0 | ||
# Set to 0 to disable. | ||
max-same-issues: 0 | ||
|
||
# Which dirs to exclude: issues from them won't be reported. | ||
# Can use regexp here: `generated.*`, regexp is applied on full path, | ||
# including the path prefix if one is set. | ||
# Default dirs are skipped independently of this option's value (see exclude-dirs-use-default). | ||
# "/" will be replaced by current OS file path separator to properly work on Windows. | ||
# Default: [] | ||
exclude-dirs: | ||
- .codecov | ||
- .github | ||
- .vscode | ||
- dist | ||
|
||
run: | ||
timeout: 2m | ||
|
||
linters: | ||
disable-all: true | ||
enable: | ||
# Simple linter to check that your code does not contain non-ASCII identifiers [fast: true, auto-fix: false] | ||
- asciicheck | ||
# checks whether HTTP response body is closed successfully [fast: false, auto-fix: false] | ||
- bodyclose | ||
# check the function whether use a non-inherited context [fast: false, auto-fix: false] | ||
- contextcheck | ||
# Computes and checks the cognitive complexity of functions [fast: true, auto-fix: false] | ||
- gocognit | ||
# Checks Go code for unused constants, variables, functions and types [fast: false, auto-fix: false] | ||
- unused | ||
# Errcheck is a program for checking for unchecked errors in go programs. These unchecked errors can be critical bugs in some cases [fast: false, auto-fix: false] | ||
- errcheck | ||
# Checks that sentinel errors are prefixed with the `Err` and error types are suffixed with the `Error`. [fast: false, auto-fix: false] | ||
- errname | ||
# errorlint is a linter for that can be used to find code that will cause problems with the error wrapping scheme introduced in Go 1.13. [fast: false, auto-fix: false] | ||
- errorlint | ||
# check exhaustiveness of enum switch statements [fast: false, auto-fix: false] | ||
- exhaustive | ||
# Gci controls golang package import order and makes it always deterministic. [fast: true, auto-fix: false] | ||
- gci | ||
# Provides diagnostics that check for bugs, performance and style issues. [fast: false, auto-fix: false] | ||
- gocritic | ||
# Inspects source code for security problems [fast: false, auto-fix: false] | ||
- gosec | ||
# Linter for Go source code that specializes in simplifying a code [fast: false, auto-fix: false] | ||
- gosimple | ||
# Vet examines Go source code and reports suspicious constructs, such as Printf calls whose arguments do not align with the format string [fast: false, auto-fix: false] | ||
- govet | ||
# Detects when assignments to existing variables are not used [fast: true, auto-fix: false] | ||
- ineffassign | ||
# Finds commonly misspelled English words in comments [fast: true, auto-fix: true] | ||
- misspell | ||
# Finds naked returns in functions greater than a specified function length [fast: true, auto-fix: false] | ||
- nakedret | ||
# Staticcheck is a go vet on steroids, applying a ton of static analysis checks [fast: false, auto-fix: false] | ||
- staticcheck | ||
# Like the front-end of a Go compiler, parses and type-checks Go code [fast: false, auto-fix: false] | ||
- typecheck | ||
# Reports ill-formed or insufficient nolint directives [fast: true, auto-fix: false] | ||
- nolintlint | ||
# Checks for misuse of Sprintf to construct a host with port in a URL. | ||
- nosprintfhostport | ||
# checks whether Err of rows is checked successfully in `sql.Rows` [fast: false, auto-fix: false] | ||
- rowserrcheck | ||
# Checks that sql.Rows and sql.Stmt are closed. [fast: false, auto-fix: false] | ||
- sqlclosecheck | ||
# Remove unnecessary type conversions [fast: false, auto-fix: false] | ||
- unconvert | ||
|
||
# Linters settings. | ||
linters-settings: | ||
gocognit: | ||
min-complexity: 35 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
version: 2 | ||
project_name: auto-vfio | ||
archives: | ||
- strip_binary_directory: true | ||
# format_overrides: | ||
# - goos: windows | ||
# format: zip | ||
files: | ||
- README.md | ||
name_template: "{{ .ProjectName }}_{{ .Tag }}_{{ .Os }}_{{ .Arch }}" | ||
builds: | ||
- env: | ||
- CGO_ENABLED=0 | ||
goos: | ||
- linux | ||
# - darwin | ||
# - windows | ||
goarch: | ||
- amd64 | ||
# - arm64 | ||
flags: | ||
- -mod=readonly | ||
- -trimpath | ||
ldflags: | ||
- -s | ||
- -w | ||
- -X=main.version={{.Tag}} | ||
checksum: | ||
name_template: "sha256sums.txt" | ||
algorithm: sha256 | ||
snapshot: | ||
name_template: "{{ .Tag }}-next" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"recommendations": [ | ||
"leodevbro.blockman", | ||
"weredev.copyrawvalue", | ||
"editorconfig.editorconfig", | ||
"usernamehw.errorlens", | ||
"golang.go", | ||
"ohanedan.lowlight-go-errors" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"go.lintTool": "golangci-lint", | ||
"go.lintFlags": [ | ||
"--fast" | ||
], | ||
"go.delveConfig": { | ||
"dlvFlags": [ | ||
// "--check-go-version=true" | ||
] | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2024 Dataflows | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
# auto-vfio | ||
|
||
Tool to automate the setup of VFIO passthrough on Linux systems. | ||
|
||
## Usage | ||
|
||
```properties | ||
Usage: auto-vfio <command> [flags] | ||
|
||
Automate the setup of VFIO passthrough on Linux systems | ||
|
||
Flags: | ||
-h, --help Show context-sensitive help. | ||
-c, --config-file="default.yaml" Config file location. Supported formats: .json, .yaml, .yml, .toml | ||
-l, --log-level="info" Logging level. One of: trace, debug, info, warn, error, fatal, panic | ||
|
||
Commands: | ||
list (l) [flags] | ||
List IOMMU groups and PCI devices | ||
|
||
rebind (r) --bus=bus-address1,... [flags] | ||
Rebind a device from its driver to vfio-pci | ||
|
||
version [flags] | ||
Show version information and exit | ||
|
||
Run "auto-vfio <command> --help" for more information on a command. | ||
``` | ||
|
||
### Rebind devices | ||
|
||
```properties | ||
Usage: auto-vfio rebind (r) --bus=bus-address1,... [flags] | ||
|
||
Rebind a device from its driver to vfio-pci | ||
|
||
Flags: | ||
-h, --help Show context-sensitive help. | ||
-c, --config-file="default.yaml" Config file location. Supported formats: .json, .yaml, .yml, .toml | ||
-l, --log-level="info" Logging level. One of: trace, debug, info, warn, error, fatal, panic | ||
|
||
-b, --bus=bus-address1,... Comma separated lisf of Bus addresses. Use 'list' command to get them. Example: 0000:07:00.0,0000:07:00.1 | ||
-p, --persist Persist binding to vfio-pci across reboots | ||
``` | ||
|
||
### List devices | ||
|
||
Output is similar to `lspci -nnk` but with additional information about IOMMU groups. Using <https://github.com/TimRots/gutil-linux> for interpreting PCI devices and vendors. | ||
|
||
```properties | ||
auto-vfio list | ||
|
||
Usage: auto-vfio list (c) [flags] | ||
|
||
List IOMMU groups and PCI devices | ||
|
||
Flags: | ||
-h, --help Show context-sensitive help. | ||
-c, --config-file="default.yaml" Config file location. Supported formats: .json, .yaml, .yml, .toml | ||
-l, --log-level="info" Logging level. One of: trace, debug, info, warn, error, fatal, panic | ||
|
||
--tree Hierarchical output | ||
-o, --output-format="" Output format. One of: json, yaml, xml, toml, props, shell, csv, tsv, | ||
-y, --yq=STRING YQ expression to apply to the output. Ignored if output format is not specified | ||
``` | ||
|
||
- Filtering devices with <https://mikefarah.gitbook.io/yq> expressions: | ||
|
||
```bash | ||
./auto-vfio list \ | ||
--tree \ | ||
--yq 'with_entries(select(.value[] | .DeviceClass | test("VGA")))' | ||
``` | ||
|
||
- **Note**: for `csv`/`tsv`, when filtering with yq, the resulting data must be flatened. | ||
|
||
For example, if you want to filter csv/tsv and pretty print only some columns: | ||
|
||
```bash | ||
./auto-vfio list \ | ||
--output-format=tsv \ | ||
--yq '[.[] | select(.DeviceClass | test("VGA")) | {"Group": .IommuGroup, "Bus": .Bus, "DeviceName": .DeviceName}]' | \ | ||
column -t -s $'\t' | ||
``` | ||
|
||
```properties | ||
Group Bus DeviceName | ||
17 0000:01:00.0 GA102 [GeForce RTX 3080 12GB] | ||
20 0000:07:00.0 AD107 [GeForce RTX 4060] | ||
``` | ||
|
||
## Develop | ||
|
||
- Build: `go build .` | ||
- Run: `go run .` | ||
- Test: `go test ./...` | ||
|
||
## License | ||
|
||
[MIT](LICENSE) |
Oops, something went wrong.