Skip to content

Commit

Permalink
examples/singlestep-events: display listen error and break the loop
Browse files Browse the repository at this point in the history
  • Loading branch information
Wenzel committed Dec 20, 2020
1 parent a802dbe commit 4c13f32
Showing 1 changed file with 20 additions and 13 deletions.
33 changes: 20 additions & 13 deletions examples/singlestep-events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,25 +60,32 @@ fn main() {
// listen
let mut i: u64 = 0;
while running.load(Ordering::SeqCst) {
let event = drv.listen(1000).expect("Failed to listen for events");
match event {
Some(ev) => {
match ev.kind {
match drv.listen(1000) {
Err(error) => {
println!("Error while listening for events: {}. Exiting.", error);
break;
}
Ok(event) => {
match event {
Some(ev) => {
match ev.kind {
EventType::Singlestep {} => (),
_ => panic!("Not singlestep event"),
};
let ev_nb_output = format!("{}", i).cyan();
let vcpu_output = format!("VCPU {}", ev.vcpu).yellow();
let singlestep_output = format!("singlestep occurred!").color("blue");
println!(
};
let ev_nb_output = format!("{}", i).cyan();
let vcpu_output = format!("VCPU {}", ev.vcpu).yellow();
let singlestep_output = format!("singlestep occurred!").color("blue");
println!(
"[{}] {} - {}: ",
ev_nb_output, vcpu_output, singlestep_output
);
drv.reply_event(ev, EventReplyType::Continue)
);
drv.reply_event(ev, EventReplyType::Continue)
.expect("Failed to send event reply");
i = i + 1;
i = i + 1;
}
None => println!("No events yet..."),
}
}
None => println!("No events yet..."),
}
}
let duration = start.elapsed();
Expand Down

0 comments on commit 4c13f32

Please sign in to comment.