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