linuxkit: Fix qemu run behaviour when file does not exist

This commit fixes an issue reported on Slack where `linuxkit run` will
assume that a file that is neither a kernel or iso must be a disk image
without first checking that it exists. This would result in `qemu-img`
attempting to create a disk with 0 size due to the default behaviour of
creating disk images that do not exist.

Signed-off-by: Dave Tucker <dt@docker.com>
This commit is contained in:
Dave Tucker 2017-07-13 11:14:20 +01:00
parent 9e5179f11c
commit 94f2d2cd9a

View File

@ -170,6 +170,9 @@ func runQemu(args []string) {
// user not trying to boot off ISO or kernel, so assume booting from a disk image
if !*kernelBoot && !*isoBoot {
if _, err := os.Stat(path); err != nil {
log.Fatalf("Boot disk image %s does not exist", path)
}
// currently no way to set format, but autodetect probably works
d := Disks{DiskConfig{Path: path}}
disks = append(d, disks...)