-
Notifications
You must be signed in to change notification settings - Fork 4
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
support for windows plugins #4
Conversation
Add initial support for making windows delay-link library which hopefully we will be able to link against. qemu-plugins has win_link_hook which does the runtime link-up to the host qemu.exe. the tiny example compiles and runs for me now. No way to access g_free on windows, so we instead leak memory at the moment.
[lints.rust] | ||
non_snake_case = "allow" |
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.
to stop it complaining about the generated code.
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.
TIL, nice!
//![lints.rust] | ||
//!non_snake_case = "allow" |
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.
again, to suppress warnings. It seems that this generate-bindings.rs script is intended to run standalone, but it compiles everything under src/ directory anyway. I wonder if there's a way to stop it doing that.
@@ -25,7 +29,7 @@ use tar::Archive; | |||
use xz2::read::XzDecoder; | |||
|
|||
const QEMU_SRC_URL_BASE: &str = "https://download.qemu.org/"; | |||
const QEMU_VERSION: &str = "8.1.3"; | |||
const QEMU_VERSION: &str = "8.2.0"; |
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.
this should really be done in a normal upgrade. Probably before this PR.
qemu-plugin/src/lib.rs
Outdated
#[cfg(windows)] | ||
unsafe fn g_free(_mem: *mut c_void){ | ||
//TODO: We would really like to call g_free in the qemu binary here | ||
//but we can't, because windows doesn't export symbols unless you explicitly export them | ||
//and g_free isn't so exported. | ||
|
||
//For now, we're just going to leak. | ||
} |
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.
😢
I'm not sure what we'll be able to do here.
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.
Ouch. I'm not a windows person but is there an equivalent to dlsym/dlopen to get it since we should have glib2 also loaded before us after all?
Wow, this is awesome, quite a productive holiday season 😉 I'll take a look! |
Just merged #5 which includes these commits so I'm going to go ahead and close this one. |
This is intended to fix #3.
Here's my first (mostly successful) go at this. I'll add explanatory comments into the changes, but at a high level:
generate_bindings.rs
now (on windows) also createsqemu_plugin_api.def
build.rs
script forqemu-plugin-sys
(on windows) makes the appropriate delay link .lib file from the .def. This only works in gnu-style toolchains, not -msvc style.qemu-plugin
. It works without further config on the plugins side.g_free
is a problem - windows doesn't expose functions unless asked to, so we don't have an (easy) way of getting access tog_free
. For now I've implemented it as a no-op, and so we leak memory whenever it's used.The tiny example compiles and runs on my windows machine, as does my internal more complex plugin.
tracer
doesn't compile because it usesmemfd
, which doesn't work on windows.Limitations:
-gnu
only, because I'm using dlltool. there may be a way to get this to work on-msvc
, but I've not looked into it.g_free
leaks