diff options
author | johannst <johannes.stoelp@gmail.com> | 2021-06-01 22:53:52 +0200 |
---|---|---|
committer | johannst <johannes.stoelp@gmail.com> | 2021-06-01 22:53:52 +0200 |
commit | 9d2859957408b4c719760a7073e54cd3729561f6 (patch) | |
tree | cd926d4f94185af5807213ec2e52c68a0d6db65b /examples/long_mode.rs | |
parent | 387dd9e27b9425f23ff0eb0c6e9ea785a762fd48 (diff) | |
download | mini-kvm-rs-9d2859957408b4c719760a7073e54cd3729561f6.tar.gz mini-kvm-rs-9d2859957408b4c719760a7073e54cd3729561f6.zip |
adapted examples with new exit reasons
Diffstat (limited to 'examples/long_mode.rs')
-rw-r--r-- | examples/long_mode.rs | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/examples/long_mode.rs b/examples/long_mode.rs index 67c014a..668364f 100644 --- a/examples/long_mode.rs +++ b/examples/long_mode.rs @@ -126,7 +126,7 @@ fn setup_long_mode(sregs: &mut kvm_sys::kvm_sregs, mem: &mut UserMem) { fn main() -> std::io::Result<()> { // Create VM & VCPU. let vm = Kvm::new()?.create_vm()?; - let vcpu = vm.create_vpcu(0)?; + let mut vcpu = vm.create_vpcu(0)?; // Map memory for guest VM. let mut mem = UserMem::new(0x8000)?; @@ -155,10 +155,20 @@ fn main() -> std::io::Result<()> { while let Ok(exit) = vcpu.run() { match exit { KvmExit::Halt => break, + KvmExit::IoIn(port, data) => { + println!("IO_IN: port={} len={}", port, data.len()); + // Provide some input data. + data.fill(0xaa); + } KvmExit::IoOut(_port, data) => { let s = std::str::from_utf8(data).unwrap(); print!("{}", s); } + KvmExit::MmioRead(addr, data) => { + println!("MMIO_READ: addr={:#x} len={}", addr, data.len()); + // Provide some read data. + data.fill(0xbb); + } KvmExit::MmioWrite(addr, data) => { println!( "MMIO_WRITE: addr={:#x} len={} data={:#x?}", |