Skip to content

Commit 177d2b9

Browse files
committed
sanity check port range
1 parent 4115024 commit 177d2b9

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

pkg/drivers/qemu/qemu.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,10 @@ func parsePortRange(rawPortRange string) (int, int, error) {
270270

271271
portRange := strings.Split(rawPortRange, "-")
272272

273+
if len(portRange) < 2 {
274+
return 0, 0, errors.New("Invalid port range, must be at least of length 2")
275+
}
276+
273277
minPort, err := strconv.Atoi(portRange[0])
274278
if err != nil {
275279
return 0, 0, errors.Wrap(err, "Invalid port range")
@@ -378,7 +382,7 @@ func (d *Driver) Start() error {
378382
// hardware acceleration is important, it increases performance by 10x
379383
if runtime.GOOS == "darwin" {
380384
startCmd = append(startCmd, "-accel", "hvf")
381-
} else if runtime.GOOS == "linux" {
385+
} else if _, err := os.Stat("/dev/kvm"); err == nil && runtime.GOOS == "linux" {
382386
startCmd = append(startCmd, "-accel", "kvm")
383387
}
384388

0 commit comments

Comments
 (0)