-
-
Notifications
You must be signed in to change notification settings - Fork 322
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor of Qemu configuration #2707
base: main
Are you sure you want to change the base?
Conversation
|
||
#[test] | ||
#[cfg(feature = "usermode")] | ||
fn usermode() { | ||
let program = "/bin/pwd"; | ||
let qemu = Qemu::builder().program("/bin/pwd").build().unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doens't the old API look better here? Can't we just keep Qemu::builder() and .build()
then calls Qemu::init_whatever
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's true, but the thing is that we need to separate the configuration step from the init step, and the builder generated by typed-builder
is not made for this, it's a pain to move around
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO it's more important to have a good API than to have nice code "on the inside".
This is already what you're using (right?) idanarye/rust-typed-builder#80
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from the user's point of view, i think separating configuration from actual initialization is not so bad as well.
it makes more clear what the configuration part is and where qemu is actually getting initialized.
hiding something like qemu initialization in a From
implementation doesn't sound good imho
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No it's really bad for users. We have builders everywhere in the codebase and they all work the same. There's no reason this shoudl work differently. You can still pass around an un-built builder
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but it works like any other builder, right? it's just that the builder doesn't build directly qemu, but qemu's config instead.
i think QemuConfig::builder
makes it quite clear what we are building is not QEMU, right?
|
LibAFL/libafl_qemu/src/emu/builder.rs Lines 127 to 130 in af20343
@rmalmain the problem is that Qemu::init_with_params is run before EMULATOR_MODULES is initialized by Emulator::new_with_qemu
|
* back to one QEMU init function * other small things
* qemu is now a parameter to EmulatorModule callbacks and most function hooks. * EmulatorModules is initialized before QEMU is initialized.
some things we should do at some point:
|
* continue to propagate qemu argument as hook first parameter * use pre_syscall* and post_syscall* everywhere * fix some clippy stuff
…d use the module interface instead. * adapt qemu_launcher example to fully work with emulator, since qemu must now be initialized by emulator.
this pr has an important breaking change: qemu cannot be initialized independently from emulator. if emulator is needed, qemu must be initialized by emulator (before it was possible to initialize qemu and give it to emulator). |
No description provided.