diff --git a/examples/singlestep-events.rs b/examples/singlestep-events.rs index a5c6e2e9..1d95644e 100644 --- a/examples/singlestep-events.rs +++ b/examples/singlestep-events.rs @@ -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();