From affcde7afb771e2d9838094314222eb0966e02a5 Mon Sep 17 00:00:00 2001 From: Claus Lohmar Date: Tue, 21 Jul 2026 19:11:19 +0000 Subject: [PATCH] fix: provisioner now extracts archives and discovers disks before conversion The job submission receives the original filename (e.g. Debian_13_VMG.7z) but qemu-img convert needs the actual VMDK path inside the archive. Now reuse extract_if_needed() + discover_disk() from converter module to locate the real disk image before conversion. --- backend/provisioner.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/backend/provisioner.py b/backend/provisioner.py index 1044364..fd6217d 100644 --- a/backend/provisioner.py +++ b/backend/provisioner.py @@ -24,10 +24,10 @@ from models import ( JobStatus, DiskType, ) +from converter import extract_if_needed, discover_disk logger = logging.getLogger("backend.provisioner") -STAGING_IN = Path("/mnt/converter/in") STAGING_OUT = Path("/mnt/converter/out") # In-memory job tracking — survives as long as the process runs @@ -164,13 +164,15 @@ def _process_job(job_id: str, req: JobSubmissionRequest): output_path = out_dir / f"vm-{vmid}-disk-{idx}.qcow2" if spec.disk_type == DiskType.IMAGE_FILE: - source_path = STAGING_IN / spec.source_filename - if not source_path.exists(): - raise FileNotFoundError(f"Source file not found: {source_path}") + # Extract archive if needed, then locate the actual disk image + source = extract_if_needed(spec.source_filename) + disk = discover_disk(source) + source_path = disk.path + logger.info("Disk %d: source=%s format=%s size=%.1f GiB", + idx, source_path, disk.format, disk.size_gb) - logger.info("Converting disk %d: %s → %s", idx, source_path, output_path) _run(["qemu-img", "convert", - "-f", spec.format.value if spec.format else "vmdk", + "-f", disk.format, "-O", "qcow2", str(source_path), str(output_path)], timeout=7200)