Skip to content

Commit fd6c6ca

Browse files
committed
feat(vmm): added one-shot
1 parent 9316569 commit fd6c6ca

6 files changed

Lines changed: 1558 additions & 70 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vmm/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ uuid = { workspace = true, features = ["v4"] }
1919
sha2.workspace = true
2020
hex.workspace = true
2121
fs-err.workspace = true
22+
tempfile.workspace = true
2223
dirs.workspace = true
2324
which.workspace = true
2425
clap = { workspace = true, features = ["derive", "string"] }

vmm/src/app/qemu.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ fn create_hd(
6868
image_file: impl AsRef<Path>,
6969
backing_file: Option<impl AsRef<Path>>,
7070
size: &str,
71+
work_dir: Option<impl AsRef<Path>>,
7172
) -> Result<()> {
7273
let mut command = Command::new("qemu-img");
7374
command.arg("create").arg("-f").arg("qcow2");
@@ -79,6 +80,11 @@ fn create_hd(
7980
}
8081
command.arg(image_file.as_ref());
8182
command.arg(size);
83+
84+
// Set working directory if provided
85+
if let Some(work_dir) = work_dir {
86+
command.current_dir(work_dir.as_ref());
87+
}
8288
let output = command.output()?;
8389
if !output.status.success() {
8490
bail!(
@@ -233,7 +239,7 @@ impl VmConfig {
233239
let disk_size = format!("{}G", self.manifest.disk_size);
234240
let hda_path = workdir.hda_path();
235241
if !hda_path.exists() {
236-
create_hd(&hda_path, self.image.hda.as_ref(), &disk_size)?;
242+
create_hd(&hda_path, self.image.hda.as_ref(), &disk_size, Some(&workdir))?;
237243
}
238244
if !cfg.user.is_empty() {
239245
fs_err::set_permissions(&hda_path, Permissions::from_mode(0o660))?;

0 commit comments

Comments
 (0)