forked from rust-vmm/vmm-reference
-
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.
main: Handle errors gracefully in main()
Handle calls to VMM::try_from() or vmm.run(). This commit adds anyhow and thiserror crates to handle errors. The `anyhow` crate is used in the main binary to add extra context and give a pretty view of error trace. The create `thiserror` was used to easily derive `std::error::Error` for errors provided by libs. The new crates pulls the following extra crates: ```diff +name = "proc-macro2" +name = "quote" +name = "syn" +name = "thiserror-impl" +name = "unicode-xid" ``` New error format: examples: ```sh $ vmm-reference --kernel \ path=/path/vmlinuz-5.10.25 Error: Failed to create VMM from configurations Caused by: Error issuing an ioctl to KVM. $ echo $? 1 ``` ```sh $ vmm-reference --kernel path Error: Failed to parse CLI options Caused by: Failed to parse cli Invalid input for kernel: Missing required argument: path ``` ``` $vmm-reference Error: Failed to parse CLI options Caused by: Failed to parse cli error: The following required arguments were not provided: --kernel <kernel> USAGE: vmm-reference [OPTIONS] --kernel <kernel> For more information try --help ``` Fixes: rust-vmm#99 Signed-off-by: Carlos Venegas <[email protected]>
- Loading branch information
Showing
7 changed files
with
141 additions
and
48 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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 |
---|---|---|
|
@@ -6,5 +6,6 @@ edition = "2018" | |
|
||
[dependencies] | ||
clap = "2.33.3" | ||
thiserror = "1.0" | ||
|
||
vmm = { path = "../vmm" } |
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
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
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 |
---|---|---|
|
@@ -5,6 +5,7 @@ authors = ["rust-vmm AWS maintainers <[email protected]>"] | |
edition = "2018" | ||
|
||
[dependencies] | ||
thiserror = "1.0" | ||
|
||
event-manager = "0.2.1" | ||
kvm-bindings = { version = "0.4.0", features = ["fam-wrappers"] } | ||
|
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