Comments (5)
I often use weak pointers in event callbacks for the vmi implementation in my company. Helps to alleviate segfaults. ;)
from libmicrovmi.
The default response sent in drop
does not make much sense to me. I would like more control of what I send.
Also, I wonder if this will complicate implementation because we may need to add quite a few logic in the drop
function. The function may need to know whether a response by user has already been sent before it sends a default one.
Moreover, I will think twice before adding a reference to Introspectable
, which may bring some troubles with the borrow checker.
from libmicrovmi.
Also, I wonder if this will complicate implementation because we may need to add quite a few logic in the drop function. The function may need to know whether a response by user has already been sent before it sends a default one.
A boolean would suffice
#[repr(C)]
pub struct Event {
pub vcpu: u16,
pub kind: EventType,
driver: &dyn Introspectable, // pseudo code here, this might not be Rust compatible
reply_sent: bool,
}
impl Event {
// this API should be called to clearly define what event reply you want
fn reply(reply_type: ReplyEventType) -> Result<(), Box<dyn Error>> {
self.driver.reply_event(self, reply_type)?;
Ok(())
}
}
impl Drop for Event {
fn drop(&self) {
if !self.reply_sent {
self.reply(self, ReplyEventType::Continue);
self.reply_sent = true;
}
}
}
Moreover, I will think twice before adding a reference to Introspectable, which may bring some troubles with the borrow checker.
Yes, when I tried to implement it, I have issues with the lifetimes and such, so I gave up.
from libmicrovmi.
Yes, when I tried to implement it, I have issues with the lifetimes and such, so I gave up.
You could use reference counting instead. I know this is very C++-ish, but this would allow you to store non-owning references aka weak pointers in your event. You need to upgrade weak pointers if you want to use them and this will fail if the object does not exist anymore. Might be worth a shot.
https://doc.rust-lang.org/std/rc/struct.Weak.html
from libmicrovmi.
Here is an idea: Why don't we have something like an event supervisor? The only way to listen for events is to register callbacks with the event supervisor. This would allow us to shape how events have to be handled. For example we could enforce an event reply by defining the reply as the return value of the callback.
from libmicrovmi.
Related Issues (20)
- RUSTSEC-2020-0095: difference is unmaintained
- Init function should be fallible HOT 1
- Driver initialization should be fallible HOT 1
- Build system: opportunistic drivers
- Volatility3 integration HOT 10
- libmicrovmi python bindings HOT 19
- KVM: Handle read size > 4K
- API: remove get_page_access HOT 2
- Design: refactoring read_physical API HOT 2
- Include libmicrovmi.h generated C header into the Debian package HOT 2
- xen libraries linked with libmicrovmi.so
- Add technical documentation HOT 1
- LeechCore integration HOT 34
- Design: Driver initialization argument handling HOT 6
- RUSTSEC-2020-0077: memmap is unmaintained
- Native VirtualBox driver via builtin debugger interface HOT 3
- Windows release
- RUSTSEC-2021-0119: Out-of-bounds write in nix::unistd::getgrouplist
- Memflow support; current state of the art
- Can't Install on Arch Based Systems HOT 4
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 libmicrovmi.