Comments (6)
rust-vmm/vhost#215 and rust-vmm/vhost#208 are an examples where this would have helped.
The helper should probably also check that the types of the fields are only integeral types that can be safely assigning from byte slices. Checking repr(C) would also help.
from vm-memory.
As @roypat suggested on #274, there is https://docs.rs/zerocopy/latest/zerocopy that may be useful here. However, it only allows (de)serializing from and to &[u8]. That does not work for our volatile memory scenarios. But maybe one could contribute a pointer based API towards that crate? 🤔
from vm-memory.
I don't think we'd need a pointer based API for zerocopy, our ByteValued
trait only operates on slices (its Bytes
that uses pointers, but this trait is about containers that allow byte-level access to its contents, such as guest memory, not about PODs. So the Bytes
trait would have its ByteValued
bounds updated to whatever the zerocopy equivalent is)
from vm-memory.
It seems that rust-vmm/acpi_tables has done the switch from ByteValued
to zerocopy a while ago, and it seemed to have gone smoothly: https://github.com/rust-vmm/acpi_tables
I think doing this can be a good first step towards reducing our confusing jungle of traits
from vm-memory.
Ah. You are right. I misunderstood the API. I thought that it would require an additional copy from the slice to the object. But it just turns a reference to a slice into a reference to a struct instance. So we can just copy to a slice and then use zerocopy.
from vm-memory.
I have a crate that solves this without requiring any procedural macros.
from vm-memory.
Related Issues (20)
- Update vmm-sys-util dependency to 0.11.0
- Sorry, wrong proces
- Tests fail on 32-bit HOT 2
- tests: "We need to get a mut reference to `self.container`." from non-mut &self reference is UB HOT 2
- While this might be correct for all usecases, this is not safe for 100% of host target scenarios. Quoting the docs: HOT 1
- Publish v0.12.1 HOT 1
- Unsoundness: VolatileMemory should be `unsafe`, private, or sealed because it relies on get_slice in unsafe code HOT 3
- vm-memory with perisistent memory
- Build errors with latest nightly toolchain `cargo 1.75.0-nightly (65e297d1e 2023-11-03)` HOT 3
- Crate does not build on nightly HOT 2
- Missing Divide-by-Zero Check
- GuestMemory::try_access() Invariant not Checked
- Test breaking changes against other crates in rust-vmm
- Test `GuestMemory::try_access` error cases
- Unsoundness in `get_atomic_ref` in `volatile_memory.rs` HOT 3
- Get a slice of a `GuestRegionMmap` HOT 5
- `MmapRange` under `xen` feature flag HOT 7
- `GuestMemory` permissions HOT 1
- Extend to confidential computing HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vm-memory.