A simple, zero-configuration script to quickly boot FreeBSD ISO images using QEMU

Rename 'drive' option to 'image' in options interface and related functions

+11 -11
+3 -3
main.ts
··· 36 36 .option("-m, --memory <size:string>", "Amount of memory for the VM", { 37 37 default: "2G", 38 38 }) 39 - .option("-d, --drive <path:string>", "Path to VM disk image") 39 + .option("-i, --image <path:string>", "Path to VM disk image") 40 40 .option( 41 41 "--disk-format <format:string>", 42 42 "Disk image format (e.g., qcow2, raw)", ··· 102 102 isoPath = await downloadIso(resolvedInput, options); 103 103 } 104 104 105 - if (options.drive) { 105 + if (options.image) { 106 106 await createDriveImageIfNeeded(options); 107 107 } 108 108 109 - if (!input && options.drive && !await emptyDiskImage(options.drive)) { 109 + if (!input && options.image && !await emptyDiskImage(options.image)) { 110 110 isoPath = null; 111 111 } 112 112
+8 -8
src/utils.ts
··· 12 12 cpu: string; 13 13 cpus: number; 14 14 memory: string; 15 - drive?: string; 15 + image?: string; 16 16 diskFormat: string; 17 17 size: string; 18 18 bridge?: string; ··· 47 47 const filename = url.split("/").pop()!; 48 48 const outputPath = options.output ?? filename; 49 49 50 - if (options.drive && await Deno.stat(options.drive).catch(() => false)) { 51 - const driveSize = await du(options.drive); 50 + if (options.image && await Deno.stat(options.image).catch(() => false)) { 51 + const driveSize = await du(options.image); 52 52 if (driveSize > 10) { 53 53 console.log( 54 54 chalk.yellowBright( 55 - `Drive image ${options.drive} is not empty (size: ${driveSize} KB), skipping ISO download to avoid overwriting existing data.`, 55 + `Drive image ${options.image} is not empty (size: ${driveSize} KB), skipping ISO download to avoid overwriting existing data.`, 56 56 ), 57 57 ); 58 58 return null; ··· 176 176 "chardev:con0", 177 177 ...await setupFirmwareFilesIfNeeded(), 178 178 ..._.compact( 179 - options.drive && [ 179 + options.image && [ 180 180 "-drive", 181 - `file=${options.drive},format=${options.diskFormat},if=virtio`, 181 + `file=${options.image},format=${options.diskFormat},if=virtio`, 182 182 ], 183 183 ), 184 184 ], ··· 198 198 diskSize: options.size, 199 199 diskFormat: options.diskFormat, 200 200 isoPath: isoPath ? Deno.realPathSync(isoPath) : undefined, 201 - drivePath: options.drive ? Deno.realPathSync(options.drive) : undefined, 201 + drivePath: options.image ? Deno.realPathSync(options.image) : undefined, 202 202 version: DEFAULT_VERSION, 203 203 status: "RUNNING", 204 204 pid: cmd.pid, ··· 239 239 240 240 export async function createDriveImageIfNeeded( 241 241 { 242 - drive: path, 242 + image: path, 243 243 diskFormat: format, 244 244 size, 245 245 }: Options,