Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ pub struct Args {
/// This effectively skips the 5 second startup delay.
#[clap(long, short = 'd')]
pub boot: bool,
/// Mount a persistent store which may be used by OVMF to store non-volatile variables
#[clap(long, short = 'p')]
pub persistent: bool,
}

impl Args {
Expand Down
23 changes: 23 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,29 @@ fn main() {
.additional_args
.extend(args.qemu_args.iter().cloned());

// Prepare persistent mount
if args.persistent {
let persistent_image_path = {
let mut base = std::env::home_dir().unwrap_or(PathBuf::from("/"));
base.push(".uefi-run.persistent.fat");
base
};

if !persistent_image_path.exists() {
EfiImage::new(&persistent_image_path, 0x40_0000)
.expect("Failed to create persistent image");
}

qemu_config.drives.insert(
0,
QemuDriveConfig {
file: persistent_image_path.to_str().unwrap().to_string(),
media: "disk".to_string(),
format: "raw".to_string(),
},
)
}

// Run qemu
let mut qemu_process = qemu_config.run().expect("Failed to start qemu");

Expand Down