Skip to content

Commit

Permalink
examples: add --no-pause option for mem-dump
Browse files Browse the repository at this point in the history
  • Loading branch information
Wenzel committed Jul 29, 2021
1 parent b1379ed commit 8b9cbc2
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions examples/mem-dump.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ fn parse_args() -> ArgMatches<'static> {
.author("Mathieu Tarral")
.about("Dumps VM physical memory")
.args(DriverInitParams::to_clap_args().as_ref())
.arg(
Arg::with_name("no-pause")
.long("no-pause")
.required(false)
.takes_value(false)
.help("Don't pause the VM while dumping the memory"),
)
.arg(
Arg::with_name("output")
.short("o")
Expand All @@ -38,6 +45,7 @@ fn main() {
.common
.clone()
.map_or(String::from("unknown_vm_name"), |v| v.vm_name);
let no_pause = matches.is_present("no-pause");
let dump_path = Path::new(
matches
.value_of("output")
Expand All @@ -55,8 +63,10 @@ fn main() {
microvmi::init(None, Some(init_params)).expect("Failed to init libmicrovmi");
spinner.finish_and_clear();

println!("pausing the VM");
drv.pause().expect("Failed to pause VM");
if !no_pause {
println!("pausing the VM");
drv.pause().expect("Failed to pause VM");
}

let max_addr = drv.get_max_physical_addr().unwrap();
println!(
Expand Down Expand Up @@ -96,6 +106,8 @@ fn main() {
dump_path.display()
);

println!("resuming the VM");
drv.resume().expect("Failed to resume VM");
if !no_pause {
println!("resuming the VM");
drv.resume().expect("Failed to resume VM");
}
}

0 comments on commit 8b9cbc2

Please sign in to comment.