MshvError allows different kinds of errors to be returned from the
library. One intended use is to return details about a failed hypercall
from the MSHV_ROOT_HVCALL ioctl, so useful error messages can be
printed.
Implement from_hvcall for future use with MSHV_ROOT_HVCALL, along with
tests.
Use into() to convert uses of errno::Error to MshvError.
The only way to debug hypercall failures that result from the IOCTL calls in mshv-ioctls today, is to use dmesg and rely on debug printing in the kernel itself.
The MshvError type is the first step to solving thism this by allowing mshv-ioctls to return either an errno::Error or details about a hypercall-related error (hypercall code and status code).
This will help users/developers of VMMs identify the root cause of issues more reliably.
This PR introduces a couple of dependencies:
https://crates.io/crates/thiserror is used in many places in rust-vmm to create error enums with automatically generated From and Display traits. Similarly, here it is used to define MshvError.
https://crates.io/crates/num_enum is the defacto way to convert integers to enums by implementing the TryFromPrimitive trait. It is used to convert u16 to enum HvError. If there is a better way to do this please let me know!
Since this PR changes the Result type used by mshv-ioctls, it may cause API breakages with other crates. From testing with Cloud Hypervisor, I have only found one, in the vfio-ioctls crate. It is fixed in a backward-compatible manner here: https://github.com/rust-vmm/vfio/pull/44
Requirements
Before submitting your PR, please make sure you addressed the following
requirements:
[x] All commits in this PR have Signed-Off-By trailers (with
git commit -s), and the commit message has max 60 characters for the
summary and max 75 characters for each description line.
[x] All added/changed functionality has a corresponding unit/integration
test.
[x] All added/changed public-facing functionality has entries in the "Upcoming
Release" section of CHANGELOG.md (if no such section exists, please create one).
[x] Any newly added unsafe code is properly documented.
MshvError allows different kinds of errors to be returned from the library. One intended use is to return details about a failed hypercall from the MSHV_ROOT_HVCALL ioctl, so useful error messages can be printed.
Implement from_hvcall for future use with MSHV_ROOT_HVCALL, along with tests.
Use into() to convert uses of errno::Error to MshvError.
Summary of the PR
This is a precursor patch to https://github.com/rust-vmm/mshv/pull/128.
The only way to debug hypercall failures that result from the IOCTL calls in
mshv-ioctls
today, is to use dmesg and rely on debug printing in the kernel itself.The MshvError type is the first step to solving thism this by allowing
mshv-ioctls
to return either anerrno::Error
or details about a hypercall-related error (hypercall code and status code).This will help users/developers of VMMs identify the root cause of issues more reliably.
This PR introduces a couple of dependencies:
From
andDisplay
traits. Similarly, here it is used to define MshvError.TryFromPrimitive
trait. It is used to convertu16
toenum HvError
. If there is a better way to do this please let me know!Since this PR changes the
Result
type used by mshv-ioctls, it may cause API breakages with other crates. From testing with Cloud Hypervisor, I have only found one, in the vfio-ioctls crate. It is fixed in a backward-compatible manner here: https://github.com/rust-vmm/vfio/pull/44Requirements
Before submitting your PR, please make sure you addressed the following requirements:
git commit -s
), and the commit message has max 60 characters for the summary and max 75 characters for each description line.unsafe
code is properly documented.