You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We want a trait like `GuestAddressSpace` for `IoMemory`, but just
duplicating it into an `IoAddressSpace` trait is not so easy:
We could rename the current `GuestAddressSpace` to `IoAddressSpace` and
require `M: IoMemory` (instead of `M: GuestMemory`), and then define
`GuestAddressSpace` as:
```rust
pub trait GuestAddressSpace: IoAddressSpace<M: GuestMemory> {}
impl<AS: IoAddressSpace> GuestAddressSpace for AS
where
AS::M: GuestMemory,
{}
```
But doing just this would break all existing `GuestAddressSpace` users,
as they’d now need to import `IoAddressSpace` to use `memory()`.
(Re-)Adding `GuestAddressSpace::memory()` as
```rust
fn memory(&self) -> <Self as IoAddressSpace>::T {
IoAddressSpace::memory(self)
}
```
also doesn’t (just) work, as it gets the compiler confused which
`memory()` to use (between `GuestAddressSpace` and `IoAddressSpace`), so
the `IoAddressSpace::memory()` method would need to be called
differently. However, I would find that a bit silly, and it would also
then later require changes if the user wants to switch from
`GuestMemory` to `IoMemory`.
Instead just changing the `GuestAddressSpace::M: GuestMemory`
requirement to `M: IoMemory` seems easier:
- All callers that just use the `Bytes` interface remain completely
unchanged,
- It does break users that actually need the `GuestMemory` interface,
but from what I have seen, that is only the case for
`vhost::vhost_kern`. There, we can simply require that
`<AS as GuestAddressSpace>::M: GuestMemory`.
Signed-off-by: Hanna Czenczek <[email protected]>
0 commit comments