runtimejs / runtime-cli

Command line tools for runtime.js
7 stars 5 forks source link

Add --drive, mkimg command #5

Closed facekapow closed 8 years ago

facekapow commented 8 years ago

Adds a --drive option for run, start, and watch to allow attaching disk image files as virtio-blk devices.

Also adds an mkimg command for creating FAT32 images to use them with runtime.js. Depends on qemu-img on all platforms, hdiutil and diskutil on macOS (builtin), losetup and mkfs.msdos on Linux (included on most distributions), and diskpart on Windows (bulitin). Probably should also add code to check whether the commands are present.

Tested on:

iefserge commented 8 years ago

Nice, btw I was able to create a 128M image in MacOS, there might be some minimum size for it

facekapow commented 8 years ago

Ahh, ok, I completely overlooked this as a possibility. A quick search returned a minimum limit for FAT32 of 32763 Kb (~33 Mb). I'll implement a check for minimum image size instead of limiting to Gigabytes.

facekapow commented 8 years ago

I think this is pretty much done. I've added checks to make sure the commands that are going to be used are present, tested on all supported platforms, made the minimum size 33792kb (33mb) for creating images, and tested --drive on all platforms and it works as expected. Any extra suggestions?

iefserge commented 8 years ago

@facekapow not sure why but I get this error when trying to launch it without disk

--- starting qemu ---
qemu-system-x86_64: -drive file=,if=virtio,media=disk,format=raw: Device needs media, but drive is empty
facekapow commented 8 years ago

There we go, should be fixed now. Empty strings weren't being ignored and the default value for the drive parameter is an empty string. Guess I forgot to test one use case, not using it at all :smile:, thanks for catching that. Also changed instanceof Array to Array.isArray().

facekapow commented 8 years ago

Ok to merge?

iefserge commented 8 years ago

@facekapow yeah, this is awesome! 👍 sorry for the delay