pub trait HasCallbacks:
Send
+ Sync
+ 'static {
// Provided methods
fn on_vcpu_init(
&mut self,
id: PluginId,
vcpu_id: VCPUIndex,
) -> Result<(), Error> { ... }
fn on_vcpu_exit(
&mut self,
id: PluginId,
vcpu_id: VCPUIndex,
) -> Result<(), Error> { ... }
fn on_vcpu_idle(
&mut self,
id: PluginId,
vcpu_id: VCPUIndex,
) -> Result<(), Error> { ... }
fn on_vcpu_resume(
&mut self,
id: PluginId,
vcpu_id: VCPUIndex,
) -> Result<(), Error> { ... }
fn on_translation_block_translate(
&mut self,
id: PluginId,
tb: TranslationBlock<'_>,
) -> Result<(), Error> { ... }
fn on_flush(&mut self, id: PluginId) -> Result<(), Error> { ... }
fn on_syscall(
&mut self,
id: PluginId,
vcpu_index: VCPUIndex,
num: i64,
a1: u64,
a2: u64,
a3: u64,
a4: u64,
a5: u64,
a6: u64,
a7: u64,
a8: u64,
) -> Result<(), Error> { ... }
fn on_syscall_return(
&mut self,
id: PluginId,
vcpu_index: VCPUIndex,
num: i64,
ret: i64,
) -> Result<(), Error> { ... }
}
Expand description
Trait implemented by structs which have callbacks which should be registered with QEMU.
§Example
struct MyPlugin;
impl qemu_plugin::plugin::HasCallbacks for MyPlugin {
// This callback will be registered on plugin load
fn on_translation_block_translate(&mut self, _: qemu_plugin::PluginId, tb: qemu_plugin::TranslationBlock) -> anyhow::Result<()> {
println!("Translation block translated");
Ok(())
}
}
impl qemu_plugin::plugin::Register for MyPlugin {}
Provided Methods§
Sourcefn on_vcpu_init(
&mut self,
id: PluginId,
vcpu_id: VCPUIndex,
) -> Result<(), Error>
fn on_vcpu_init( &mut self, id: PluginId, vcpu_id: VCPUIndex, ) -> Result<(), Error>
Callback triggered on vCPU init
§Arguments
id
- The ID of the pluginvcpu_id
- The ID of the vCPU
§Example
struct MyPlugin;
impl qemu_plugin::plugin::HasCallbacks for MyPlugin {
fn on_vcpu_init(&mut self, id: qemu_plugin::PluginId, vcpu_id: qemu_plugin::VCPUIndex) -> Result<(), anyhow::Error> {
println!("vCPU {} initialized for plugin {}", vcpu_id, id);
Ok(())
}
}
struct MyPlugin;
Sourcefn on_translation_block_translate(
&mut self,
id: PluginId,
tb: TranslationBlock<'_>,
) -> Result<(), Error>
fn on_translation_block_translate( &mut self, id: PluginId, tb: TranslationBlock<'_>, ) -> Result<(), Error>
Callback triggered on translation block translation
§Arguments
id
- The ID of the plugintb
- The translation block
Sourcefn on_syscall(
&mut self,
id: PluginId,
vcpu_index: VCPUIndex,
num: i64,
a1: u64,
a2: u64,
a3: u64,
a4: u64,
a5: u64,
a6: u64,
a7: u64,
a8: u64,
) -> Result<(), Error>
fn on_syscall( &mut self, id: PluginId, vcpu_index: VCPUIndex, num: i64, a1: u64, a2: u64, a3: u64, a4: u64, a5: u64, a6: u64, a7: u64, a8: u64, ) -> Result<(), Error>
Callback triggered on syscall
§Arguments
id
- The ID of the pluginvcpu_index
- The ID of the vCPUnum
- The syscall numbera1
- The first syscall argumenta2
- The second syscall argumenta3
- The third syscall argumenta4
- The fourth syscall argumenta5
- The fifth syscall argumenta6
- The sixth syscall argumenta7
- The seventh syscall argumenta8
- The eighth syscall argument