Check if qemu-img is present before startup

This commit is contained in:
2025-05-26 19:21:40 +02:00
parent ff372800bd
commit de33c7d521
5 changed files with 25 additions and 4 deletions

@ -155,7 +155,7 @@ impl FileDisk {
}
DiskFormat::QCow2 => {
let mut cmd = Command::new("/usr/bin/qemu-img");
let mut cmd = Command::new(constants::QEMU_IMAGE_PROGRAM);
cmd.arg("create")
.arg("-f")
.arg("qcow2")
@ -189,12 +189,13 @@ struct QCowInfoOutput {
/// Get QCow2 virtual size
fn qcow_virt_size(path: &str) -> anyhow::Result<usize> {
// Run qemu-img
let mut cmd = Command::new("qemu-img");
let mut cmd = Command::new(constants::QEMU_IMAGE_PROGRAM);
cmd.args(["info", path, "--output", "json", "--force-share"]);
let output = cmd.output()?;
if !output.status.success() {
anyhow::bail!(
"qemu-img info failed, status: {}, stderr: {}",
"{} info failed, status: {}, stderr: {}",
constants::QEMU_IMAGE_PROGRAM,
output.status,
String::from_utf8_lossy(&output.stderr)
);