basic/basic.rs
1use vmi_arch_amd64::Amd64;
2use vmi_core::{VcpuId, VmiCore};
3use vmi_driver_xen::VmiXenDriver;
4use xen::XenStore;
5
6fn main() -> Result<(), Box<dyn std::error::Error>> {
7 let domain_id = 'x: {
8 for name in &["win7", "win10", "win11", "ubuntu22"] {
9 if let Some(domain_id) = XenStore::new()?.domain_id_from_name(name)? {
10 break 'x domain_id;
11 }
12 }
13
14 panic!("Domain not found");
15 };
16
17 // Setup VMI.
18 let driver = VmiXenDriver::<Amd64>::new(domain_id)?;
19 let vmi = VmiCore::new(driver)?;
20
21 // Get the interrupt descriptor table for each VCPU and print it.
22 let _pause_guard = vmi.pause_guard()?;
23 let info = vmi.info()?;
24 for vcpu_id in 0..info.vcpus {
25 let registers = vmi.registers(VcpuId(vcpu_id))?;
26 let idt = Amd64::interrupt_descriptor_table(&vmi, ®isters)?;
27
28 println!("IDT[{vcpu_id}]: {idt:#?}");
29 }
30
31 Ok(())
32}