rust: cell: add BQL-enforcing RefCell variant
authorPaolo Bonzini <pbonzini@redhat.com>
Fri, 15 Nov 2024 11:20:35 +0000 (12:20 +0100)
committerPaolo Bonzini <pbonzini@redhat.com>
Tue, 10 Dec 2024 17:49:26 +0000 (18:49 +0100)
commitc596199f639cdf4cc021c9bc076e4a1e64e9d50f
treeb03baf9bffed81111d5280bbca9eb6ef4dc7c498
parent8e194c0ea5cdbae05b77125a582f9927678121ee
rust: cell: add BQL-enforcing RefCell variant

Similar to the existing BqlCell, introduce a custom interior mutability
primitive that resembles RefCell but accounts for QEMU's threading model.
Borrowing the RefCell requires proving that the BQL is held, and
attempting to access without the BQL is a runtime panic.

Almost all of the code was taken from Rust's standard library, while
removing unstable features and probably-unnecessary functionality that
amounts to 60% of the original code.  A lot of what's left is documentation,
as well as unit tests in the form of doctests.  These are not yet integrated
in "make check" but can be run with "cargo test --doc".

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
rust/qemu-api/Cargo.toml
rust/qemu-api/meson.build
rust/qemu-api/src/cell.rs