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

Add support for customizable drive and disk format options in QEMU

+18 -2
+18 -2
main.ts
··· 10 10 cpu: string; 11 11 cpus: number; 12 12 memory: string; 13 + drive?: string; 14 + diskFormat: string; 13 15 } 14 16 15 17 async function downloadIso(url: string, outputPath?: string): Promise<string> { ··· 60 62 options.cpus.toString(), 61 63 "-cdrom", 62 64 isoPath, 63 - //"-drive", 64 - //"file=freebsd-vm.img,format=raw,if=virtio", 65 65 "-netdev", 66 66 "user,id=net0,hostfwd=tcp::2222-:22", 67 67 "-device", ··· 73 73 "stdio,id=con0,signal=off", 74 74 "-serial", 75 75 "chardev:con0", 76 + ...(options.drive 77 + ? [ 78 + "-drive", 79 + `file=${options.drive},format=${options.diskFormat},if=virtio`, 80 + ] 81 + : []), 76 82 ], 77 83 stdin: "inherit", 78 84 stdout: "inherit", ··· 128 134 .option("-m, --memory <size:string>", "Amount of memory for the VM", { 129 135 default: "2G", 130 136 }) 137 + .option("-d, --drive <path:string>", "Path to VM disk image") 138 + .option( 139 + "--disk-format <format:string>", 140 + "Disk image format (e.g., qcow2, raw)", 141 + { 142 + default: "raw", 143 + }, 144 + ) 131 145 .example( 132 146 "Default usage", 133 147 "freebsd-up", ··· 159 173 cpu: options.cpu, 160 174 memory: options.memory, 161 175 cpus: options.cpus, 176 + drive: options.drive, 177 + diskFormat: options.diskFormat, 162 178 }); 163 179 }) 164 180 .parse(Deno.args);